From 248b925d52119fef794154a9f2d259976b74180a Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Thu, 27 Nov 2014 17:16:16 +0900 Subject: [PATCH 2/9] Upload initial version Change-Id: Ibcea1acc5dfda7a66d2152104956407f03d60428 --- AUTHORS | 2 + CMakeLists.txt | 62 +++ ChangeLog | 4 + LICENSE | 202 +++++++++ NEWS | 0 NOTICE | 3 + README | 5 + libscl-core.pc.in | 14 + packaging/libscl-core.changes | 0 packaging/libscl-core.manifest | 5 + packaging/libscl-core.spec | 61 +++ src/sclconnection-isf.cpp | 928 +++++++++++++++++++++++++++++++++++++++++ src/sclconnection-isf.h | 92 ++++ src/sclconnection.cpp | 272 ++++++++++++ src/sclconnection.h | 87 ++++ src/sclcore.cpp | 266 ++++++++++++ src/sclcore.h | 307 ++++++++++++++ src/sclcorecallback.h | 101 +++++ src/sclcoreimpl.cpp | 242 +++++++++++ src/sclcoreimpl.h | 107 +++++ src/sclcoretypes.h | 58 +++ src/sclcoreui-efl.cpp | 488 ++++++++++++++++++++++ src/sclcoreui-efl.h | 66 +++ src/sclcoreui.cpp | 107 +++++ src/sclcoreui.h | 84 ++++ 25 files changed, 3563 insertions(+) create mode 100644 AUTHORS create mode 100644 CMakeLists.txt create mode 100644 ChangeLog create mode 100644 LICENSE create mode 100644 NEWS create mode 100644 NOTICE create mode 100644 README create mode 100644 libscl-core.pc.in create mode 100644 packaging/libscl-core.changes create mode 100644 packaging/libscl-core.manifest create mode 100644 packaging/libscl-core.spec create mode 100644 src/sclconnection-isf.cpp create mode 100644 src/sclconnection-isf.h create mode 100644 src/sclconnection.cpp create mode 100644 src/sclconnection.h create mode 100644 src/sclcore.cpp create mode 100644 src/sclcore.h create mode 100644 src/sclcorecallback.h create mode 100644 src/sclcoreimpl.cpp create mode 100644 src/sclcoreimpl.h create mode 100644 src/sclcoretypes.h create mode 100644 src/sclcoreui-efl.cpp create mode 100644 src/sclcoreui-efl.h create mode 100644 src/sclcoreui.cpp create mode 100644 src/sclcoreui.h diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..2e8a0de --- /dev/null +++ b/AUTHORS @@ -0,0 +1,2 @@ +Developer: + Ji-hoon Lee diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..5527ec3 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,62 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(libscl-core CXX) + +SET(SRCS + src/sclcoreui.cpp + src/sclcoreui-efl.cpp + src/sclcoreimpl.cpp + src/sclconnection.cpp + src/sclconnection-isf.cpp + src/sclcore.cpp +) + +SET(PACKAGE ${PROJECT_NAME}) +SET(PKGNAME ${PACKAGE}) +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(LIBDIR "${PREFIX}/lib") + +IF("${CMAKE_BUILD_TYPE}" STREQUAL "") + SET(CMAKE_BUILD_TYPE "Release") +ENDIF() +MESSAGE(STATUS "Build type: ${CMAKE_BUILD_TYPE}") + +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src + ${CMAKE_SOURCE_DIR}/src/include + ) + +INCLUDE(FindPkgConfig) +pkg_check_modules(pkgs REQUIRED + elementary + dlog + isf + vconf + x11 + libscl-common + ) + +FOREACH(flag ${pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall") +SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") +SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -g") + +ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"") +ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"") +ADD_DEFINITIONS("-DLOG_TAG=\"LIBSCL_CORE\"") +ADD_DEFINITIONS("-D__EFL__") + +ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) + +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS}) + +set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "") +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIBDIR}) + +INSTALL(FILES "${CMAKE_SOURCE_DIR}/src/sclcore.h" DESTINATION include/libscl-core) +INSTALL(FILES "${CMAKE_SOURCE_DIR}/src/sclcoretypes.h" DESTINATION include/libscl-core) +INSTALL(FILES "${CMAKE_SOURCE_DIR}/src/sclcorecallback.h" DESTINATION include/libscl-core) + +CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) +INSTALL(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION lib/pkgconfig) diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..f17fd14 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,4 @@ +2014-10-29 11:15 Ji-hoon Lee + + Initial version. + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE @@ -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/NEWS b/NEWS new file mode 100644 index 0000000..e69de29 diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..fa3678d --- /dev/null +++ b/NOTICE @@ -0,0 +1,3 @@ +Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved. +Except as noted, this software is licensed under Apache License, Version 2. +Please, see the LICENSE file for Apache License terms and conditions. diff --git a/README b/README new file mode 100644 index 0000000..47a4b48 --- /dev/null +++ b/README @@ -0,0 +1,5 @@ +libscl-core +============== + +This is a library that helps developing S/W Keyboards. + diff --git a/libscl-core.pc.in b/libscl-core.pc.in new file mode 100644 index 0000000..78aa9c7 --- /dev/null +++ b/libscl-core.pc.in @@ -0,0 +1,14 @@ +# Package Information for pkg-config + +prefix=/usr +exec_prefix=${prefix} +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: libscl-core +Description: SCL Core - A library for developing software keyboards +Version: 1.0 +Requires: libscl-common +Libs: -L${libdir} -lscl-core +Cflags: -I${includedir}/libscl-core + diff --git a/packaging/libscl-core.changes b/packaging/libscl-core.changes new file mode 100644 index 0000000..e69de29 diff --git a/packaging/libscl-core.manifest b/packaging/libscl-core.manifest new file mode 100644 index 0000000..017d22d --- /dev/null +++ b/packaging/libscl-core.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/libscl-core.spec b/packaging/libscl-core.spec new file mode 100644 index 0000000..fd3ef65 --- /dev/null +++ b/packaging/libscl-core.spec @@ -0,0 +1,61 @@ +%define _optdir /opt +%define _appdir %{_optdir}/apps + +Name: libscl-core +Summary: A library for developing software keyboards +Version: 0.0.1 +Release: 1 +Group: System Environment/Libraries +License: Apache License, Version 2.0 +Source0: libscl-core-%{version}.tar.gz +BuildRequires: gettext-tools +BuildRequires: cmake +BuildRequires: pkgconfig(elementary) +BuildRequires: pkgconfig(vconf) +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(isf) +BuildRequires: pkgconfig(x11) +BuildRequires: pkgconfig(libscl-common) + + +%description +A library that helps developing S/W Keyboard + +%package devel +Summary: SCL-Core header file +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} + +%description devel +A devel pacakge of libscl-core library that helps developing S/W Keyboard + +%prep +%setup -q + + +%build +cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +mkdir -p %{buildroot}/usr/share/license +cp LICENSE %{buildroot}/usr/share/license/%{name} + +%make_install + + + +%post + +%postun + +%files +%defattr(-,root,root,-) +%{_libdir}/libscl-core.so +/usr/share/license/%{name} + +%files devel +%defattr(-,root,root,-) +%{_includedir}/* +%{_libdir}/pkgconfig/libscl-core.pc diff --git a/src/sclconnection-isf.cpp b/src/sclconnection-isf.cpp new file mode 100644 index 0000000..d45f912 --- /dev/null +++ b/src/sclconnection-isf.cpp @@ -0,0 +1,928 @@ +/* + * Copyright (c) 2012 - 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + */ + +#include "sclconnection-isf.h" +#include "sclcoreimpl.h" + +#include +#include + +using namespace scl; + +static scim::ConfigPointer _scim_config (0); + +/* Slot functions for calling appropriate callback functions */ +static void slot_exit (const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_ise_hide(ic, ic_uuid.c_str()); + callback->on_exit(); + } + if (agent) { + agent->update_ise_exit(); + } + } + elm_exit (); +} + +static void slot_attach_input_context (const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_attach_input_context(ic, ic_uuid.c_str()); + } + } +} + +static void slot_detach_input_context (const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_detach_input_context(ic, ic_uuid.c_str()); + } + } +} + +static void slot_reload_config (const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_reload_config(ic, ic_uuid.c_str()); + } + } +} + +static void slot_update_screen (const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid, int screen_number) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + //callback->on_update_screen(ic, ic_uuid.c_str(), screen_number); + } + } +} + +static void slot_update_spot_location (const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid, int x, int y) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_update_spot_location(ic, ic_uuid.c_str(), x, y); + } + } +} + +static void slot_update_cursor_position (const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid, int cursor_pos) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_update_cursor_position(ic, ic_uuid.c_str(), cursor_pos); + } + } +} + +static void slot_update_surrounding_text (const scim::HelperAgent *agent, int ic, const scim::String &text, int cursor) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_update_surrounding_text(ic, text.c_str(), cursor); + } + } +} + +static void slot_trigger_property (const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid, const scim::String &property) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + //callback->on_trigger_property(ic, ic_uuid.c_str(), property.c_str()); + } + } +} + +static void slot_focus_out (const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_focus_out(ic, ic_uuid.c_str()); + } + } +} + +static void slot_focus_in (const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_focus_in(ic, ic_uuid.c_str()); + } + } +} + +static void slot_ise_show (const scim::HelperAgent *agent, int ic, char *buf, size_t &len) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + /* Make sure the appropriate keyboard ise was selected -> is this really necessary? */ + //impl->set_keyboard_ise_by_uuid(impl->get_keyboard_ise_uuid().c_str()); + + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + /* Check if effect is enabled */ + Ise_Context ise_context; + memset(&ise_context, 0x00, sizeof(ise_context)); + + if (len >= sizeof(Ise_Context)) { + memcpy(&ise_context, buf, sizeof(ise_context)); + + if (ise_context.imdata_size > 0) { + callback->on_set_imdata(buf + sizeof(ise_context), ise_context.imdata_size); + } + } else { + LOGD("\n-=-= WARNING - buf %p len %d size %d \n", buf, len, sizeof(ise_context)); + } + callback->on_ise_show(ic, impl->get_screen_rotation_degree(), ise_context); + } + } +} + +static void slot_ise_hide (const scim::HelperAgent *agent, int ic, const scim::String &ic_uuid) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_ise_hide(ic, ic_uuid.c_str()); + } + } +} + +static void slot_get_geometry (const scim::HelperAgent *agent, struct scim::rectinfo &info) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_get_geometry(&(info.pos_x), &(info.pos_y), &(info.width), &(info.height)); + } + } +} + +static void slot_set_mode (const scim::HelperAgent *agent, scim::uint32 &mode) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_set_mode(mode); + } + } +} + +static void slot_set_language (const scim::HelperAgent *agent, scim::uint32 &language) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_set_language(language); + } + } +} + +static void slot_set_imdata (const scim::HelperAgent *agent, char *buf, size_t &len) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_set_imdata(buf, len); + } + } +} + +static void slot_get_imdata (const scim::HelperAgent *, char **buf, size_t &len) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_get_imdata(buf, &len); + } + } +} + +static void slot_get_language_locale (const scim::HelperAgent *, int ic, char **locale) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_get_language_locale(ic, locale); + } + } +} + +static void slot_set_return_key_type (const scim::HelperAgent *agent, scim::uint32 &type) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_set_return_key_type(type); + } + } +} + +static void slot_get_return_key_type (const scim::HelperAgent *agent, scim::uint32 &type) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_get_return_key_type(&type); + } + } +} + +static void slot_set_return_key_disable (const scim::HelperAgent *agent, scim::uint32 &disabled) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_set_return_key_disable(disabled); + } + } +} + +static void slot_get_return_key_disable (const scim::HelperAgent *agent, scim::uint32 &disabled) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_get_return_key_disable(&disabled); + } + } +} + +static void slot_set_layout (const scim::HelperAgent *agent, scim::uint32 &layout) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_set_layout(layout); + } + } +} + +static void slot_get_layout (const scim::HelperAgent *agent, scim::uint32 &layout) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_get_layout(&layout); + } + } +} + +static void slot_set_caps_mode (const scim::HelperAgent *agent, scim::uint32 &mode) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_set_caps_mode(mode); + } + } +} + +static void slot_reset_input_context (const scim::HelperAgent *agent, int ic, const scim::String &uuid) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_reset_input_context(ic, uuid.c_str()); + } + } +} + +static void slot_update_candidate_geometry (const scim::HelperAgent *agent, int ic, const scim::String &uuid, const scim::rectinfo &info) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_update_candidate_geometry(ic, uuid.c_str(), info.pos_x, info.pos_y, info.width, info.height); + } + } +} +static void slot_update_keyboard_ise (const scim::HelperAgent *agent, int ic, const scim::String &uuid, + const scim::String &ise_name, const scim::String &ise_uuid) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_update_keyboard_ise(ic, uuid.c_str(), ise_name.c_str(), ise_uuid.c_str()); + } + } +} + +static void slot_candidate_more_window_show (const scim::HelperAgent *agent, int ic, const scim::String &uuid) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_candidate_more_window_show(ic, uuid.c_str()); + } + } +} + +static void slot_candidate_more_window_hide (const scim::HelperAgent *agent, int ic, const scim::String &uuid) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_candidate_more_window_hide(ic, uuid.c_str()); + } + } +} + +static void slot_select_aux (const scim::HelperAgent *agent, int ic, const scim::String &uuid, int index) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_select_aux(ic, uuid.c_str(), index); + } + } +} + +static void slot_select_candidate (const scim::HelperAgent *agent, int ic, const scim::String &uuid, int index) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_select_candidate(ic, uuid.c_str(), index); + } + } +} + +static void slot_candidate_table_page_up (const scim::HelperAgent *agent, int ic, const scim::String &uuid) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_candidate_table_page_up(ic, uuid.c_str()); + } + } +} + +static void slot_candidate_table_page_down (const scim::HelperAgent *agent, int ic, const scim::String &uuid) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_candidate_table_page_down(ic, uuid.c_str()); + } + } +} + +static void slot_update_candidate_table_page_size (const scim::HelperAgent *, int ic, const scim::String &uuid, int page_size) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_update_candidate_table_page_size(ic, uuid.c_str(), page_size); + } + } +} + +static void slot_update_lookup_table (const scim::HelperAgent *, scim::LookupTable &table) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + SclCandidateTable lookup_table; + lookup_table.page_size = table.get_page_size(); + lookup_table.current_page_start = table.get_current_page_start(); + lookup_table.cursor_pos = table.get_cursor_pos(); + lookup_table.cursor_visible = table.is_cursor_visible(); + lookup_table.page_size_fixed = table.is_page_size_fixed(); + lookup_table.candidate_labels.clear(); + for (int page_index = 0;page_index < lookup_table.page_size;page_index++) { + scim::WideString label = table.get_candidate_label(page_index); + lookup_table.candidate_labels.push_back(scim::utf8_wcstombs(label).c_str()); + } + + callback->on_update_lookup_table(lookup_table); + + std::vector labels; + for (int loop = 0;loop < lookup_table.candidate_labels.size();loop) { + labels.push_back(scim::utf8_mbstowcs(lookup_table.candidate_labels.at(loop).c_str())); + } + table.set_candidate_labels(labels); + } + } +} + +static void slot_select_associate (const scim::HelperAgent *agent, int ic, const scim::String &uuid, int index) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_select_associate(ic, uuid.c_str(), index); + } + } +} + +static void slot_associate_table_page_up (const scim::HelperAgent *agent, int ic, const scim::String &uuid) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_associate_table_page_up(ic, uuid.c_str()); + } + } +} + +static void slot_associate_table_page_down (const scim::HelperAgent *agent, int ic, const scim::String &uuid) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_associate_table_page_down(ic, uuid.c_str()); + } + } +} + +static void slot_update_associate_table_page_size (const scim::HelperAgent *, int ic, const scim::String &uuid, int page_size) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_update_associate_table_page_size(ic, uuid.c_str(), page_size); + } + } +} + +static void slot_turn_on_log (const scim::HelperAgent *agent, scim::uint32 &on) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_turn_on_log(on); + } + } +} + +/* Internal input handler function */ +Eina_Bool input_handler (void *data, Ecore_Fd_Handler *fd_handler) +{ + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + scim::HelperAgent *agent = static_cast(data); + if (agent) { + if (agent->has_pending_event()) { + if (!(agent->filter_event())) { + LOGD("helper_agent.filter_event() failed!!!\n"); + impl->fini(); + elm_exit(); + } + } else { + LOGD("helper_agent.has_pending_event() failed!!!\n"); + impl->fini(); + elm_exit(); + } + } + } + + return ECORE_CALLBACK_RENEW; +} + +CSCLConnectionISF::CSCLConnectionISF() +{ + m_initialized = FALSE; + m_fd_handler = NULL; + + m_backend_identifier = "ISF"; +} + +CSCLConnectionISF::~CSCLConnectionISF() +{ +} + +sclboolean CSCLConnectionISF::init() +{ + sclboolean ret = FALSE; + + m_initialized = TRUE; + + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + SclCoreAppInfo appinfo; + callback->on_get_app_info(&appinfo); + m_helper_info.uuid = scim::String(appinfo.uuid.c_str()); + m_helper_info.name = scim::String(appinfo.name.c_str()); + m_helper_info.option = scim::SCIM_HELPER_STAND_ALONE | scim::SCIM_HELPER_NEED_SCREEN_INFO | + scim::SCIM_HELPER_NEED_SPOT_LOCATION_INFO | scim::SCIM_HELPER_AUTO_RESTART; + } + } + + m_helper_agent.signal_connect_exit (scim::slot (slot_exit)); + m_helper_agent.signal_connect_attach_input_context (scim::slot (slot_attach_input_context)); + m_helper_agent.signal_connect_detach_input_context (scim::slot (slot_detach_input_context)); + m_helper_agent.signal_connect_reload_config (scim::slot (slot_reload_config)); + m_helper_agent.signal_connect_update_screen (scim::slot (slot_update_screen)); + m_helper_agent.signal_connect_update_spot_location (scim::slot (slot_update_spot_location)); + m_helper_agent.signal_connect_update_cursor_position (scim::slot (slot_update_cursor_position)); + m_helper_agent.signal_connect_update_surrounding_text (scim::slot (slot_update_surrounding_text)); + m_helper_agent.signal_connect_trigger_property (scim::slot (slot_trigger_property)); + //m_helper_agent.signal_connect_process_imengine_event (slot (slot_process_imengine_event)); + m_helper_agent.signal_connect_focus_out (scim::slot (slot_focus_out)); + m_helper_agent.signal_connect_focus_in (scim::slot (slot_focus_in)); + m_helper_agent.signal_connect_ise_show (scim::slot (slot_ise_show)); + m_helper_agent.signal_connect_ise_hide (scim::slot (slot_ise_hide)); + m_helper_agent.signal_connect_get_geometry (scim::slot (slot_get_geometry)); + m_helper_agent.signal_connect_set_mode (scim::slot (slot_set_mode)); + m_helper_agent.signal_connect_set_language (scim::slot (slot_set_language)); + m_helper_agent.signal_connect_set_imdata (scim::slot (slot_set_imdata)); + m_helper_agent.signal_connect_get_imdata (scim::slot (slot_get_imdata)); + m_helper_agent.signal_connect_get_language_locale (scim::slot (slot_get_language_locale)); + m_helper_agent.signal_connect_set_return_key_type (scim::slot (slot_set_return_key_type)); + m_helper_agent.signal_connect_get_return_key_type (scim::slot (slot_get_return_key_type)); + m_helper_agent.signal_connect_set_return_key_disable (scim::slot (slot_set_return_key_disable)); + m_helper_agent.signal_connect_get_return_key_disable (scim::slot (slot_get_return_key_disable)); + m_helper_agent.signal_connect_get_layout (scim::slot (slot_get_layout)); + m_helper_agent.signal_connect_set_layout (scim::slot (slot_set_layout)); + m_helper_agent.signal_connect_set_caps_mode (scim::slot (slot_set_caps_mode)); + m_helper_agent.signal_connect_reset_input_context (scim::slot (slot_reset_input_context)); + m_helper_agent.signal_connect_update_candidate_geometry (scim::slot (slot_update_candidate_geometry)); + m_helper_agent.signal_connect_update_keyboard_ise (scim::slot (slot_update_keyboard_ise)); + //m_helper_agent.signal_connect_update_keyboard_ise_list (slot (slot_update_keyboard_ise_list)); + m_helper_agent.signal_connect_candidate_more_window_show (scim::slot (slot_candidate_more_window_show)); + m_helper_agent.signal_connect_candidate_more_window_hide (scim::slot (slot_candidate_more_window_hide)); + m_helper_agent.signal_connect_select_aux (scim::slot (slot_select_aux)); + m_helper_agent.signal_connect_select_candidate (scim::slot (slot_select_candidate)); + m_helper_agent.signal_connect_candidate_table_page_up (scim::slot (slot_candidate_table_page_up)); + m_helper_agent.signal_connect_candidate_table_page_down (scim::slot (slot_candidate_table_page_down)); + m_helper_agent.signal_connect_update_candidate_table_page_size (scim::slot (slot_update_candidate_table_page_size)); + m_helper_agent.signal_connect_update_lookup_table (scim::slot (slot_update_lookup_table)); + m_helper_agent.signal_connect_select_associate (scim::slot (slot_select_associate)); + m_helper_agent.signal_connect_associate_table_page_up (scim::slot (slot_associate_table_page_up)); + m_helper_agent.signal_connect_associate_table_page_down (scim::slot (slot_associate_table_page_down)); + m_helper_agent.signal_connect_update_associate_table_page_size (scim::slot (slot_update_associate_table_page_size)); + m_helper_agent.signal_connect_turn_on_log (scim::slot (slot_turn_on_log)); + + + return ret; +} + +void CSCLConnectionISF::fini() +{ + close_connection(); + m_initialized = FALSE; +} + +void CSCLConnectionISF::open_connection(const sclchar *display) +{ + if (m_initialized) { + m_helper_agent.open_connection(m_helper_info, display); + int fd = m_helper_agent.get_connection_number(); + + if (fd >= 0) { + Evas_Object *main_window = NULL; + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + main_window = NATIVE_WINDOW_CAST(impl->get_main_window()); + } + Ecore_X_Window xwindow = elm_win_xwindow_get(main_window); + char xid[255]; + snprintf(xid, 255, "%d", xwindow); + scim::Property prop(xid, "XID", "", ""); + scim::PropertyList props; + props.push_back(prop); + m_helper_agent.register_properties(props); + + m_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, input_handler, &m_helper_agent, NULL, NULL); + } + } +} +void CSCLConnectionISF::close_connection() +{ + if (m_initialized) { + if (m_fd_handler) { + ecore_main_fd_handler_del(m_fd_handler); + m_fd_handler = NULL; + } + m_helper_agent.update_ise_exit(); + m_helper_agent.close_connection(); + } +} + +void CSCLConnectionISF::config_reload() +{ + if (m_initialized) { + m_helper_agent.reload_config(); + } +} + +sclboolean CSCLConnectionISF::config_read_int(const sclchar *name, sclint &value) +{ + sclboolean ret = FALSE; + if (m_initialized && _scim_config) { + value = _scim_config->read(name, value); + } + return ret; +} + +sclboolean CSCLConnectionISF::config_read_string(const sclchar *name, std::string &value) +{ + sclboolean ret = FALSE; + if (m_initialized && _scim_config) { + value = _scim_config->read(name, value); + } + return ret; +} + +sclboolean CSCLConnectionISF::config_write_int(const sclchar *name, sclint value) +{ + sclboolean ret = FALSE; + if (m_initialized && _scim_config) { + _scim_config->write(name, value); + } + return ret; +} + +sclboolean CSCLConnectionISF::config_write_string(const sclchar *name, const std::string value) +{ + sclboolean ret = FALSE; + if (m_initialized && _scim_config) { + _scim_config->write(name, value); + } + return ret; +} + +sclboolean CSCLConnectionISF::config_erase(const sclchar *name) +{ + sclboolean ret = FALSE; + if (m_initialized && _scim_config) { + _scim_config->erase(name); + } + return ret; +} + +void CSCLConnectionISF::send_imengine_event(sclint ic, const sclchar *ic_uuid, const sclint command, const sclu32 value) +{ + if (m_initialized) { + scim::String uuid; + if (ic_uuid) { + uuid = scim::String(ic_uuid); + } + scim::Transaction trans; + trans.put_command(command); + trans.put_data (value); + m_helper_agent.send_imengine_event(ic, uuid, trans); + } +} + +void CSCLConnectionISF::reset_keyboard_ise() +{ + if (m_initialized) { + m_helper_agent.reset_keyboard_ise(); + } +} + +void CSCLConnectionISF::send_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask) +{ + if (m_initialized) { + scim::String uuid; + if (ic_uuid) { + uuid = scim::String(ic_uuid); + } + scim::KeyEvent event; + event.code = keycode; + event.mask = keymask; + m_helper_agent.send_key_event(ic, uuid, event); + } +} + +void CSCLConnectionISF::forward_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask) +{ + if (m_initialized) { + scim::String uuid; + if (ic_uuid) { + uuid = scim::String(ic_uuid); + } + scim::KeyEvent event; + event.code = keycode; + event.mask = keymask; + m_helper_agent.forward_key_event(ic, uuid, event); + } +} + +void CSCLConnectionISF::commit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str) +{ + if (m_initialized) { + scim::String uuid; + if (ic_uuid) { + uuid = scim::String(ic_uuid); + } + m_helper_agent.commit_string(ic, uuid, scim::utf8_mbstowcs(str)); + } +} + +void CSCLConnectionISF::select_candidate(int index) +{ + if (m_initialized) { + m_helper_agent.select_candidate(index); + } +} + +void CSCLConnectionISF::show_preedit_string(sclint ic, const sclchar *ic_uuid) +{ + if (m_initialized) { + scim::String uuid; + if (ic_uuid) { + uuid = scim::String(ic_uuid); + } + m_helper_agent.show_preedit_string(ic, uuid); + } +} + +void CSCLConnectionISF::show_aux_string(void) +{ + if (m_initialized) { + m_helper_agent.show_aux_string(); + } +} + +void CSCLConnectionISF::show_candidate_string(void) +{ + if (m_initialized) { + m_helper_agent.show_candidate_string(); + } +} + +void CSCLConnectionISF::show_associate_string(void) +{ + if (m_initialized) { + m_helper_agent.show_associate_string(); + } +} + +void CSCLConnectionISF::hide_preedit_string(sclint ic, const sclchar *ic_uuid) +{ + if (m_initialized) { + scim::String uuid; + if (ic_uuid) { + uuid = scim::String(ic_uuid); + } + m_helper_agent.hide_preedit_string(ic, uuid); + } +} + +void CSCLConnectionISF::hide_aux_string(void) +{ + if (m_initialized) { + m_helper_agent.hide_aux_string(); + } +} + +void CSCLConnectionISF::hide_candidate_string(void) +{ + if (m_initialized) { + m_helper_agent.hide_candidate_string(); + } +} + +void CSCLConnectionISF::hide_associate_string(void) +{ + if (m_initialized) { + m_helper_agent.hide_associate_string(); + } +} + +void CSCLConnectionISF::update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str) +{ + if (m_initialized) { + scim::AttributeList list; + scim::String uuid; + if (ic_uuid) { + uuid = scim::String(ic_uuid); + } + m_helper_agent.update_preedit_string(ic, uuid, scim::utf8_mbstowcs(str), list); + + if (str && strlen(str) > 0) { + show_preedit_string(ic, ic_uuid); + } else { + hide_preedit_string(ic, ic_uuid); + } + } +} + +void CSCLConnectionISF::update_aux_string(const sclchar *str) +{ + if (m_initialized) { + scim::AttributeList list; + m_helper_agent.update_aux_string(scim::String(str), list); + } +} + +void CSCLConnectionISF::update_input_context(sclu32 type, sclu32 value) +{ + if (m_initialized) { + m_helper_agent.update_input_context(type, value); + } +} + +void CSCLConnectionISF::set_candidate_position(sclint left, sclint top) +{ + if (m_initialized) { + m_helper_agent.set_candidate_position(left, top); + } +} + +void CSCLConnectionISF::candidate_hide(void) +{ + if (m_initialized) { + m_helper_agent.candidate_hide(); + } +} + +void CSCLConnectionISF::set_keyboard_ise_by_uuid(const sclchar *uuid) +{ + if (m_initialized) { + m_helper_agent.set_keyboard_ise_by_uuid(uuid); + } +} + +void CSCLConnectionISF::get_keyboard_ise(const sclchar *uuid) +{ + if (m_initialized) { + m_helper_agent.get_keyboard_ise(uuid); + } +} + +extern "C" +{ + void scim_module_init (void) { + } + + void scim_module_exit (void) { + } + + unsigned int scim_helper_module_number_of_helpers (void) { + return 1; + } + + bool scim_helper_module_get_helper_info (unsigned int idx, scim::HelperInfo &info) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + SclCoreAppInfo appinfo; + callback->on_get_app_info(&appinfo); + info.uuid = scim::String(appinfo.uuid.c_str()); + info.name = scim::String(appinfo.name.c_str()); + info.option = scim::SCIM_HELPER_STAND_ALONE | scim::SCIM_HELPER_NEED_SCREEN_INFO | + scim::SCIM_HELPER_NEED_SPOT_LOCATION_INFO | scim::SCIM_HELPER_AUTO_RESTART; + + return true; + } + } + return false; + } + + scim::String scim_helper_module_get_helper_language (unsigned int idx) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + SclCoreAppInfo appinfo; + callback->on_get_app_info(&appinfo); + return scim::String(appinfo.language.c_str()); + } + } + return scim::String(""); + } + + void scim_helper_module_run_helper (const scim::String &uuid, const scim::ConfigPointer &config, const scim::String &display) { + _scim_config = config; + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + impl->run(display.c_str()); + } + } +} diff --git a/src/sclconnection-isf.h b/src/sclconnection-isf.h new file mode 100644 index 0000000..bd66e42 --- /dev/null +++ b/src/sclconnection-isf.h @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2012 - 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + */ + +#ifndef __SCL_CONNECTION_ISF_H__ +#define __SCL_CONNECTION_ISF_H__ + +#define Uses_SCIM_UTILITY +#define Uses_SCIM_OBJECT +#define Uses_SCIM_POINTER +#define Uses_SCIM_EVENT +#define Uses_SCIM_HELPER +#define Uses_SCIM_CONFIG_BASE + +#include +#include +#include +#include "sclconnection.h" + +//SCL_BEGIN_DECLS + +namespace scl +{ + +class CSCLConnectionISF : public CSCLConnection +{ +public: + CSCLConnectionISF(); + ~CSCLConnectionISF(); + + virtual sclboolean init(); + virtual void fini(); + + virtual void open_connection(const sclchar *display); + virtual void close_connection(); + + void config_reload(); + sclboolean config_read_int(const sclchar *name, sclint &value); + sclboolean config_read_string(const sclchar *name, std::string &value); + sclboolean config_write_int(const sclchar *name, sclint value); + sclboolean config_write_string(const sclchar *name, const std::string value); + sclboolean config_erase(const sclchar *name); + + void send_imengine_event(sclint ic, const sclchar *ic_uuid, const sclint command, const sclu32 value); + void reset_keyboard_ise(); + void send_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask); + void forward_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask); + void commit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str); + void select_candidate(int index); + void show_preedit_string(sclint ic, const sclchar *ic_uuid); + void show_aux_string(void); + void show_candidate_string(void); + void show_associate_string(void); + void hide_preedit_string(sclint ic, const sclchar *ic_uuid); + void hide_aux_string(void); + void hide_candidate_string(void); + void hide_associate_string(void); + void update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str); + void update_aux_string(const sclchar *str); + void update_input_context(sclu32 type, sclu32 value); + void set_candidate_position(sclint left, sclint top); + void candidate_hide(void); + void set_keyboard_ise_by_uuid(const sclchar *uuid); + void get_keyboard_ise(const sclchar *uuid); + +private: + sclboolean m_initialized; + + scim::HelperInfo m_helper_info; + scim::HelperAgent m_helper_agent; + + Ecore_Fd_Handler *m_fd_handler; +}; + +} + +//SCL_END_DECLS + +#endif //__SCL_CONNECTION_ISF_H__ diff --git a/src/sclconnection.cpp b/src/sclconnection.cpp new file mode 100644 index 0000000..8cd59aa --- /dev/null +++ b/src/sclconnection.cpp @@ -0,0 +1,272 @@ +/* + * Copyright (c) 2012 - 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + */ + +#include "sclconnection.h" + +#include "sclconnection-isf.h" + +using namespace scl; + +CSCLConnection::CSCLConnection() +{ + m_backend_identifier = "undefined"; + m_impl = NULL; +} + +CSCLConnection::~CSCLConnection() +{ +} + +std::string CSCLConnection::get_backend_indentifier() +{ + return m_backend_identifier; +} + +sclboolean CSCLConnection::init() +{ + sclboolean ret = FALSE; + if (m_impl == NULL) { + /* There could be other backend implementations.. */ + m_impl = new CSCLConnectionISF; + } + if (m_impl) { + ret = m_impl->init(); + } + return ret; +} + +void CSCLConnection::fini() +{ + if (m_impl) { + m_impl->fini(); + delete m_impl; + m_impl = NULL; + } +} + +void CSCLConnection::open_connection(const sclchar *display) +{ + if (m_impl) { + m_impl->open_connection(display); + } +} + +void CSCLConnection::close_connection() +{ + if (m_impl) { + m_impl->close_connection(); + } +} + +void CSCLConnection::config_reload() +{ + if (m_impl) { + m_impl->config_reload(); + } +} + +sclboolean CSCLConnection::config_read_int(const sclchar *name, sclint &value) +{ + sclboolean ret = FALSE; + if (m_impl) { + ret = m_impl->config_read_int(name, value); + } + return ret; +} + +sclboolean CSCLConnection::config_read_string(const sclchar *name, std::string &value) +{ + sclboolean ret = FALSE; + if (m_impl) { + ret = m_impl->config_read_string(name, value); + } + return ret; +} + +sclboolean CSCLConnection::config_write_int(const sclchar *name, sclint value) +{ + sclboolean ret = FALSE; + if (m_impl) { + ret = m_impl->config_write_int(name, value); + } + return ret; +} + +sclboolean CSCLConnection::config_write_string(const sclchar *name, const std::string value) +{ + sclboolean ret = FALSE; + if (m_impl) { + ret = m_impl->config_write_string(name, value); + } + return ret; +} + +sclboolean CSCLConnection::config_erase(const sclchar *name) +{ + sclboolean ret = FALSE; + if (m_impl) { + ret = m_impl->config_erase(name); + } + return ret; +} + +void CSCLConnection::send_imengine_event(sclint ic, const sclchar *ic_uuid, const sclint command, const sclu32 value) +{ + if (m_impl) { + m_impl->send_imengine_event(ic, ic_uuid, command, value); + } +} + +void CSCLConnection::reset_keyboard_ise() +{ + if (m_impl) { + m_impl->reset_keyboard_ise(); + } +} + +void CSCLConnection::send_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask) +{ + if (m_impl) { + m_impl->send_key_event(ic, ic_uuid, keycode, keymask); + } +} + +void CSCLConnection::forward_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask) +{ + if (m_impl) { + m_impl->forward_key_event(ic, ic_uuid, keycode, keymask); + } +} + +void CSCLConnection::commit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str) +{ + if (m_impl) { + m_impl->commit_string(ic, ic_uuid, str); + } +} + +void CSCLConnection::select_candidate(int index) +{ + if (m_impl) { + m_impl->select_candidate(index); + } +} + +void CSCLConnection::show_preedit_string(sclint ic, const sclchar *ic_uuid) +{ + if (m_impl) { + m_impl->show_preedit_string(ic, ic_uuid); + } +} + +void CSCLConnection::show_aux_string(void) +{ + if (m_impl) { + m_impl->show_aux_string(); + } +} + +void CSCLConnection::show_candidate_string(void) +{ + if (m_impl) { + m_impl->show_candidate_string(); + } +} + +void CSCLConnection::show_associate_string(void) +{ + if (m_impl) { + m_impl->show_associate_string(); + } +} + +void CSCLConnection::hide_preedit_string(sclint ic, const sclchar *ic_uuid) +{ + if (m_impl) { + m_impl->hide_preedit_string(ic, ic_uuid); + } +} + +void CSCLConnection::hide_aux_string(void) +{ + if (m_impl) { + m_impl->hide_aux_string(); + } +} + +void CSCLConnection::hide_candidate_string(void) +{ + if (m_impl) { + m_impl->hide_candidate_string(); + } +} + +void CSCLConnection::hide_associate_string(void) +{ + if (m_impl) { + m_impl->hide_associate_string(); + } +} + +void CSCLConnection::update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str) +{ + if (m_impl) { + m_impl->update_preedit_string(ic, ic_uuid, str); + } +} + +void CSCLConnection::update_aux_string(const sclchar *str) +{ + if (m_impl) { + m_impl->update_aux_string(str); + } +} + +void CSCLConnection::update_input_context(sclu32 type, sclu32 value) +{ + if (m_impl) { + m_impl->update_input_context(type, value); + } +} + +void CSCLConnection::set_candidate_position(sclint left, sclint top) +{ + if (m_impl) { + m_impl->set_candidate_position(left, top); + } +} + +void CSCLConnection::candidate_hide(void) +{ + if (m_impl) { + m_impl->candidate_hide(); + } +} + +void CSCLConnection::set_keyboard_ise_by_uuid(const sclchar *uuid) +{ + if (m_impl) { + m_impl->set_keyboard_ise_by_uuid(uuid); + } +} + +void CSCLConnection::get_keyboard_ise(const sclchar *uuid) +{ + if (m_impl) { + m_impl->get_keyboard_ise(uuid); + } +} diff --git a/src/sclconnection.h b/src/sclconnection.h new file mode 100644 index 0000000..0179d25 --- /dev/null +++ b/src/sclconnection.h @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2012 - 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + */ + +#ifndef __SCL_CONNECTION_H__ +#define __SCL_CONNECTION_H__ + +#include +#include "scltypes.h" +//SCL_BEGIN_DECLS + +namespace scl +{ +/** + * @brief The base class to work as a soft-based keyboard + * + * This class implements all functions for working as a soft-based keyboard + * In side of ISE developer, they can modify it by their requirements. + */ +class CSCLConnection +{ +public: + CSCLConnection(); + ~CSCLConnection(); + + std::string get_backend_indentifier(); + + virtual sclboolean init(); + virtual void fini(); + + virtual void open_connection(const sclchar *display); + virtual void close_connection(); + + virtual void config_reload(); + virtual sclboolean config_read_int(const sclchar *name, sclint &value); + virtual sclboolean config_read_string(const sclchar *name, std::string &value); + virtual sclboolean config_write_int(const sclchar *name, sclint value); + virtual sclboolean config_write_string(const sclchar *name, const std::string value); + virtual sclboolean config_erase(const sclchar *name); + + virtual void send_imengine_event(sclint ic, const sclchar *ic_uuid, const sclint command, const sclu32 value); + virtual void reset_keyboard_ise(); + virtual void send_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask); + virtual void forward_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask); + virtual void commit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str); + virtual void select_candidate(int index); + virtual void show_preedit_string(sclint ic, const sclchar *ic_uuid); + virtual void show_aux_string(void); + virtual void show_candidate_string(void); + virtual void show_associate_string(void); + virtual void hide_preedit_string(sclint ic, const sclchar *ic_uuid); + virtual void hide_aux_string(void); + virtual void hide_candidate_string(void); + virtual void hide_associate_string(void); + virtual void update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str); + virtual void update_aux_string(const sclchar *str); + virtual void update_input_context(sclu32 type, sclu32 value); + virtual void set_candidate_position(sclint left, sclint top); + virtual void candidate_hide(void); + virtual void set_keyboard_ise_by_uuid(const sclchar *uuid); + virtual void get_keyboard_ise(const sclchar *uuid); + +protected: + std::string m_backend_identifier; + +private: + CSCLConnection *m_impl; +}; + +} + +//SCL_END_DECLS + +#endif //__SCL_CONNECTION_H__ diff --git a/src/sclcore.cpp b/src/sclcore.cpp new file mode 100644 index 0000000..9a27e93 --- /dev/null +++ b/src/sclcore.cpp @@ -0,0 +1,266 @@ +/* + * Copyright (c) 2012 - 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + */ + +#include "sclcore.h" +#include "sclcoreimpl.h" + +using namespace scl; + +CSCLCore::CSCLCore(ISCLCoreEventCallback *callback) +{ + m_impl = CSCLCoreImpl::get_instance(); + + if (m_impl) { + m_impl->set_core_event_callback(callback); + } +} + +CSCLCore::~CSCLCore() +{ + m_impl = NULL; +} + +void CSCLCore::config_reload() +{ + if (m_impl) { + m_impl->config_reload(); + } +} + +sclboolean CSCLCore::config_read_int(const sclchar *name, sclint &value) +{ + sclboolean ret = FALSE; + if (m_impl) { + ret = m_impl->config_read_int(name, value); + } + return ret; +} + +sclboolean CSCLCore::config_read_string(const sclchar *name, std::string &value) +{ + sclboolean ret = FALSE; + if (m_impl) { + ret = m_impl->config_read_string(name, value); + } + return ret; +} + +sclboolean CSCLCore::config_write_int(const sclchar *name, sclint value) +{ + sclboolean ret = FALSE; + if (m_impl) { + ret = m_impl->config_write_int(name, value); + } + return ret; +} + +sclboolean CSCLCore::config_write_string(const sclchar *name, const std::string value) +{ + sclboolean ret = FALSE; + if (m_impl) { + ret = m_impl->config_write_string(name, value); + } + return ret; +} + +sclboolean CSCLCore::config_erase(const sclchar *name) +{ + sclboolean ret = FALSE; + if (m_impl) { + ret = m_impl->config_erase(name); + } + return ret; +} + +void CSCLCore::send_imengine_event(sclint ic, const sclchar *ic_uuid, const sclint command, const sclu32 value) +{ + if (m_impl) { + m_impl->send_imengine_event(ic, ic_uuid, command, value); + } +} + +void CSCLCore::reset_keyboard_ise() +{ + if (m_impl) { + m_impl->reset_keyboard_ise(); + } +} + +void CSCLCore::send_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask) +{ + if (m_impl) { + m_impl->send_key_event(ic, ic_uuid, keycode, keymask); + } +} + +void CSCLCore::forward_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask) +{ + if (m_impl) { + m_impl->forward_key_event(ic, ic_uuid, keycode, keymask); + } +} + +void CSCLCore::commit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str) +{ + if (m_impl) { + m_impl->commit_string(ic, ic_uuid, str); + } +} + +void CSCLCore::select_candidate(int index) +{ + if (m_impl) { + m_impl->select_candidate(index); + } +} + +void CSCLCore::show_preedit_string(sclint ic, const sclchar *ic_uuid) +{ + if (m_impl) { + m_impl->show_preedit_string(ic, ic_uuid); + } +} + +void CSCLCore::show_aux_string(void) +{ + if (m_impl) { + m_impl->show_aux_string(); + } +} + +void CSCLCore::show_candidate_string(void) +{ + if (m_impl) { + m_impl->show_candidate_string(); + } +} + +void CSCLCore::show_associate_string(void) +{ + if (m_impl) { + m_impl->show_associate_string(); + } +} + +void CSCLCore::hide_preedit_string(sclint ic, const sclchar *ic_uuid) +{ + if (m_impl) { + m_impl->hide_preedit_string(ic, ic_uuid); + } +} + +void CSCLCore::hide_aux_string(void) +{ + if (m_impl) { + m_impl->hide_aux_string(); + } +} + +void CSCLCore::hide_candidate_string(void) +{ + if (m_impl) { + m_impl->hide_candidate_string(); + } +} + +void CSCLCore::hide_associate_string(void) +{ + if (m_impl) { + m_impl->hide_associate_string(); + } +} + +void CSCLCore::update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str) +{ + if (m_impl) { + m_impl->update_preedit_string(ic, ic_uuid, str); + } +} + +void CSCLCore::update_aux_string(const sclchar *str) +{ + if (m_impl) { + m_impl->update_aux_string(str); + } +} + +void CSCLCore::update_input_context(sclu32 type, sclu32 value) +{ + if (m_impl) { + m_impl->update_input_context(type, value); + } +} + +void CSCLCore::set_candidate_position(sclint left, sclint top) +{ + if (m_impl) { + m_impl->set_candidate_position(left, top); + } +} + +void CSCLCore::candidate_hide(void) +{ + if (m_impl) { + m_impl->candidate_hide(); + } +} + +void CSCLCore::set_keyboard_ise_by_uuid(const sclchar *uuid) +{ + if (m_impl) { + m_impl->set_keyboard_ise_by_uuid(uuid); + } +} + +void CSCLCore::get_keyboard_ise(const sclchar *uuid) +{ + if (m_impl) { + m_impl->get_keyboard_ise(uuid); + } +} + +sclwindow CSCLCore::get_main_window() +{ + sclwindow ret = SCLWINDOW_INVALID; + if (m_impl) { + ret = m_impl->get_main_window(); + } + return ret; +} + +void CSCLCore::set_keyboard_size_hints(SclSize portrait, SclSize landscape) +{ + if (m_impl) { + m_impl->set_keyboard_size_hints(portrait, landscape); + } +} + +sclwindow CSCLCore::create_option_window() +{ + sclwindow ret = SCLWINDOW_INVALID; + if (m_impl) { + ret = m_impl->create_option_window(); + } + return ret; +} + +void CSCLCore::destroy_option_window(sclwindow window) +{ + if (m_impl) { + m_impl->destroy_option_window(window); + } +} \ No newline at end of file diff --git a/src/sclcore.h b/src/sclcore.h new file mode 100644 index 0000000..78dd569 --- /dev/null +++ b/src/sclcore.h @@ -0,0 +1,307 @@ +/* + * Copyright (c) 2012 - 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + */ + +#ifndef __SCL_CORE_H__ +#define __SCL_CORE_H__ + +//SCL_BEGIN_DECLS + +#include + +#include +#include "sclcoretypes.h" +#include "sclcorecallback.h" + +namespace scl +{ + +/* To use pimpl idiom */ +class CSCLCoreImpl; + +/** + * @brief The base class that provides features for a soft-keyboard + * + * This class implements all functions for working as a soft-based keyboard + */ +class CSCLCore +{ +public: + CSCLCore(ISCLCoreEventCallback *callback); + ~CSCLCore(); + + /** + * @brief Request ISF to reload all configuration. + */ + void config_reload(); + + /** + * @brief Request ISF to read a integer value with given key name. + */ + sclboolean config_read_int(const sclchar *name, sclint &value); + + /** + * @brief Request ISF to read a string value with given key name. + */ + sclboolean config_read_string(const sclchar *name, std::string &value); + + /** + * @brief Request ISF to write a integer value with given key name. + */ + sclboolean config_write_int(const sclchar *name, sclint value); + + /** + * @brief Request ISF to write a string value with given key name. + */ + sclboolean config_write_string(const sclchar *name, const std::string value); + + /** + * @brief Request ISF to erase stored value with given key name. + */ + sclboolean config_erase(const sclchar *name); + + /** + * @brief Send an Event to IMEngine + * + * @param[in] ic The handle of the IMEngineInstance to receive the event. + * -1 means the currently focused IMEngineInstance. + * @param[in] ic_uuid The UUID of the IMEngineInstance. NULL means don't match. + * @param[in] command The command to be sent. + * @param[in] value The value corresponding to the command. + */ + void send_imengine_event(sclint ic, const sclchar *ic_uuid, const sclint command, const sclu32 value); + + /** + * @brief Send a reset keyboard Event to IMEngine + */ + void reset_keyboard_ise(); + + /** + * @brief Send a KeyEvent to ISF + * + * @param[in] ic The handle of the IMEngineInstance to receive the event. + * -1 means the currently focused IMEngineInstance. + * @param[in] ic_uuid The UUID of the IMEngineInstance. NULL means don't match. + * @param[in] keycode The KeyEvent to be sent. + * @param[in] keymask The modifier key mask + */ + void send_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask); + + /** + * @brief Forward a KeyEvent to client application directly. + * + * @param[in] ic The handle of the client Input Context to receive the event. + * -1 means the currently focused Input Context. + * @param[in] ic_uuid The UUID of the IMEngineInstance. NULL means don't match. + * @param[in] keycode The KeyEvent to be sent. + * @param[in] keymask The modifier key mask + */ + void forward_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask); + + /** + * @brief Commit a string to client application directly. + * + * @param[in] ic The handle of the client Input Context to receive the WideString. + * -1 means the currently focused Input Context. + * @param[in] ic_uuid The UUID of the IMEngine used by the Input Context. + * NULL means don't match. + * @param[in] str The UTF-8 string to be committed. + */ + void commit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str); + + void select_candidate(int index); + /** + * @brief Request to show preedit string. + * + * @param[in] ic The handle of the client Input Context to receive the request. + * -1 means the currently focused Input Context. + * @param[in] ic_uuid The UUID of the IMEngine used by the Input Context. + * NULL means don't match. + */ + void show_preedit_string(sclint ic, const sclchar *ic_uuid); + + /** + * @brief Request to show aux string. + */ + void show_aux_string(void); + + /** + * @brief Request to show candidate string. + */ + void show_candidate_string(void); + + /** + * @brief Request to show associate string. + */ + void show_associate_string(void); + + /** + * @brief Request to hide preedit string. + * + * @param[in] ic The handle of the client Input Context to receive the request. + * -1 means the currently focused Input Context. + * @param[in] ic_uuid The UUID of the IMEngine used by the Input Context. + * NULL means don't match. + */ + void hide_preedit_string(sclint ic, const sclchar *ic_uuid); + + /** + * @brief Request to hide aux string. + */ + void hide_aux_string(void); + + /** + * @brief Request to hide candidate string. + */ + void hide_candidate_string(void); + + /** + * @brief Request to hide associate string. + */ + void hide_associate_string(void); + + /** + * @brief Update a new WideString for preedit. + * + * @param[in] ic The handle of the client Input Context to receive the WideString. + * -1 means the currently focused Input Context. + * @param[in] ic_uuid The UUID of the IMEngine used by the Input Context. + * NULL means don't match. + * @param[in] str The UTF-8 string to be updated. + * @param[in] attrs The attribute list for preedit string. + */ + /*void update_preedit_string (int ic, const sclchar *ic_uuid, const sclchar *str, const AttributeList &attrs) const;*/ + void update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str); + + /** + * @brief Update a new string for aux. + * + * @param[in] str The string to be updated. + * @param[in] attrs The attribute list for aux string. + */ + //void update_aux_string (const sclchar *str, const AttributeList &attrs) const; + void update_aux_string(const sclchar *str); + + /** + * @brief Request to update candidate. + * + * @param[in] table The lookup table for candidate. + */ + void update_candidate_string(const SclCandidateTable &table) const; + + /** + * @brief Request to update associate. + * + * @param[in] table The lookup table for associate. + */ + void update_associate_string(const SclCandidateTable &table) const; + + /** + * @ brief When the input context of ISE is changed, + * ISE can call this function to notify application + * + * @param[in] type type of event. + * @param[in] value value of event. + */ + void update_input_context(sclu32 type, sclu32 value); + + /** + * @ brief Request to get surrounding text. + * + * @param[in] uuid The helper ISE UUID. + * @param[in] maxlen_before The max length of before. + * @param[in] maxlen_after The max length of after. + */ + void get_surrounding_text(const sclchar *uuid, sclint maxlen_before, sclint maxlen_after) const; + + /** + * @ brief Request to delete surrounding text. + * + * @param[in] offset The offset for cursor position. + * @param[in] len The length for delete text. + */ + void delete_surrounding_text(int offset, int len) const; + + /** + * @ brief Set candidate position in screen. + * + * @param[in] left The x position in screen. + * @param[in] top The y position in screen. + */ + void set_candidate_position(sclint left, sclint top); + + /** + * @ brief Request to hide candidate window. + */ + void candidate_hide(void); + + /** + * @ brief Request to get candidate window size and position. + * + * @param[in] uuid The helper ISE UUID. + */ + //void get_candidate_window_geometry (const String &uuid) const; + + /** + * @ brief Set current keyboard ISE. + * + * @param[in] uuid The keyboard ISE UUID. + */ + void set_keyboard_ise_by_uuid(const sclchar *uuid); + + /** + * @ brief Request to get current keyboard ISE information. + * + * @param[in] uuid The helper ISE UUID. + */ + void get_keyboard_ise(const sclchar *uuid); + + /** + * @ brief Request to get uuid list of all keyboard ISEs. + * + * @param[in] uuid The helper ISE UUID. + */ + //void get_keyboard_ise_list (const String &uuid) const; + + /** + * @brief This API returns the pointer to main keyboard window + */ + sclwindow get_main_window(); + + /** + * @brief This API updates the keyboard window's geometry information + */ + void set_keyboard_size_hints(SclSize portrait, SclSize landscape); + + /** + * @brief Requests to create an option window + */ + sclwindow create_option_window(); + + /** + * @brief Requests to destroy an option window + */ + void destroy_option_window(sclwindow window); + +private: + CSCLCoreImpl *m_impl; +}; + +} + +//SCL_END_DECLS + +#endif //__SCL_CORE_H__ diff --git a/src/sclcorecallback.h b/src/sclcorecallback.h new file mode 100644 index 0000000..cc1650b --- /dev/null +++ b/src/sclcorecallback.h @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2012 - 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + */ + +#include +#include "scltypes.h" +#include "sclcoretypes.h" + +#ifndef __SCL_CORE_CALLBACK_H__ +#define __SCL_CORE_CALLBACK_H__ + +//SCL_BEGIN_DECLS + +namespace scl +{ + +/* The SCL Core app information struct */ +typedef struct { + /* The name of this input method + Example : "Tizen keyboard" */ + std::string name; + /* The uuid to identify this input method + Example : "12aa3425-f88d-45f4-a509-cee8dfe904e3"*/ + std::string uuid; + /* The locale string that this input methods supports + Example : "en_US" */ + std::string language; +} SclCoreAppInfo; + +struct ISCLCoreEventCallback { + virtual void on_get_app_info(SclCoreAppInfo *info) {} + + virtual void on_init() {} + virtual void on_exit() {} + virtual void on_attach_input_context(sclint ic, const sclchar *ic_uuid) {} + virtual void on_detach_input_context(sclint ic, const sclchar *ic_uuid) {} + virtual void on_reload_config(sclint ic, const sclchar *ic_uuid) {} + virtual void on_update_spot_location(sclint ic, const sclchar *ic_uuid, sclint x, sclint y) {} + virtual void on_update_cursor_position(sclint ic, const sclchar *ic_uuid, sclint cursor_pos) {} + virtual void on_update_surrounding_text(sclint ic, const sclchar *text, sclint cursor) {} + virtual void on_focus_out(sclint ic, const sclchar *ic_uuid) {} + virtual void on_focus_in(sclint ic, const sclchar *ic_uuid) {} + virtual void on_ise_show(sclint ic, const int degree, Ise_Context context) {} + virtual void on_ise_hide(sclint ic, const sclchar *ic_uuid) {} + virtual void on_get_geometry(sclu32 *pos_x, sclu32 *pos_y, sclu32 *width, sclu32 *height) {} + virtual void on_set_mode(sclu32 mode) {} + virtual void on_set_language(sclu32 language) {} + virtual void on_set_imdata(sclchar *buf, sclu32 len) {} + virtual void on_get_imdata(sclchar **buf, sclu32 *len) {} + virtual void on_get_language_locale(sclint ic, sclchar **locale) {} + virtual void on_set_return_key_type(sclu32 type) {} + virtual void on_get_return_key_type(sclu32 *type) {} + virtual void on_set_return_key_disable(sclu32 disabled) {} + virtual void on_get_return_key_disable(sclu32 *disabled) {} + virtual void on_set_layout(sclu32 layout) {} + virtual void on_get_layout(sclu32 *layout) {} + virtual void on_set_caps_mode(sclu32 mode) {} + virtual void on_reset_input_context(sclint ic, const sclchar *uuid) {} + virtual void on_update_candidate_geometry(sclint ic, const sclchar *uuid, sclu32 pos_x, sclu32 pos_y, sclu32 width, sclu32 height) {} + virtual void on_update_keyboard_ise(sclint ic, const sclchar *uuid, const sclchar *ise_name, const sclchar *ise_uuid) {} + virtual void on_candidate_more_window_show(sclint ic, const sclchar *uuid) {} + virtual void on_candidate_more_window_hide(sclint ic, const sclchar *uuid) {} + virtual void on_select_aux(sclint ic, const sclchar *uuid, sclint index) {} + virtual void on_select_candidate(sclint ic, const sclchar *uuid, sclint index) {} + virtual void on_candidate_table_page_up(sclint ic, const sclchar *uuid) {} + virtual void on_candidate_table_page_down(sclint ic, const sclchar *uuid) {} + virtual void on_update_lookup_table(SclCandidateTable& table) {} + virtual void on_update_candidate_table_page_size(sclint ic, const sclchar *uuid, sclint page_size) {} + virtual void on_select_associate(sclint ic, const sclchar *uuid, sclint index) {} + virtual void on_associate_table_page_up(sclint ic, const sclchar *uuid) {} + virtual void on_associate_table_page_down(sclint ic, const sclchar *uuid) {} + virtual void on_update_associate_table_page_size(sclint ic, const sclchar *uuid, sclint page_size) {} + virtual void on_turn_on_log(sclu32 on) {} + + virtual void on_set_display_language(const sclchar *language) {} + virtual void on_set_theme_name(const sclchar *name) {} + virtual void on_set_rotation_degree(sclint degree) {} + virtual void on_set_accessibility_state(sclboolean state) {} + + virtual void on_create_option_window(sclwindow window, SCLOptionWindowType type) {} + virtual void on_destroy_option_window(sclwindow window) {} +}; + +} + +//SCL_END_DECLS + +#endif //__SCL_CORE_CALLBACK_H__ diff --git a/src/sclcoreimpl.cpp b/src/sclcoreimpl.cpp new file mode 100644 index 0000000..00c982e --- /dev/null +++ b/src/sclcoreimpl.cpp @@ -0,0 +1,242 @@ +/* + * Copyright (c) 2012 - 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + */ + +#include "sclcoreimpl.h" + +using namespace scl; + +CSCLCoreImpl::CSCLCoreImpl() +{ + m_event_callback = NULL; +} + +CSCLCoreImpl::~CSCLCoreImpl() +{ +} + +CSCLCoreImpl* +CSCLCoreImpl::get_instance() +{ + static CSCLCoreImpl instance; + return &instance; +} + +void CSCLCoreImpl::init(const sclchar *display) +{ + m_connection.init(); + m_core_ui.init(); + + m_connection.open_connection(display); + + if (m_event_callback) { + m_event_callback->on_init(); + } +} + +void CSCLCoreImpl::fini() +{ + if (m_event_callback) { + m_event_callback->on_exit(); + } + + m_connection.close_connection(); + + m_core_ui.fini(); + m_connection.fini(); +} + +void CSCLCoreImpl::set_core_event_callback(ISCLCoreEventCallback *callback) +{ + m_event_callback = callback; +} + +ISCLCoreEventCallback* CSCLCoreImpl::get_core_event_callback() +{ + ISCLCoreEventCallback* ret = m_event_callback; + return ret; +} + +void CSCLCoreImpl::config_reload() +{ + m_connection.config_reload(); +} + +sclboolean CSCLCoreImpl::config_read_int(const sclchar *name, sclint &value) +{ + return m_connection.config_read_int(name, value); +} + +sclboolean CSCLCoreImpl::config_read_string(const sclchar *name, std::string &value) +{ + return m_connection.config_read_string(name, value); +} + +sclboolean CSCLCoreImpl::config_write_int(const sclchar *name, sclint value) +{ + return m_connection.config_write_int(name, value); +} + +sclboolean CSCLCoreImpl::config_write_string(const sclchar *name, const std::string value) +{ + return m_connection.config_write_string(name, value); +} + +sclboolean CSCLCoreImpl::config_erase(const sclchar *name) +{ + return m_connection.config_erase(name); +} + +void CSCLCoreImpl::send_imengine_event(sclint ic, const sclchar *ic_uuid, const sclint command, const sclu32 value) +{ + m_connection.send_imengine_event(ic, ic_uuid, command, value); +} + +void CSCLCoreImpl::reset_keyboard_ise() +{ + m_connection.reset_keyboard_ise(); +} + +void CSCLCoreImpl::send_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask) +{ + m_connection.send_key_event(ic, ic_uuid, keycode, keymask); +} + +void CSCLCoreImpl::forward_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask) +{ + m_connection.forward_key_event(ic, ic_uuid, keycode, keymask); +} + +void CSCLCoreImpl::commit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str) +{ + m_connection.commit_string(ic, ic_uuid, str); +} + +void CSCLCoreImpl::select_candidate(int index) +{ + m_connection.select_candidate(index); +} + +void CSCLCoreImpl::show_preedit_string(sclint ic, const sclchar *ic_uuid) +{ + m_connection.show_preedit_string(ic, ic_uuid); +} + +void CSCLCoreImpl::show_aux_string(void) +{ + m_connection.show_aux_string(); +} + +void CSCLCoreImpl::show_candidate_string(void) +{ + m_connection.show_candidate_string(); +} + +void CSCLCoreImpl::show_associate_string(void) +{ + m_connection.show_associate_string(); +} + +void CSCLCoreImpl::hide_preedit_string(sclint ic, const sclchar *ic_uuid) +{ + m_connection.hide_preedit_string(ic, ic_uuid); +} + +void CSCLCoreImpl::hide_aux_string(void) +{ + m_connection.hide_aux_string(); +} + +void CSCLCoreImpl::hide_candidate_string(void) +{ + m_connection.hide_candidate_string(); +} + +void CSCLCoreImpl::hide_associate_string(void) +{ + m_connection.hide_associate_string(); +} + +void CSCLCoreImpl::update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str) +{ + m_connection.update_preedit_string(ic, ic_uuid, str); +} + +void CSCLCoreImpl::update_aux_string(const sclchar *str) +{ + m_connection.update_aux_string(str); +} + +void CSCLCoreImpl::update_input_context(sclu32 type, sclu32 value) +{ + m_connection.update_input_context(type, value); +} + +void CSCLCoreImpl::set_candidate_position(sclint left, sclint top) +{ + m_connection.set_candidate_position(left, top); +} + +void CSCLCoreImpl::candidate_hide(void) +{ + m_connection.candidate_hide(); +} + +void CSCLCoreImpl::set_keyboard_ise_by_uuid(const sclchar *uuid) +{ + m_connection.set_keyboard_ise_by_uuid(uuid); +} + +void CSCLCoreImpl::get_keyboard_ise(const sclchar *uuid) +{ + m_connection.get_keyboard_ise(uuid); +} + +void CSCLCoreImpl::run(const sclchar *display) +{ + m_core_ui.init(); + m_connection.init(); + + m_core_ui.run(display); + + m_connection.fini(); + m_core_ui.fini(); +} + +sclwindow CSCLCoreImpl::get_main_window() +{ + return m_core_ui.get_main_window(); +} + +int CSCLCoreImpl::get_screen_rotation_degree() +{ + return m_core_ui.get_screen_rotation_degree(); +} + +void CSCLCoreImpl::set_keyboard_size_hints(SclSize portrait, SclSize landscape) +{ + m_core_ui.set_keyboard_size_hints(portrait, landscape); +} + +sclwindow CSCLCoreImpl::create_option_window() +{ + return m_core_ui.create_option_window(OPTION_WINDOW_TYPE_NORMAL); +} + +void CSCLCoreImpl::destroy_option_window(sclwindow window) +{ + m_core_ui.destroy_option_window(window); +} \ No newline at end of file diff --git a/src/sclcoreimpl.h b/src/sclcoreimpl.h new file mode 100644 index 0000000..5547d75 --- /dev/null +++ b/src/sclcoreimpl.h @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2012 - 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + */ + +#ifndef __SCL_CORE_IMPL_H__ +#define __SCL_CORE_IMPL_H__ + +#include "sclcore.h" +#include "sclcoreui.h" +#include "sclcorecallback.h" +#include "sclconnection.h" + +//SCL_BEGIN_DECLS + +namespace scl +{ + +class CSCLCoreImpl +{ +private: + CSCLCoreImpl(); + +public: + ~CSCLCoreImpl(); + static CSCLCoreImpl* get_instance(); + + void init(const sclchar *display); + void fini(); + + void run(const sclchar *display); + + void set_core_event_callback(ISCLCoreEventCallback *callback); + ISCLCoreEventCallback* get_core_event_callback(); + + void config_reload(); + sclboolean config_read_int(const sclchar *name, sclint &value); + sclboolean config_read_string(const sclchar *name, std::string &value); + sclboolean config_write_int(const sclchar *name, sclint value); + sclboolean config_write_string(const sclchar *name, const std::string value); + sclboolean config_erase(const sclchar *name); + + void send_imengine_event(sclint ic, const sclchar *ic_uuid, const sclint command, const sclu32 value); + void reset_keyboard_ise(); + void send_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask); + void forward_key_event(sclint ic, const sclchar *ic_uuid, sclu32 keycode, sclu16 keymask); + void commit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str); + void select_candidate(int index); + void show_preedit_string(sclint ic, const sclchar *ic_uuid); + void show_aux_string(void); + void show_candidate_string(void); + void show_associate_string(void); + void hide_preedit_string(sclint ic, const sclchar *ic_uuid); + void hide_aux_string(void); + void hide_candidate_string(void); + void hide_associate_string(void); + /*void update_preedit_string (int ic, const sclchar *ic_uuid, const sclchar *str, const AttributeList &attrs) const;*/ + void update_preedit_string(sclint ic, const sclchar *ic_uuid, const sclchar *str); + //void update_aux_string (const sclchar *str, const AttributeList &attrs) const; + void update_aux_string(const sclchar *str); + //void update_candidate_string (const LookupTable &table) const; + //void update_associate_string (const LookupTable &table) const; + void update_input_context(sclu32 type, sclu32 value); + //void get_surrounding_text (const String &uuid, + // int maxlen_before, + // int maxlen_after) const; + //void delete_surrounding_text (int offset, + // int len) const; + void set_candidate_position(sclint left, sclint top); + void candidate_hide(void); + //void get_candidate_window_geometry (const String &uuid) const; + void set_keyboard_ise_by_uuid(const sclchar *uuid); + void get_keyboard_ise(const sclchar *uuid); + //void get_keyboard_ise_list (const String &uuid) const; + + sclwindow get_main_window(); + int get_screen_rotation_degree(); + void set_keyboard_size_hints(SclSize portrait, SclSize landscape); + + sclwindow create_option_window(); + void destroy_option_window(sclwindow window); + +private: + SclCoreAppInfo m_app_info; + ISCLCoreEventCallback *m_event_callback; + + CSCLConnection m_connection; + CSCLCoreUI m_core_ui; +}; + +} + +//SCL_END_DECLS + +#endif //__SCL_CORE_IMPL_H__ \ No newline at end of file diff --git a/src/sclcoretypes.h b/src/sclcoretypes.h new file mode 100644 index 0000000..14193c4 --- /dev/null +++ b/src/sclcoretypes.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2012 - 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + */ + +#ifndef __SCL_CORE_TYPES_H__ +#define __SCL_CORE_TYPES_H__ + +#include +#include + +#include "scltypes.h" + +namespace scl +{ + +typedef enum _SCLKeyMask +{ + KEY_MASK_NULL = 0, + KEY_MASK_SHIFT = (1<<0), + KEY_MASK_RELEASE = (1<<15), +} SCLKeyMask; + +typedef enum _SCLOptionWindowType +{ + OPTION_WINDOW_TYPE_NORMAL, + OPTION_WINDOW_TYPE_SETTINGAPPLICATION, + + OPTION_WINDOW_TYPE_MAX, +} SCLOptionWindowType; + +typedef struct _SclCandidateTable{ + sclint page_size; + sclint current_page_start; + sclint cursor_pos; + sclboolean cursor_visible; + sclboolean page_size_fixed; + + std::vector candidate_labels; +} SclCandidateTable; + +} + +//SCL_END_DECLS + +#endif //__SCL_CORE_TYPES_H__ diff --git a/src/sclcoreui-efl.cpp b/src/sclcoreui-efl.cpp new file mode 100644 index 0000000..4a4dbb3 --- /dev/null +++ b/src/sclcoreui-efl.cpp @@ -0,0 +1,488 @@ +/* + * Copyright (c) 2012 - 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + */ + +#include "sclcoreui-efl.h" +#include "sclcoreimpl.h" + +#include +#include + +#include +#include + +#include +#include +#include + + +using namespace scl; + + +CSCLCoreUIEFL::CSCLCoreUIEFL() +{ + m_initialized = FALSE; + + m_backend_identifier = "EFL"; +} + +CSCLCoreUIEFL::~CSCLCoreUIEFL() +{ +} + +sclboolean CSCLCoreUIEFL::init() +{ + sclboolean ret = FALSE; + + m_initialized = TRUE; + m_rotation_degree = -1; + + for (int loop = 0;loop < OPTION_WINDOW_TYPE_MAX;loop++) { + m_option_window_info[OPTION_WINDOW_TYPE_NORMAL].window = SCLWINDOW_INVALID; + m_option_window_info[OPTION_WINDOW_TYPE_NORMAL].handler = NULL; + } + + return ret; +} + +void CSCLCoreUIEFL::fini() +{ + m_initialized = FALSE; +} + +sclwindow CSCLCoreUIEFL::get_main_window() +{ + if (m_initialized) { + return m_main_window; + } +} + +void CSCLCoreUIEFL::set_keyboard_size_hints(SclSize portrait, SclSize landscape) +{ + Evas_Object *main_window = NATIVE_WINDOW_CAST(m_main_window); + ecore_x_e_window_rotation_geometry_set(elm_win_xwindow_get(main_window), 0, 0, 0, portrait.width, portrait.height); + ecore_x_e_window_rotation_geometry_set(elm_win_xwindow_get(main_window), 90, 0, 0, landscape.height, landscape.width); + ecore_x_e_window_rotation_geometry_set(elm_win_xwindow_get(main_window), 180, 0, 0, portrait.width, portrait.height); + ecore_x_e_window_rotation_geometry_set(elm_win_xwindow_get(main_window), 270, 0, 0, landscape.height, landscape.width); +} + +const char * extract_themename_from_theme_file_path(const char *filepath) { + static char themename[_POSIX_PATH_MAX] = {0}; + memset(themename, 0x00, sizeof(themename)); + + if (filepath) { + /* There could be more than 1 theme filepath, separated by : */ + char pathstr[_POSIX_PATH_MAX] = {0}; + strncpy(pathstr, filepath, _POSIX_PATH_MAX - 1); + for(int loop = 0;loop < _POSIX_PATH_MAX;loop++) { + if (pathstr[loop] == ':') { + /* FIXME : Let's consider the 1st theme filepath only for now */ + pathstr[loop] = '\0'; + } + } + + if (pathstr[0]) { + const char *filename = ecore_file_file_get(pathstr); + if (filename) { + char *stripname = ecore_file_strip_ext(filename); + if (stripname) { + strncpy(themename, stripname, _POSIX_PATH_MAX - 1); + free(stripname); + } + } + } + } + + return themename; +} + +void language_changed_cb(keynode_t *key, void* data) +{ + char clang[_POSIX_PATH_MAX] = {0}; + char *vconf_str = vconf_get_str(VCONFKEY_LANGSET); + if (vconf_str) { + snprintf(clang, sizeof(clang), "%s",vconf_str); + free(vconf_str); + } + LOGD("current language is %s\n",clang); + + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_set_display_language(clang); + } + } +} + +void theme_changed_cb(keynode_t *key, void* data) +{ + char clang[256] = {0}; + char *vconf_str = vconf_get_str(VCONFKEY_SETAPPL_WIDGET_THEME_STR); + if (vconf_str) { + snprintf(clang, sizeof(clang), "%s",extract_themename_from_theme_file_path(vconf_str)); + free(vconf_str); + } + LOGD("current theme is %s\n",clang); + + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_set_theme_name(clang); + } + } +} + +void accessibility_changed_cb(keynode_t *key, void* data) +{ + int vconf_value = 0; + if (vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &vconf_value) == 0) { + LOGD("accessbility state : %d\n", vconf_value); + + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_set_accessibility_state(vconf_value); + } + } + } +} + +static Eina_Bool _client_message_cb (void *data, int type, void *event) +{ + Ecore_X_Event_Client_Message *ev = (Ecore_X_Event_Client_Message *)event; + + ISCLCoreEventCallback *callback = NULL; + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + Evas_Object *main_window = NULL; + if (impl) { + callback = impl->get_core_event_callback(); + main_window = NATIVE_WINDOW_CAST(impl->get_main_window()); + } + +#ifndef APPLY_WINDOW_MANAGER_CHANGE +#else + if (ev->message_type == ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE) { + LOGD("ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE , %d %d\n", ev->data.l[0], gFHiddenState); + angle = ev->data.l[0]; + ise_set_screen_direction(angle); + if (!gFHiddenState) { + ise_show(gLastIC); + } + } else if (ev->message_type == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_STATE) { + LOGD("ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_STATE , %d\n", ev->data.l[0]); + elm_win_keyboard_mode_set(main_window, (Elm_Win_Keyboard_Mode)(ev->data.l[0])); + gFHiddenState = !(ev->data.l[0]); + } +#endif + + if (ev->message_type == ECORE_X_ATOM_E_WINDOW_ROTATION_CHANGE_REQUEST) { + if (ev->win == elm_win_xwindow_get(main_window)) { + int degree = ev->data.l[1]; + CSCLCoreUIEFL *coreui = static_cast(data); + if (coreui) { + coreui->set_screen_rotation_degree(degree); + } + LOGD("_ECORE_X_ATOM_E_WINDOW_ROTATION_REQUEST, %d\n", degree); + if (callback) { + callback->on_set_rotation_degree(degree); + } + Ecore_X_Window control_window = 0; + Ecore_X_Atom atom = ecore_x_atom_get ("_ISF_CONTROL_WINDOW"); + Ecore_X_Window root = ecore_x_window_root_first_get (); + if (ecore_x_window_prop_xid_get(root, atom, ECORE_X_ATOM_WINDOW, &control_window, 1) == 1) { + ecore_x_client_message32_send(control_window, ECORE_X_ATOM_E_WINDOW_ROTATION_CHANGE_REQUEST, + ECORE_X_EVENT_MASK_WINDOW_CONFIGURE, + ev->data.l[0], ev->data.l[1], ev->data.l[2], ev->data.l[3], ev->data.l[4]); + } + } + } + + return ECORE_CALLBACK_RENEW; +} + +int CSCLCoreUIEFL::get_screen_rotation_degree() +{ + int angle = 0; + if (m_rotation_degree == -1) { + int ret = 0; + Atom type_return; + int format_return; + unsigned long nitems_return; + unsigned long bytes_after_return; + unsigned char *data_window = NULL; + unsigned char *data_angle = NULL; + + Ecore_X_Window app_window = 0; + + Evas_Object *keypad_win = NATIVE_WINDOW_CAST(m_main_window); + + LOGD("Trying to get app window degree for %p\n", keypad_win); + Ecore_X_Window win = elm_win_xwindow_get(NATIVE_WINDOW_CAST(keypad_win)); + ret = XGetWindowProperty((Display *)ecore_x_display_get (), + ecore_x_window_root_get(win), + ecore_x_atom_get("_ISF_ACTIVE_WINDOW"), + 0, G_MAXLONG, False, XA_WINDOW, &type_return, + &format_return, &nitems_return, &bytes_after_return, + &data_window); + + if (ret == Success) { + if ((type_return == XA_WINDOW) && (format_return == 32) && (data_window)) { + app_window = *(Window *)data_window; + + ret = XGetWindowProperty((Display *)ecore_x_display_get(), app_window, + ecore_x_atom_get("_E_ILLUME_ROTATE_WINDOW_ANGLE"), + 0, G_MAXLONG, False, XA_CARDINAL, &type_return, + &format_return, &nitems_return, &bytes_after_return, + &data_angle); + + LOGD("app_window : %p, ret %d, %d, %p\n", app_window, ret, type_return, data_angle); + if (ret == Success) { + if (data_angle) { + if (type_return == XA_CARDINAL) { + angle = *(unsigned int*)data_angle; + LOGD("current rotation angle is %p %d\n", app_window, angle); + } + XFree(data_angle); + } + } + } + if (data_window) + XFree(data_window); + } + } else { + angle = m_rotation_degree; + } + + return angle; +} + +void signal_handler(int sig) { + elm_exit(); +} + +void CSCLCoreUIEFL::run(const sclchar *display) +{ + char *argv[4]; + int argc = 3; + + std::string name; + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + SclCoreAppInfo appinfo; + callback->on_get_app_info(&appinfo); + name = appinfo.name; + } + + argv [0] = const_cast (name.c_str()); + argv [1] = (char *)"--display"; + argv [2] = const_cast (display); + argv [3] = 0; + + elm_init(argc, argv); + + elm_policy_set (ELM_POLICY_THROTTLE, ELM_POLICY_THROTTLE_NEVER); + + Evas_Object *main_window = elm_win_add(NULL, "Tizen Keyboard", ELM_WIN_UTILITY); + m_main_window = SCL_WINDOW_CAST(main_window); + + //elm_win_alpha_set(main_window, EINA_TRUE); + elm_win_borderless_set(main_window, EINA_TRUE); + elm_win_keyboard_win_set(main_window, EINA_TRUE); + elm_win_autodel_set(main_window, EINA_TRUE); + elm_win_title_set(main_window, "Tizen Keyboard"); + unsigned int set = 1; + ecore_x_window_prop_card32_set(elm_win_xwindow_get(main_window), + ECORE_X_ATOM_E_WINDOW_ROTATION_SUPPORTED, + &set, 1); + +#ifdef FULL_SCREEN_TEST + elm_win_fullscreen_set(main_window, EINA_TRUE); +#endif + + /*Evas_Object *box = elm_box_add(main_window); + evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_win_resize_object_add(main_window, box);*/ + + vconf_notify_key_changed(VCONFKEY_LANGSET, language_changed_cb, NULL); + vconf_notify_key_changed(VCONFKEY_SETAPPL_WIDGET_THEME_STR, theme_changed_cb, NULL); + vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, accessibility_changed_cb, NULL); + + /* Should we call these callback functions here? */ + language_changed_cb(NULL, NULL); + theme_changed_cb(NULL, NULL); + accessibility_changed_cb(NULL, NULL); + + impl->init(display); + + Ecore_Event_Handler *XClientMsgHandler = + ecore_event_handler_add (ECORE_X_EVENT_CLIENT_MESSAGE, _client_message_cb, this); + + signal(SIGQUIT, signal_handler); + signal(SIGTERM, signal_handler); + signal(SIGINT, signal_handler); + signal(SIGHUP, signal_handler); + + elm_run(); + + impl->fini(); + + vconf_ignore_key_changed(VCONFKEY_LANGSET, language_changed_cb); + vconf_ignore_key_changed(VCONFKEY_SETAPPL_WIDGET_THEME_STR, theme_changed_cb); + vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, accessibility_changed_cb); + + ecore_event_handler_del(XClientMsgHandler); + + elm_shutdown(); + } +} + +static Eina_Bool focus_out_cb(void *data, int type, void *event) +{ + OptionWindowInfo *info = static_cast(data); + if (info) { + if (info->window) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_destroy_option_window(info->window); + } + } + + evas_object_hide(NATIVE_WINDOW_CAST(info->window)); + evas_object_del(NATIVE_WINDOW_CAST(info->window)); + info->window = NULL; + } + if (info->handler) { + ecore_event_handler_del(info->handler); + info->handler = NULL; + } + } + + return ECORE_CALLBACK_CANCEL; +} + +static void +set_transient_for_app_window(Evas_Object *window) +{ + /* Set a transient window for window stack */ + /* Gets the current XID of the active window into the root window property */ + Atom type_return; + unsigned long nitems_return; + unsigned long bytes_after_return; + int format_return; + unsigned char *data = NULL; + Ecore_X_Window xAppWindow; + Ecore_X_Window xWindow = elm_win_xwindow_get(window); + gint ret = 0; + + ret = XGetWindowProperty ((Display *)ecore_x_display_get(), ecore_x_window_root_get(xWindow), + ecore_x_atom_get("_ISF_ACTIVE_WINDOW"), + 0, G_MAXLONG, False, XA_WINDOW, &type_return, + &format_return, &nitems_return, &bytes_after_return, + &data); + + if (ret == Success) { + if (data) { + if (type_return == XA_WINDOW) { + xAppWindow = *(Window *)data; + LOGD("TRANSIENT_FOR SET : %x , %x", xAppWindow, xWindow); + ecore_x_icccm_transient_for_set(xWindow, xAppWindow); + } + XFree(data); + } + } +} + +sclwindow CSCLCoreUIEFL::create_option_window(SCLOptionWindowType type) +{ + if (type < 0 || type >= OPTION_WINDOW_TYPE_MAX) { + return SCLWINDOW_INVALID; + } + + Evas_Object *window = elm_win_util_standard_add("Option window", "Option window"); + + const char *szProfile[] = {"mobile", ""}; + elm_win_profiles_set(window, szProfile, 1); + + elm_win_borderless_set(window, EINA_TRUE); + + Evas_Coord win_w = 0, win_h = 0; + ecore_x_window_size_get(ecore_x_window_root_first_get(), &win_w, &win_h); + int degree = get_screen_rotation_degree(); + if(degree == 90 || degree == 270){ + evas_object_resize(window, win_h, win_w); + }else{ + evas_object_resize(window, win_w, win_h); + } + + int rots[] = { 0, 90, 180, 270 }; + elm_win_wm_rotation_available_rotations_set(window, rots, (sizeof(rots) / sizeof(int))); + + elm_win_indicator_mode_set (window, ELM_WIN_INDICATOR_SHOW); + + Ecore_Event_Handler *handler = NULL; + if (type == OPTION_WINDOW_TYPE_NORMAL) { + handler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_FOCUS_OUT, focus_out_cb, &m_option_window_info[type]); + set_transient_for_app_window(window); + } + + m_option_window_info[type].window = window; + m_option_window_info[type].handler = handler; + + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_create_option_window(window, type); + } + } + + return window; +} + +void CSCLCoreUIEFL::destroy_option_window(sclwindow window) +{ + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_destroy_option_window(window); + } + } + + for (int loop = 0;loop < OPTION_WINDOW_TYPE_MAX;loop++) { + if (m_option_window_info[loop].window == window) { + m_option_window_info[OPTION_WINDOW_TYPE_NORMAL].window = SCLWINDOW_INVALID; + if (m_option_window_info[loop].handler) { + ecore_event_handler_del(m_option_window_info[loop].handler); + m_option_window_info[loop].handler = NULL; + } + } + } + evas_object_del(NATIVE_WINDOW_CAST(window)); +} + +void CSCLCoreUIEFL::set_screen_rotation_degree(int degree) +{ + m_rotation_degree = degree; +} \ No newline at end of file diff --git a/src/sclcoreui-efl.h b/src/sclcoreui-efl.h new file mode 100644 index 0000000..5787230 --- /dev/null +++ b/src/sclcoreui-efl.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2012 - 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + */ + +#ifndef __SCL_CORE_UI_EFL_H__ +#define __SCL_CORE_UI_EFL_H__ + +#include "sclcoreui.h" + +#include + +//SCL_BEGIN_DECLS + +namespace scl +{ + +typedef struct { + sclwindow window; + Ecore_Event_Handler *handler; +} OptionWindowInfo; + +class CSCLCoreUIEFL : public CSCLCoreUI +{ +public: + CSCLCoreUIEFL(); + ~CSCLCoreUIEFL(); + + virtual sclboolean init(); + virtual void fini(); + + virtual void run(const sclchar *display); + virtual sclwindow get_main_window(); + virtual void set_keyboard_size_hints(SclSize portrait, SclSize landscape); + virtual int get_screen_rotation_degree(); + + virtual sclwindow create_option_window(SCLOptionWindowType type); + virtual void destroy_option_window(sclwindow window); + + void set_screen_rotation_degree(int degree); +private: + sclboolean m_initialized; + + sclint m_rotation_degree; + sclwindow m_main_window; + + OptionWindowInfo m_option_window_info[OPTION_WINDOW_TYPE_MAX]; +}; + +} + +//SCL_END_DECLS + +#endif //__SCL_CORE_UI_EFL_H__ diff --git a/src/sclcoreui.cpp b/src/sclcoreui.cpp new file mode 100644 index 0000000..e856f1b --- /dev/null +++ b/src/sclcoreui.cpp @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2012 - 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + */ + +#include "sclcoreui.h" + +#include "sclcoreui-efl.h" + +using namespace scl; + +CSCLCoreUI::CSCLCoreUI() +{ + m_backend_identifier = "undefined"; + m_impl = NULL; +} + +CSCLCoreUI::~CSCLCoreUI() +{ +} + +std::string CSCLCoreUI::get_backend_indentifier() +{ + return m_backend_identifier; +} + +sclboolean CSCLCoreUI::init() +{ + sclboolean ret = FALSE; + if (m_impl == NULL) { + /* There could be other backend implementations.. */ + m_impl = new CSCLCoreUIEFL; + } + if (m_impl) { + ret = m_impl->init(); + } + return ret; +} + +void CSCLCoreUI::fini() +{ + if (m_impl) { + m_impl->fini(); + delete m_impl; + m_impl = NULL; + } +} + +void CSCLCoreUI::run(const sclchar *display) +{ + if (m_impl) { + m_impl->run(display); + } +} + +void CSCLCoreUI::set_keyboard_size_hints(SclSize portrait, SclSize landscape) +{ + if (m_impl) { + m_impl->set_keyboard_size_hints(portrait, landscape); + } +} + +sclwindow CSCLCoreUI::get_main_window() +{ + sclwindow ret = SCLWINDOW_INVALID; + if (m_impl) { + ret = m_impl->get_main_window(); + } + return ret; +} + +int CSCLCoreUI::get_screen_rotation_degree() +{ + int ret = 0; + if (m_impl) { + ret = m_impl->get_screen_rotation_degree(); + } + return ret; +} + +sclwindow CSCLCoreUI::create_option_window(SCLOptionWindowType type) +{ + sclwindow ret = SCLWINDOW_INVALID; + if (m_impl) { + ret = m_impl->create_option_window(type); + } + return ret; +} + +void CSCLCoreUI::destroy_option_window(sclwindow window) +{ + if (m_impl) { + m_impl->destroy_option_window(window); + } +} \ No newline at end of file diff --git a/src/sclcoreui.h b/src/sclcoreui.h new file mode 100644 index 0000000..01650fd --- /dev/null +++ b/src/sclcoreui.h @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2012 - 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + * + */ + +#ifndef __SCL_CORE_UI_H__ +#define __SCL_CORE_UI_H__ + +//SCL_BEGIN_DECLS +#include + +#include "scltypes.h" +#include "sclcorecallback.h" + +namespace scl +{ + +/** + * @brief The base class that provides features for a soft-keyboard + * + * This class implements all functions for working as a soft-based keyboard + */ +class CSCLCoreUI +{ +public: + CSCLCoreUI(); + ~CSCLCoreUI(); + + std::string get_backend_indentifier(); + + virtual sclboolean init(); + virtual void fini(); + + virtual void run(const sclchar *display); + + /** + * @brief This API returns the pointer to main keyboard window + */ + virtual sclwindow get_main_window(); + + /** + * @brief This API returns the rotation angle of the current screen + */ + virtual int get_screen_rotation_degree(); + + /** + * @brief This API updates the keyboard window's geometry information + */ + virtual void set_keyboard_size_hints(SclSize portrait, SclSize landscape); + + /** + * @brief Requests to create an option window + */ + virtual sclwindow create_option_window(SCLOptionWindowType type); + + /** + * @brief Requests to destroy an option window + */ + virtual void destroy_option_window(sclwindow window); + +protected: + std::string m_backend_identifier; + +private: + CSCLCoreUI *m_impl; +}; + +} + +//SCL_END_DECLS + +#endif //__SCL_CORE_UI_H__ -- 2.7.4 From 6b9e5e3bfd4a0e2f8b43406412bc977d63e9f57a Mon Sep 17 00:00:00 2001 From: Ji-hoon Lee Date: Wed, 3 Dec 2014 14:45:26 +0900 Subject: [PATCH 3/9] Implemented option window show request handler Change-Id: Ic4df44a06c48b1f050b78c173a13844fc46206ae --- packaging/libscl-core.spec | 3 ++ src/sclconnection-isf.cpp | 13 ++++++++- src/sclcoreimpl.cpp | 10 +++++++ src/sclcoreimpl.h | 3 ++ src/sclcoretypes.h | 2 +- src/sclcoreui-efl.cpp | 70 ++++++++++++++++++++++++++++++++++++++-------- 6 files changed, 87 insertions(+), 14 deletions(-) diff --git a/packaging/libscl-core.spec b/packaging/libscl-core.spec index fd3ef65..a4cb58f 100644 --- a/packaging/libscl-core.spec +++ b/packaging/libscl-core.spec @@ -34,6 +34,9 @@ A devel pacakge of libscl-core library that helps developing S/W Keyboard %build +export CFLAGS+=" -DTIZEN_DEBUG_ENABLE" +export CXXFLAGS+=" -DTIZEN_DEBUG_ENABLE" +export FFLAGS+=" -DTIZEN_DEBUG_ENABLE" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} make %{?jobs:-j%jobs} diff --git a/src/sclconnection-isf.cpp b/src/sclconnection-isf.cpp index d45f912..debff6f 100644 --- a/src/sclconnection-isf.cpp +++ b/src/sclconnection-isf.cpp @@ -485,6 +485,17 @@ static void slot_turn_on_log (const scim::HelperAgent *agent, scim::uint32 &on) } } +static void slot_show_ise_option_window (const scim::HelperAgent *agent, int ic, const scim::String &uuid) { + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + CSCLCoreUI *core_ui = impl->get_core_ui(); + if (core_ui) { + LOGD("slot_show_ise_option_window() called!!!\n"); + core_ui->create_option_window(OPTION_WINDOW_TYPE_SETTING_APPLICATION); + } + } +} + /* Internal input handler function */ Eina_Bool input_handler (void *data, Ecore_Fd_Handler *fd_handler) { @@ -584,7 +595,7 @@ sclboolean CSCLConnectionISF::init() m_helper_agent.signal_connect_associate_table_page_down (scim::slot (slot_associate_table_page_down)); m_helper_agent.signal_connect_update_associate_table_page_size (scim::slot (slot_update_associate_table_page_size)); m_helper_agent.signal_connect_turn_on_log (scim::slot (slot_turn_on_log)); - + m_helper_agent.signal_connect_show_option_window (scim::slot (slot_show_ise_option_window)); return ret; } diff --git a/src/sclcoreimpl.cpp b/src/sclcoreimpl.cpp index 00c982e..43b1ca4 100644 --- a/src/sclcoreimpl.cpp +++ b/src/sclcoreimpl.cpp @@ -70,6 +70,16 @@ ISCLCoreEventCallback* CSCLCoreImpl::get_core_event_callback() return ret; } +CSCLCoreUI* CSCLCoreImpl::get_core_ui() +{ + return &m_core_ui; +} + +CSCLConnection* CSCLCoreImpl::get_connection() +{ + return &m_connection; +} + void CSCLCoreImpl::config_reload() { m_connection.config_reload(); diff --git a/src/sclcoreimpl.h b/src/sclcoreimpl.h index 5547d75..e11a04c 100644 --- a/src/sclcoreimpl.h +++ b/src/sclcoreimpl.h @@ -45,6 +45,9 @@ public: void set_core_event_callback(ISCLCoreEventCallback *callback); ISCLCoreEventCallback* get_core_event_callback(); + CSCLCoreUI* get_core_ui(); + CSCLConnection* get_connection(); + void config_reload(); sclboolean config_read_int(const sclchar *name, sclint &value); sclboolean config_read_string(const sclchar *name, std::string &value); diff --git a/src/sclcoretypes.h b/src/sclcoretypes.h index 14193c4..5243fdc 100644 --- a/src/sclcoretypes.h +++ b/src/sclcoretypes.h @@ -36,7 +36,7 @@ typedef enum _SCLKeyMask typedef enum _SCLOptionWindowType { OPTION_WINDOW_TYPE_NORMAL, - OPTION_WINDOW_TYPE_SETTINGAPPLICATION, + OPTION_WINDOW_TYPE_SETTING_APPLICATION, OPTION_WINDOW_TYPE_MAX, } SCLOptionWindowType; diff --git a/src/sclcoreui-efl.cpp b/src/sclcoreui-efl.cpp index 4a4dbb3..00d69cb 100644 --- a/src/sclcoreui-efl.cpp +++ b/src/sclcoreui-efl.cpp @@ -51,8 +51,8 @@ sclboolean CSCLCoreUIEFL::init() m_rotation_degree = -1; for (int loop = 0;loop < OPTION_WINDOW_TYPE_MAX;loop++) { - m_option_window_info[OPTION_WINDOW_TYPE_NORMAL].window = SCLWINDOW_INVALID; - m_option_window_info[OPTION_WINDOW_TYPE_NORMAL].handler = NULL; + m_option_window_info[loop].window = SCLWINDOW_INVALID; + m_option_window_info[loop].handler = NULL; } return ret; @@ -413,12 +413,55 @@ set_transient_for_app_window(Evas_Object *window) } } +static void +set_transient_for_isf_setting_window(Evas_Object *window) +{ + /* Set a transient window for window stack */ + /* Gets the current XID of the active window into the root window property */ + Atom type_return; + unsigned long nitems_return; + unsigned long bytes_after_return; + int format_return; + unsigned char *data = NULL; + Ecore_X_Window xControlWindow, xSettingWindow; + Ecore_X_Window xWindow = elm_win_xwindow_get(window); + gint ret = 0; + + ret = XGetWindowProperty ((Display *)ecore_x_display_get(), ecore_x_window_root_get(xWindow), + ecore_x_atom_get("_ISF_CONTROL_WINDOW"), + 0, G_MAXLONG, False, XA_WINDOW, &type_return, + &format_return, &nitems_return, &bytes_after_return, + &data); + + if (ret == Success) { + if (data) { + if (type_return == XA_WINDOW) { + xControlWindow = *(Window *)data; + + ecore_x_window_prop_xid_get (xControlWindow, ecore_x_atom_get ("ISF Setting window"), + ECORE_X_ATOM_WINDOW, &xSettingWindow, 1); + + LOGD("TRANSIENT_FOR SET : %x , %x", xSettingWindow, xWindow); + ecore_x_icccm_transient_for_set(xWindow, xSettingWindow); + } + XFree(data); + } + } +} + sclwindow CSCLCoreUIEFL::create_option_window(SCLOptionWindowType type) { if (type < 0 || type >= OPTION_WINDOW_TYPE_MAX) { return SCLWINDOW_INVALID; } + /* Just in case the previous option window for setting application exists */ + if (type == OPTION_WINDOW_TYPE_SETTING_APPLICATION) { + if (m_option_window_info[type].window != SCLWINDOW_INVALID) { + destroy_option_window(m_option_window_info[type].window); + } + } + Evas_Object *window = elm_win_util_standard_add("Option window", "Option window"); const char *szProfile[] = {"mobile", ""}; @@ -440,23 +483,26 @@ sclwindow CSCLCoreUIEFL::create_option_window(SCLOptionWindowType type) elm_win_indicator_mode_set (window, ELM_WIN_INDICATOR_SHOW); + CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); + if (impl) { + ISCLCoreEventCallback *callback = impl->get_core_event_callback(); + if (callback) { + callback->on_create_option_window(window, type); + } + } + Ecore_Event_Handler *handler = NULL; if (type == OPTION_WINDOW_TYPE_NORMAL) { handler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_FOCUS_OUT, focus_out_cb, &m_option_window_info[type]); set_transient_for_app_window(window); + } else if (type == OPTION_WINDOW_TYPE_SETTING_APPLICATION) { + set_transient_for_isf_setting_window(window); + evas_object_show(window); } m_option_window_info[type].window = window; m_option_window_info[type].handler = handler; - CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); - if (impl) { - ISCLCoreEventCallback *callback = impl->get_core_event_callback(); - if (callback) { - callback->on_create_option_window(window, type); - } - } - return window; } @@ -472,14 +518,14 @@ void CSCLCoreUIEFL::destroy_option_window(sclwindow window) for (int loop = 0;loop < OPTION_WINDOW_TYPE_MAX;loop++) { if (m_option_window_info[loop].window == window) { - m_option_window_info[OPTION_WINDOW_TYPE_NORMAL].window = SCLWINDOW_INVALID; + evas_object_del(NATIVE_WINDOW_CAST(window)); + m_option_window_info[loop].window = SCLWINDOW_INVALID; if (m_option_window_info[loop].handler) { ecore_event_handler_del(m_option_window_info[loop].handler); m_option_window_info[loop].handler = NULL; } } } - evas_object_del(NATIVE_WINDOW_CAST(window)); } void CSCLCoreUIEFL::set_screen_rotation_degree(int degree) -- 2.7.4 From 751d2822ce200d06d8d7deb39c05cd7971309a84 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 9 Jan 2015 21:32:25 +0900 Subject: [PATCH 4/9] Set additional window property for keyboard main window Change-Id: Iafe31bc8ae2803a64cffa85c203f098c61f640fb --- src/sclcoreui-efl.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/sclcoreui-efl.cpp b/src/sclcoreui-efl.cpp index 00d69cb..e54aa92 100644 --- a/src/sclcoreui-efl.cpp +++ b/src/sclcoreui-efl.cpp @@ -151,7 +151,7 @@ void accessibility_changed_cb(keynode_t *key, void* data) { int vconf_value = 0; if (vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, &vconf_value) == 0) { - LOGD("accessbility state : %d\n", vconf_value); + LOGD("accessibility state : %d\n", vconf_value); CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); if (impl) { @@ -303,24 +303,18 @@ void CSCLCoreUIEFL::run(const sclchar *display) Evas_Object *main_window = elm_win_add(NULL, "Tizen Keyboard", ELM_WIN_UTILITY); m_main_window = SCL_WINDOW_CAST(main_window); - //elm_win_alpha_set(main_window, EINA_TRUE); elm_win_borderless_set(main_window, EINA_TRUE); elm_win_keyboard_win_set(main_window, EINA_TRUE); elm_win_autodel_set(main_window, EINA_TRUE); elm_win_title_set(main_window, "Tizen Keyboard"); + elm_win_prop_focus_skip_set(main_window, EINA_TRUE); + unsigned int set = 1; ecore_x_window_prop_card32_set(elm_win_xwindow_get(main_window), ECORE_X_ATOM_E_WINDOW_ROTATION_SUPPORTED, &set, 1); -#ifdef FULL_SCREEN_TEST - elm_win_fullscreen_set(main_window, EINA_TRUE); -#endif - - /*Evas_Object *box = elm_box_add(main_window); - evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_win_resize_object_add(main_window, box);*/ + ecore_x_icccm_name_class_set(elm_win_xwindow_get(main_window), "Virtual Keyboard", "ISF"); vconf_notify_key_changed(VCONFKEY_LANGSET, language_changed_cb, NULL); vconf_notify_key_changed(VCONFKEY_SETAPPL_WIDGET_THEME_STR, theme_changed_cb, NULL); @@ -349,7 +343,10 @@ void CSCLCoreUIEFL::run(const sclchar *display) vconf_ignore_key_changed(VCONFKEY_SETAPPL_WIDGET_THEME_STR, theme_changed_cb); vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, accessibility_changed_cb); - ecore_event_handler_del(XClientMsgHandler); + if (XClientMsgHandler) { + ecore_event_handler_del(XClientMsgHandler); + XClientMsgHandler = NULL; + } elm_shutdown(); } @@ -531,4 +528,4 @@ void CSCLCoreUIEFL::destroy_option_window(sclwindow window) void CSCLCoreUIEFL::set_screen_rotation_degree(int degree) { m_rotation_degree = degree; -} \ No newline at end of file +} -- 2.7.4 From ac2ec81f00e0df86765a38c5acc28087be237c5b Mon Sep 17 00:00:00 2001 From: Sungmin Kwak Date: Mon, 12 Jan 2015 15:39:11 +0900 Subject: [PATCH 5/9] Fix build error due to EFL 1.12 upgrade Change-Id: Icb70570718421a9db62d3d23374379f4b696cc27 --- src/sclcoreui-efl.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) mode change 100644 => 100755 src/sclcoreui-efl.cpp diff --git a/src/sclcoreui-efl.cpp b/src/sclcoreui-efl.cpp old mode 100644 new mode 100755 index e54aa92..4a93596 --- a/src/sclcoreui-efl.cpp +++ b/src/sclcoreui-efl.cpp @@ -461,8 +461,7 @@ sclwindow CSCLCoreUIEFL::create_option_window(SCLOptionWindowType type) Evas_Object *window = elm_win_util_standard_add("Option window", "Option window"); - const char *szProfile[] = {"mobile", ""}; - elm_win_profiles_set(window, szProfile, 1); + elm_win_profile_set (window, "mobile"); elm_win_borderless_set(window, EINA_TRUE); -- 2.7.4 From 06ab14b27fde1c1da3b299bcfd8daba603ca2d6f Mon Sep 17 00:00:00 2001 From: Sungmin Kwak Date: Thu, 15 Jan 2015 10:35:03 +0900 Subject: [PATCH 6/9] Remove unused Vconf key codes. Change-Id: I2fa059cc4f1ac547804565c55d8e8d35b23a7b77 --- src/sclcoreui-efl.cpp | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/src/sclcoreui-efl.cpp b/src/sclcoreui-efl.cpp index 4a93596..f70d267 100755 --- a/src/sclcoreui-efl.cpp +++ b/src/sclcoreui-efl.cpp @@ -128,25 +128,6 @@ void language_changed_cb(keynode_t *key, void* data) } } -void theme_changed_cb(keynode_t *key, void* data) -{ - char clang[256] = {0}; - char *vconf_str = vconf_get_str(VCONFKEY_SETAPPL_WIDGET_THEME_STR); - if (vconf_str) { - snprintf(clang, sizeof(clang), "%s",extract_themename_from_theme_file_path(vconf_str)); - free(vconf_str); - } - LOGD("current theme is %s\n",clang); - - CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); - if (impl) { - ISCLCoreEventCallback *callback = impl->get_core_event_callback(); - if (callback) { - callback->on_set_theme_name(clang); - } - } -} - void accessibility_changed_cb(keynode_t *key, void* data) { int vconf_value = 0; @@ -317,12 +298,10 @@ void CSCLCoreUIEFL::run(const sclchar *display) ecore_x_icccm_name_class_set(elm_win_xwindow_get(main_window), "Virtual Keyboard", "ISF"); vconf_notify_key_changed(VCONFKEY_LANGSET, language_changed_cb, NULL); - vconf_notify_key_changed(VCONFKEY_SETAPPL_WIDGET_THEME_STR, theme_changed_cb, NULL); vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, accessibility_changed_cb, NULL); /* Should we call these callback functions here? */ language_changed_cb(NULL, NULL); - theme_changed_cb(NULL, NULL); accessibility_changed_cb(NULL, NULL); impl->init(display); @@ -340,7 +319,6 @@ void CSCLCoreUIEFL::run(const sclchar *display) impl->fini(); vconf_ignore_key_changed(VCONFKEY_LANGSET, language_changed_cb); - vconf_ignore_key_changed(VCONFKEY_SETAPPL_WIDGET_THEME_STR, theme_changed_cb); vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, accessibility_changed_cb); if (XClientMsgHandler) { -- 2.7.4 From c34e9ee740e9a2b818207f29aadb73c29af3c01d Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 16 Jan 2015 09:50:29 +0900 Subject: [PATCH 7/9] Fix build warning Change-Id: I555866431e2e4c41462cfcc43a6a6958f3148a89 --- src/sclconnection-isf.cpp | 2 +- src/sclcoreui-efl.cpp | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/sclconnection-isf.cpp b/src/sclconnection-isf.cpp index debff6f..787ca12 100644 --- a/src/sclconnection-isf.cpp +++ b/src/sclconnection-isf.cpp @@ -427,7 +427,7 @@ static void slot_update_lookup_table (const scim::HelperAgent *, scim::LookupTab callback->on_update_lookup_table(lookup_table); std::vector labels; - for (int loop = 0;loop < lookup_table.candidate_labels.size();loop) { + for (int loop = 0;loop < lookup_table.candidate_labels.size();loop++) { labels.push_back(scim::utf8_mbstowcs(lookup_table.candidate_labels.at(loop).c_str())); } table.set_candidate_labels(labels); diff --git a/src/sclcoreui-efl.cpp b/src/sclcoreui-efl.cpp index f70d267..d69f6ff 100755 --- a/src/sclcoreui-efl.cpp +++ b/src/sclcoreui-efl.cpp @@ -68,6 +68,8 @@ sclwindow CSCLCoreUIEFL::get_main_window() if (m_initialized) { return m_main_window; } + else + return NULL; } void CSCLCoreUIEFL::set_keyboard_size_hints(SclSize portrait, SclSize landscape) @@ -144,7 +146,7 @@ void accessibility_changed_cb(keynode_t *key, void* data) } } -static Eina_Bool _client_message_cb (void *data, int type, void *event) +static Eina_Bool _client_message_cb(void *data, int type, void *event) { Ecore_X_Event_Client_Message *ev = (Ecore_X_Event_Client_Message *)event; @@ -184,8 +186,8 @@ static Eina_Bool _client_message_cb (void *data, int type, void *event) callback->on_set_rotation_degree(degree); } Ecore_X_Window control_window = 0; - Ecore_X_Atom atom = ecore_x_atom_get ("_ISF_CONTROL_WINDOW"); - Ecore_X_Window root = ecore_x_window_root_first_get (); + Ecore_X_Atom atom = ecore_x_atom_get("_ISF_CONTROL_WINDOW"); + Ecore_X_Window root = ecore_x_window_root_first_get(); if (ecore_x_window_prop_xid_get(root, atom, ECORE_X_ATOM_WINDOW, &control_window, 1) == 1) { ecore_x_client_message32_send(control_window, ECORE_X_ATOM_E_WINDOW_ROTATION_CHANGE_REQUEST, ECORE_X_EVENT_MASK_WINDOW_CONFIGURE, @@ -215,7 +217,7 @@ int CSCLCoreUIEFL::get_screen_rotation_degree() LOGD("Trying to get app window degree for %p\n", keypad_win); Ecore_X_Window win = elm_win_xwindow_get(NATIVE_WINDOW_CAST(keypad_win)); - ret = XGetWindowProperty((Display *)ecore_x_display_get (), + ret = XGetWindowProperty((Display *)ecore_x_display_get(), ecore_x_window_root_get(win), ecore_x_atom_get("_ISF_ACTIVE_WINDOW"), 0, G_MAXLONG, False, XA_WINDOW, &type_return, @@ -279,7 +281,7 @@ void CSCLCoreUIEFL::run(const sclchar *display) elm_init(argc, argv); - elm_policy_set (ELM_POLICY_THROTTLE, ELM_POLICY_THROTTLE_NEVER); + elm_policy_set(ELM_POLICY_THROTTLE, ELM_POLICY_THROTTLE_NEVER); Evas_Object *main_window = elm_win_add(NULL, "Tizen Keyboard", ELM_WIN_UTILITY); m_main_window = SCL_WINDOW_CAST(main_window); @@ -307,7 +309,7 @@ void CSCLCoreUIEFL::run(const sclchar *display) impl->init(display); Ecore_Event_Handler *XClientMsgHandler = - ecore_event_handler_add (ECORE_X_EVENT_CLIENT_MESSAGE, _client_message_cb, this); + ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, _client_message_cb, this); signal(SIGQUIT, signal_handler); signal(SIGTERM, signal_handler); @@ -370,7 +372,7 @@ set_transient_for_app_window(Evas_Object *window) Ecore_X_Window xWindow = elm_win_xwindow_get(window); gint ret = 0; - ret = XGetWindowProperty ((Display *)ecore_x_display_get(), ecore_x_window_root_get(xWindow), + ret = XGetWindowProperty((Display *)ecore_x_display_get(), ecore_x_window_root_get(xWindow), ecore_x_atom_get("_ISF_ACTIVE_WINDOW"), 0, G_MAXLONG, False, XA_WINDOW, &type_return, &format_return, &nitems_return, &bytes_after_return, @@ -402,7 +404,7 @@ set_transient_for_isf_setting_window(Evas_Object *window) Ecore_X_Window xWindow = elm_win_xwindow_get(window); gint ret = 0; - ret = XGetWindowProperty ((Display *)ecore_x_display_get(), ecore_x_window_root_get(xWindow), + ret = XGetWindowProperty((Display *)ecore_x_display_get(), ecore_x_window_root_get(xWindow), ecore_x_atom_get("_ISF_CONTROL_WINDOW"), 0, G_MAXLONG, False, XA_WINDOW, &type_return, &format_return, &nitems_return, &bytes_after_return, @@ -413,7 +415,7 @@ set_transient_for_isf_setting_window(Evas_Object *window) if (type_return == XA_WINDOW) { xControlWindow = *(Window *)data; - ecore_x_window_prop_xid_get (xControlWindow, ecore_x_atom_get ("ISF Setting window"), + ecore_x_window_prop_xid_get(xControlWindow, ecore_x_atom_get("ISF Setting window"), ECORE_X_ATOM_WINDOW, &xSettingWindow, 1); LOGD("TRANSIENT_FOR SET : %x , %x", xSettingWindow, xWindow); @@ -455,7 +457,7 @@ sclwindow CSCLCoreUIEFL::create_option_window(SCLOptionWindowType type) int rots[] = { 0, 90, 180, 270 }; elm_win_wm_rotation_available_rotations_set(window, rots, (sizeof(rots) / sizeof(int))); - elm_win_indicator_mode_set (window, ELM_WIN_INDICATOR_SHOW); + elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW); CSCLCoreImpl *impl = CSCLCoreImpl::get_instance(); if (impl) { -- 2.7.4 From b5eb76ec059495ad2b0df6a584fb4ce0b2fe92c9 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 16 Jan 2015 09:54:39 +0900 Subject: [PATCH 8/9] Revert "Fix build error due to EFL 1.12 upgrade" It's not necessary change. Change-Id: Ieefcbc67c5743d5b046a285279754ec9bccf9a7d --- src/sclcoreui-efl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sclcoreui-efl.cpp b/src/sclcoreui-efl.cpp index d69f6ff..4a678b3 100755 --- a/src/sclcoreui-efl.cpp +++ b/src/sclcoreui-efl.cpp @@ -441,7 +441,8 @@ sclwindow CSCLCoreUIEFL::create_option_window(SCLOptionWindowType type) Evas_Object *window = elm_win_util_standard_add("Option window", "Option window"); - elm_win_profile_set (window, "mobile"); + const char *szProfile[] = {"mobile", ""}; + elm_win_profiles_set(window, szProfile, 1); elm_win_borderless_set(window, EINA_TRUE); -- 2.7.4 From ca19d27e2a730595320dffea95730f997da385a2 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 16 Jan 2015 21:17:46 +0900 Subject: [PATCH 9/9] Remove theme change callback Change-Id: If18b99372f3a5347c35179081279eaf18220e666 --- src/sclcorecallback.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/sclcorecallback.h b/src/sclcorecallback.h index cc1650b..16a76d4 100644 --- a/src/sclcorecallback.h +++ b/src/sclcorecallback.h @@ -86,7 +86,6 @@ struct ISCLCoreEventCallback { virtual void on_turn_on_log(sclu32 on) {} virtual void on_set_display_language(const sclchar *language) {} - virtual void on_set_theme_name(const sclchar *name) {} virtual void on_set_rotation_degree(sclint degree) {} virtual void on_set_accessibility_state(sclboolean state) {} -- 2.7.4