pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/inputmethod/mozc-server226



Module Name:    pkgsrc
Committed By:   ryoon
Date:           Sat Feb 10 01:20:47 UTC 2024

Added Files:
        pkgsrc/inputmethod/mozc-server226: DESCR Makefile Makefile.common PLIST
            distinfo
        pkgsrc/inputmethod/mozc-server226/patches: patch-base_base.gyp
            patch-base_clock.cc patch-base_cpu__stats.cc patch-base_logging.cc
            patch-base_mutex.cc patch-base_password__manager.cc
            patch-base_port.h patch-base_process.cc patch-base_run__level.cc
            patch-base_system__util.cc patch-base_thread.cc
            patch-build__mozc.py patch-build__tools_mozc__version.py
            patch-build__tools_util.py patch-client_client.cc patch-config.bzl
            patch-config_stats__config__util__test.cc
            patch-gui_config__dialog_config__dialog.cc
            patch-gui_config__dialog_keybinding__editor.cc
            patch-gui_dictionary__tool_dictionary__tool.cc
            patch-gui_qt__libraries.gypi patch-gui_qt__moc.gypi
            patch-gui_qt__rcc.gypi patch-gui_qt__uic.gypi
            patch-gui_word__register__dialog_word__register__dialog.cc
            patch-gyp_common.gypi patch-gyp_directories.gypi
            patch-ipc_ipc__path__manager.cc
            patch-ipc_ipc__path__manager__test.cc patch-ipc_named__event.cc
            patch-ipc_unix__ipc.cc patch-protobuf_protobuf.gyp
            patch-renderer_renderer.gyp patch-session_session.cc
            patch-session_session__test.cc
            patch-third__party_abseil-cpp_absl_base_config.h
            patch-third__party_protobuf_post__process__dist.sh patch-uim-mozc
            patch-unix_ibus_ibus.gyp patch-unix_ibus_path__util.cc

Log Message:
inputmethod/mozc-server226: import mozc-server-2.26.4282.100nb25

Mozc is a Japanese Input Method Editor (IME) designed for multi-platform
such as Chromium OS, Windows, Mac and Linux. This open-source
project originates from Google Japanese Input.

This package is dictionary server for mozc client, such as ibus-mozc.

This package does not require deve/bazel, so you can build under
32-bit systems.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 pkgsrc/inputmethod/mozc-server226/DESCR \
    pkgsrc/inputmethod/mozc-server226/Makefile \
    pkgsrc/inputmethod/mozc-server226/Makefile.common \
    pkgsrc/inputmethod/mozc-server226/PLIST \
    pkgsrc/inputmethod/mozc-server226/distinfo
cvs rdiff -u -r0 -r1.1 \
    pkgsrc/inputmethod/mozc-server226/patches/patch-base_base.gyp \
    pkgsrc/inputmethod/mozc-server226/patches/patch-base_clock.cc \
    pkgsrc/inputmethod/mozc-server226/patches/patch-base_cpu__stats.cc \
    pkgsrc/inputmethod/mozc-server226/patches/patch-base_logging.cc \
    pkgsrc/inputmethod/mozc-server226/patches/patch-base_mutex.cc \
    pkgsrc/inputmethod/mozc-server226/patches/patch-base_password__manager.cc \
    pkgsrc/inputmethod/mozc-server226/patches/patch-base_port.h \
    pkgsrc/inputmethod/mozc-server226/patches/patch-base_process.cc \
    pkgsrc/inputmethod/mozc-server226/patches/patch-base_run__level.cc \
    pkgsrc/inputmethod/mozc-server226/patches/patch-base_system__util.cc \
    pkgsrc/inputmethod/mozc-server226/patches/patch-base_thread.cc \
    pkgsrc/inputmethod/mozc-server226/patches/patch-build__mozc.py \
    pkgsrc/inputmethod/mozc-server226/patches/patch-build__tools_mozc__version.py \
    pkgsrc/inputmethod/mozc-server226/patches/patch-build__tools_util.py \
    pkgsrc/inputmethod/mozc-server226/patches/patch-client_client.cc \
    pkgsrc/inputmethod/mozc-server226/patches/patch-config.bzl \
    pkgsrc/inputmethod/mozc-server226/patches/patch-config_stats__config__util__test.cc \
    pkgsrc/inputmethod/mozc-server226/patches/patch-gui_config__dialog_config__dialog.cc \
    pkgsrc/inputmethod/mozc-server226/patches/patch-gui_config__dialog_keybinding__editor.cc \
    pkgsrc/inputmethod/mozc-server226/patches/patch-gui_dictionary__tool_dictionary__tool.cc \
    pkgsrc/inputmethod/mozc-server226/patches/patch-gui_qt__libraries.gypi \
    pkgsrc/inputmethod/mozc-server226/patches/patch-gui_qt__moc.gypi \
    pkgsrc/inputmethod/mozc-server226/patches/patch-gui_qt__rcc.gypi \
    pkgsrc/inputmethod/mozc-server226/patches/patch-gui_qt__uic.gypi \
    pkgsrc/inputmethod/mozc-server226/patches/patch-gui_word__register__dialog_word__register__dialog.cc \
    pkgsrc/inputmethod/mozc-server226/patches/patch-gyp_common.gypi \
    pkgsrc/inputmethod/mozc-server226/patches/patch-gyp_directories.gypi \
    pkgsrc/inputmethod/mozc-server226/patches/patch-ipc_ipc__path__manager.cc \
    pkgsrc/inputmethod/mozc-server226/patches/patch-ipc_ipc__path__manager__test.cc \
    pkgsrc/inputmethod/mozc-server226/patches/patch-ipc_named__event.cc \
    pkgsrc/inputmethod/mozc-server226/patches/patch-ipc_unix__ipc.cc \
    pkgsrc/inputmethod/mozc-server226/patches/patch-protobuf_protobuf.gyp \
    pkgsrc/inputmethod/mozc-server226/patches/patch-renderer_renderer.gyp \
    pkgsrc/inputmethod/mozc-server226/patches/patch-session_session.cc \
    pkgsrc/inputmethod/mozc-server226/patches/patch-session_session__test.cc \
    pkgsrc/inputmethod/mozc-server226/patches/patch-third__party_abseil-cpp_absl_base_config.h \
    pkgsrc/inputmethod/mozc-server226/patches/patch-third__party_protobuf_post__process__dist.sh \
    pkgsrc/inputmethod/mozc-server226/patches/patch-uim-mozc \
    pkgsrc/inputmethod/mozc-server226/patches/patch-unix_ibus_ibus.gyp \
    pkgsrc/inputmethod/mozc-server226/patches/patch-unix_ibus_path__util.cc

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: pkgsrc/inputmethod/mozc-server226/DESCR
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/DESCR:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/DESCR     Sat Feb 10 01:20:46 2024
@@ -0,0 +1,8 @@
+Mozc is a Japanese Input Method Editor (IME) designed for multi-platform
+such as Chromium OS, Windows, Mac and Linux. This open-source
+project originates from Google Japanese Input.
+
+This package is dictionary server for mozc client, such as ibus-mozc.
+
+This package does not require deve/bazel, so you can build under
+32-bit systems.
Index: pkgsrc/inputmethod/mozc-server226/Makefile
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/Makefile:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/Makefile  Sat Feb 10 01:20:46 2024
@@ -0,0 +1,23 @@
+# $NetBSD: Makefile,v 1.1 2024/02/10 01:20:46 ryoon Exp $
+
+PKGNAME=       ${DISTNAME:S/mozc-/mozc-server-/}
+PKGREVISION=   25
+
+INSTALLATION_DIRS+=    libexec
+
+post-patch:
+       ${RM} ${WRKSRC}/unix/uim/uim.gyp
+
+do-build:
+       cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} \
+               ${PYTHONBIN} build_mozc.py build \
+               -c ${MOZC_BUILD_MODE} \
+                       dictionary/dictionary_base.gyp:text_dictionary_loader \
+                       server/server.gyp:mozc_server
+
+do-install:
+       ${INSTALL_PROGRAM} ${WRKSRC}/out_${OSDEST}/${MOZC_BUILD_MODE}/mozc_server \
+               ${DESTDIR}${PREFIX}/libexec/mozc_server
+
+.include "../../inputmethod/mozc-server226/Makefile.common"
+.include "../../mk/bsd.pkg.mk"
Index: pkgsrc/inputmethod/mozc-server226/Makefile.common
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/Makefile.common:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/Makefile.common   Sat Feb 10 01:20:46 2024
@@ -0,0 +1,97 @@
+# $NetBSD: Makefile.common,v 1.1 2024/02/10 01:20:46 ryoon Exp $
+
+# used by inputmethod/ibus-mozc226/Makefile
+# used by inputmethod/mozc-elisp226/Makefile
+# used by inputmethod/mozc-server226/Makefile
+# used by inputmethod/mozc-tool226/Makefile
+# used by inputmethod/mozc-renderer226/Makefile
+# used by inputmethod/uim-mozc226/Makefile
+
+MOZC_VER=      2.26.4282.100
+
+DISTNAME=      mozc-${MOZC_VER}
+CATEGORIES=    inputmethod
+MASTER_SITES=  ${MASTER_SITE_LOCAL}
+EXTRACT_SUFX=  .tar.xz
+
+MAINTAINER=    ryoon%NetBSD.org@localhost
+HOMEPAGE=      https://github.com/google/mozc/
+COMMENT=       Japanese inputmethod Mozc engine
+LICENSE=       modified-bsd
+
+UIM_MOZC=      uim-mozc-321.3ea28b1
+DISTFILES+=    ${DISTNAME}${EXTRACT_SUFX} \
+               ${UIM_MOZC}.tar.xz
+SITES.${UIM_MOZC}.tar.xz=      ${MASTER_SITE_SOURCEFORGE:=pnsft-aur/}
+
+EXTRACT_USING= bsdtar
+WRKSRC=                ${WRKDIR}/${DISTNAME}/src
+
+DISTINFO_FILE= ${.CURDIR}/../../inputmethod/mozc-server226/distinfo
+PATCHDIR=      ${.CURDIR}/../../inputmethod/mozc-server226/patches
+
+PYTHON_VERSIONS_INCOMPATIBLE+= 27
+
+TOOL_DEPENDS+= ${PYPKGPREFIX}-gyp>=0.1pre20200512.caa60026e223fc501e8b337fd5086ece4028b1c6:../../devel/gyp
+TOOL_DEPENDS+= ${PYPKGPREFIX}-six-[0-9]*:../../lang/py-six
+TOOL_DEPENDS+= ninja-build-[0-9]*:../../devel/ninja-build
+
+USE_LANGUAGES= c c++
+USE_TOOLS+=    gmake pkg-config
+
+USE_CXX_FEATURES+=     c++11
+
+CHECK_PORTABILITY_SKIP+=       third_party/protobuf/src/google/protobuf/compiler/zip_output_unittest.sh
+
+OPENSSL_CFLAGS=                -I${BUILDLINK_PREFIX.openssl}/include
+OPENSSL_INC=           -I${BUILDLINK_PREFIX.openssl}/include
+OPENSSL_LDFLAGS=       -L${BUILDLINK_PREFIX.openssl}/lib -lssl -lcrypto
+OPENSSL_LIBS=          -lssl -lcrypto
+
+SUBST_CLASSES+=                gyp
+SUBST_STAGE.gyp=       pre-configure
+SUBST_MESSAGE.gyp=     Fix gyp defaults
+SUBST_FILES.gyp+=      config.bzl
+SUBST_FILES.gyp+=      base/process.cc
+SUBST_FILES.gyp+=      gyp/directories.gypi
+SUBST_FILES.gyp+=      unix/ibus/ibus.gyp
+SUBST_FILES.gyp+=      unix/ibus/path_util.cc
+SUBST_VARS.gyp+=       OPENSSL_CFLAGS OPENSSL_INC OPENSSL_LDFLAGS OPENSSL_LIBS
+SUBST_VARS.gyp+=       PREFIX
+
+# To disable flock(1) in link stage.
+ALL_ENV+=      LINK=${CXX}
+
+.include "../../mk/bsd.prefs.mk"
+
+OPSYSVARS+=    OSDEST
+OSDEST.Linux=  linux
+OSDEST.NetBSD= bsd
+
+MOZC_BUILD_MODE=       Release # or Debug
+
+# In file included from src/dictionary/system/system_dictionary.h:43:0,
+#                  from ../../dictionary/system/system_dictionary.cc:47:
+# src/dictionary/system/key_expansion_table.h: In member function 'const mozc::dictionary::ExpandedKey mozc::dictionary::KeyExpansionTable::ExpandKey(char) const':
+# src/dictionary/system/key_expansion_table.h:83:34: error: array subscript has type 'char' [-Werror=char-subscripts]
+#      return ExpandedKey(table_[key]);
+# Maybe fix this later.
+BUILDLINK_TRANSFORM+=  rm:-Werror=char-subscripts
+
+do-configure:
+       cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} \
+               ${PYTHONBIN} build_mozc.py \
+               gyp \
+               --gypdir=${LOCALBASE}/bin
+
+.include "../../devel/glib2/buildlink3.mk"
+#.include "../../devel/protobuf/buildlink3.mk"
+# gmock is not used yet...
+#.include "../../devel/gmock/buildlink3.mk"
+.include "../../inputmethod/zinnia/buildlink3.mk"
+.include "../../www/curl/buildlink3.mk"
+.include "../../x11/gtk2/buildlink3.mk"
+.include "../../x11/qt5-qtbase/buildlink3.mk"
+
+.include "../../lang/python/tool.mk"
+.include "../../mk/atomic64.mk"
Index: pkgsrc/inputmethod/mozc-server226/PLIST
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/PLIST:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/PLIST     Sat Feb 10 01:20:46 2024
@@ -0,0 +1,2 @@
+@comment $NetBSD: PLIST,v 1.1 2024/02/10 01:20:46 ryoon Exp $
+libexec/mozc_server
Index: pkgsrc/inputmethod/mozc-server226/distinfo
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/distinfo:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/distinfo  Sat Feb 10 01:20:46 2024
@@ -0,0 +1,48 @@
+$NetBSD: distinfo,v 1.1 2024/02/10 01:20:46 ryoon Exp $
+
+BLAKE2s (mozc-2.26.4282.100.tar.xz) = 0d6239653ece7577159c7dc23ead2e2a42239496f0b7c3d30db472634689d12e
+SHA512 (mozc-2.26.4282.100.tar.xz) = 236ec8ece076aea04480cb9aee30076699a30db88356c8bd9eb0694d86716a89748a6d33d66f5ba831e95bd0d16260e3111a9c75fded9e34df35e1785980cf12
+Size (mozc-2.26.4282.100.tar.xz) = 38346468 bytes
+BLAKE2s (uim-mozc-321.3ea28b1.tar.xz) = 56a29c64bd2a2a309f3c7ffd248d21a404f3e00d2058da2d4b3b356d0184cad5
+SHA512 (uim-mozc-321.3ea28b1.tar.xz) = b28f4d207a52c208694371dbc550ac5022a29c5870b8d856bca8052106d8be88ab8d066bdc6d895ac6fa9f350ce6be16d638603e46058f9528691f97cb86d054
+Size (uim-mozc-321.3ea28b1.tar.xz) = 24400 bytes
+SHA1 (patch-base_base.gyp) = d8d9abc0da196f0573ad645937812710c7c67746
+SHA1 (patch-base_clock.cc) = bac420650fed0450cf82b5071703a1c60e974a93
+SHA1 (patch-base_cpu__stats.cc) = 9c18fb2543f352951969822e0095f01f0e8d3bcd
+SHA1 (patch-base_logging.cc) = 65938bf4f4d414a0c3bcaffe9615d976dcab2254
+SHA1 (patch-base_mutex.cc) = c52761be5ef60af35685a4de18ef18a083b1d0b9
+SHA1 (patch-base_password__manager.cc) = 6b669b7c2cf15b1a85e648265dfca0f34e86d00d
+SHA1 (patch-base_port.h) = 73b76a61759e32dcb7edcbb70b5cff6ad091a15c
+SHA1 (patch-base_process.cc) = 9b838e6178d7dd64012c94b9c55a201d096e4680
+SHA1 (patch-base_run__level.cc) = b26b0c8a457b9feb9a4de0abd7d5aae5bcd9e491
+SHA1 (patch-base_system__util.cc) = bdd468c5a22fe8ecc3de57168162944afd0bb20d
+SHA1 (patch-base_thread.cc) = 5e62c41beedc57dec004d100753bae4c77289762
+SHA1 (patch-build__mozc.py) = c0ef43010c0f048550ed4a5e9bb7b29c8a24ac77
+SHA1 (patch-build__tools_mozc__version.py) = 133f6b17d9dc811284901513e4e4ae3711710082
+SHA1 (patch-build__tools_util.py) = 5ca614adf2453fcc33c18cda74c0d9b2e4f6bc21
+SHA1 (patch-client_client.cc) = c11341d48ce55af0aea440800da4a53a62a436c1
+SHA1 (patch-config.bzl) = 5f959d46741f2f3fbf0fbbe38aa8fa1baafadb27
+SHA1 (patch-config_stats__config__util__test.cc) = f1af7403f8e06faadc5c46267d2d8b26a60c8f8d
+SHA1 (patch-gui_config__dialog_config__dialog.cc) = f3349d6ed2bee63f7bb92bc71f9d8a8ab1316b74
+SHA1 (patch-gui_config__dialog_keybinding__editor.cc) = 09c03f57031306b5cca8f1e546719db936159e2d
+SHA1 (patch-gui_dictionary__tool_dictionary__tool.cc) = cae617cc8e324b0f93adc1e76632a018530cd2c7
+SHA1 (patch-gui_qt__libraries.gypi) = ceb8d5b15d4cd5b2d907406f02413290bd4ab652
+SHA1 (patch-gui_qt__moc.gypi) = e3d42e61b35012cda10da13aa03cee67786e171c
+SHA1 (patch-gui_qt__rcc.gypi) = d38a849fe8e81672eb441a41936f454d8e45ff5c
+SHA1 (patch-gui_qt__uic.gypi) = 7dd69ee109e81f0e70f2866b77555412518b4844
+SHA1 (patch-gui_word__register__dialog_word__register__dialog.cc) = 218e3706b819855814ba8871504fc7ccb4e40b23
+SHA1 (patch-gyp_common.gypi) = ce27e8665b9dab4dc6d34d337a2cb8c985c9e6f4
+SHA1 (patch-gyp_directories.gypi) = eea985113aac5b99bf3c12267ad754817eef5dcc
+SHA1 (patch-ipc_ipc__path__manager.cc) = cd1352bd5333f1ed755dcf6221f931fcd0a936d3
+SHA1 (patch-ipc_ipc__path__manager__test.cc) = 1b83b513383f184f5ab5a56cce734b7934998533
+SHA1 (patch-ipc_named__event.cc) = 8be0b1e5c4675e5b238e07b63e395dbed3c2d125
+SHA1 (patch-ipc_unix__ipc.cc) = d5d86910ca610015103a309bba8d6392d96f6ce6
+SHA1 (patch-protobuf_protobuf.gyp) = bb1c9684881199936abb8acd73948d1cb174a1ea
+SHA1 (patch-renderer_renderer.gyp) = 83493259d6b8cd9ab6871512bebc9616d72132d1
+SHA1 (patch-session_session.cc) = 3ae2c8dd056aae4c92d9dbfdac53d9c45261aad2
+SHA1 (patch-session_session__test.cc) = 7396e2f4931257d8a33087b1bed5418a038fefa1
+SHA1 (patch-third__party_abseil-cpp_absl_base_config.h) = e996fad886e0763c7be7b79735819e668159fd82
+SHA1 (patch-third__party_protobuf_post__process__dist.sh) = 8adc79d5d7eed3cbf406ebcfbd5832b7a050ced6
+SHA1 (patch-uim-mozc) = 0000583d8f3f44ef2281888c7cfdb968c17ec798
+SHA1 (patch-unix_ibus_ibus.gyp) = aa2077cf3c379bf9ce33e97abe478540346782ad
+SHA1 (patch-unix_ibus_path__util.cc) = a6aa368d9ce8926e200602fdc370c13e35d5a8cf

Index: pkgsrc/inputmethod/mozc-server226/patches/patch-base_base.gyp
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-base_base.gyp:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-base_base.gyp       Sat Feb 10 01:20:46 2024
@@ -0,0 +1,15 @@
+$NetBSD: patch-base_base.gyp,v 1.1 2024/02/10 01:20:46 ryoon Exp $
+
+* NetBSD support
+
+--- base/base.gyp.orig 2017-11-02 13:32:45.000000000 +0000
++++ base/base.gyp
+@@ -141,7 +141,7 @@
+             },
+           },
+         }],
+-        ['target_platform=="Linux" and server_dir!=""', {
++        ['(target_platform=="Linux" or target_platform=="NetBSD") and server_dir!=""', {
+           'defines': [
+             'MOZC_SERVER_DIRECTORY="<(server_dir)"',
+           ],
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-base_clock.cc
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-base_clock.cc:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-base_clock.cc       Sat Feb 10 01:20:46 2024
@@ -0,0 +1,24 @@
+$NetBSD: patch-base_clock.cc,v 1.1 2024/02/10 01:20:46 ryoon Exp $
+
+* NetBSD support
+
+--- base/clock.cc.orig 2021-02-15 03:48:53.000000000 +0000
++++ base/clock.cc
+@@ -116,7 +116,7 @@ class ClockImpl : public ClockInterface 
+     mach_timebase_info(&timebase_info);
+     return static_cast<uint64>(1.0e9 * timebase_info.denom /
+                                timebase_info.numer);
+-#elif defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM)
++#elif defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM) || defined(OS_NETBSD)
+     return 1000000uLL;
+ #else  // platforms (OS_WIN, __APPLE__, OS_LINUX, ...)
+ #error "Not supported platform"
+@@ -133,7 +133,7 @@ class ClockImpl : public ClockInterface 
+     return static_cast<uint64>(timestamp.QuadPart);
+ #elif defined(__APPLE__)
+     return static_cast<uint64>(mach_absolute_time());
+-#elif defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM)
++#elif defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM) || defined(OS_NETBSD)
+     uint64 sec;
+     uint32 usec;
+     GetTimeOfDay(&sec, &usec);
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-base_cpu__stats.cc
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-base_cpu__stats.cc:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-base_cpu__stats.cc  Sat Feb 10 01:20:46 2024
@@ -0,0 +1,48 @@
+$NetBSD: patch-base_cpu__stats.cc,v 1.1 2024/02/10 01:20:46 ryoon Exp $
+
+* NetBSD support
+
+--- base/cpu_stats.cc.orig     2021-02-15 03:48:53.000000000 +0000
++++ base/cpu_stats.cc
+@@ -122,13 +122,13 @@ float CPUStats::GetSystemCPULoad() {
+ 
+ #endif  // __APPLE__
+ 
+-#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM)
++#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM) || defined(OS_NETBSD)
+   // NOT IMPLEMENTED
+   // TODO(taku): implement Linux version
+   // can take the info from /proc/stats
+   const uint64 total_times = 0;
+   const uint64 cpu_times = 0;
+-#endif  // OS_LINUX || OS_ANDROID || OS_WASM
++#endif  // OS_LINUX || OS_ANDROID || OS_WASM || OS_NETBSD
+ 
+   return UpdateCPULoad(total_times, cpu_times, &prev_system_total_times_,
+                        &prev_system_cpu_times_);
+@@ -175,11 +175,11 @@ float CPUStats::GetCurrentProcessCPULoad
+                            TimeValueTToInt64(task_times_info.system_time);
+ #endif  // __APPLE__
+ 
+-#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM)
++#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM) || defined(OS_NETBSD)
+   // not implemented
+   const uint64 total_times = 0;
+   const uint64 cpu_times = 0;
+-#endif  // OS_LINUX || OS_ANDROID || OS_WASM
++#endif  // OS_LINUX || OS_ANDROID || OS_WASM || OS_NETBSD
+ 
+   return UpdateCPULoad(total_times, cpu_times,
+                        &prev_current_process_total_times_,
+@@ -206,9 +206,9 @@ size_t CPUStats::GetNumberOfProcessors()
+   return static_cast<size_t>(basic_info.avail_cpus);
+ #endif  // __APPLE__
+ 
+-#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM)
++#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM) || defined(OS_NETBSD)
+   // Not implemented
+   return 1;
+-#endif  // OS_LINUX
++#endif  // OS_LINUX || OS_ANDROID || OS_WASM || OS_NETBSD
+ }
+ }  // namespace mozc
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-base_logging.cc
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-base_logging.cc:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-base_logging.cc     Sat Feb 10 01:20:46 2024
@@ -0,0 +1,27 @@
+$NetBSD: patch-base_logging.cc,v 1.1 2024/02/10 01:20:46 ryoon Exp $
+
+* NetBSD support
+
+--- base/logging.cc.orig       2021-02-15 05:04:33.000000000 +0000
++++ base/logging.cc
+@@ -62,6 +62,10 @@
+ #include "absl/flags/flag.h"
+ #include "absl/strings/str_cat.h"
+ 
++#if defined(OS_NETBSD)
++#include <lwp.h>
++#endif
++
+ ABSL_FLAG(bool, colored_log, true,
+           "Enables colored log messages on tty devices");
+ ABSL_FLAG(bool, logtostderr, false,
+@@ -112,6 +116,9 @@ string Logging::GetLogMessageHeader() {
+   return absl::StrCat(timestamp, ::getpid(), " ",
+                       // It returns unsigned long.
+                       pthread_self());
++# elif defined(OS_NETBSD)
++  return absl::StrCat(timestamp, ::getpid(), " ",
++                      (unsigned long)_lwp_self());
+ # elif defined(__APPLE__)
+ #  ifdef __LP64__
+   return absl::StrCat(timestamp, ::getpid(), " ",
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-base_mutex.cc
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-base_mutex.cc:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-base_mutex.cc       Sat Feb 10 01:20:46 2024
@@ -0,0 +1,15 @@
+$NetBSD: patch-base_mutex.cc,v 1.1 2024/02/10 01:20:46 ryoon Exp $
+
+* NetBSD support
+
+--- base/mutex.cc.orig 2021-02-15 03:48:53.000000000 +0000
++++ base/mutex.cc
+@@ -148,7 +148,7 @@ Mutex::Mutex() {
+   // PTHREAD_MUTEX_RECURSIVE_NP but Mac OS X 10.5 does not
+   pthread_mutexattr_t attr;
+   pthread_mutexattr_init(&attr);
+-#if defined(__APPLE__) || defined(OS_WASM)
++#if defined(__APPLE__) || defined(OS_WASM) || defined(OS_NETBSD)
+   pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+ #elif defined(OS_LINUX) || defined(OS_ANDROID)
+   pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-base_password__manager.cc
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-base_password__manager.cc:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-base_password__manager.cc   Sat Feb 10 01:20:46 2024
@@ -0,0 +1,15 @@
+$NetBSD: patch-base_password__manager.cc,v 1.1 2024/02/10 01:20:46 ryoon Exp $
+
+* NetBSD support
+
+--- base/password_manager.cc.orig      2021-02-15 03:48:53.000000000 +0000
++++ base/password_manager.cc
+@@ -264,7 +264,7 @@ bool WinMacPasswordManager::RemovePasswo
+ // We use plain text file for password storage on Linux. If you port this module
+ // to other Linux distro, you might want to implement a new password manager
+ // which adopts some secure mechanism such like gnome-keyring.
+-#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM)
++#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM) || defined(OS_NETBSD)
+ typedef PlainPasswordManager DefaultPasswordManager;
+ #endif  // OS_LINUX || OS_ANDROID || OS_WASM
+ 
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-base_port.h
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-base_port.h:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-base_port.h Sat Feb 10 01:20:46 2024
@@ -0,0 +1,15 @@
+$NetBSD: patch-base_port.h,v 1.1 2024/02/10 01:20:46 ryoon Exp $
+
+--- base/port.h.orig   2021-02-15 05:04:33.000000000 +0000
++++ base/port.h
+@@ -69,6 +69,10 @@ using std::string;
+ #define MOZC_OS_DEFINED
+ #endif  // OS_WASM
+ 
++#ifdef OS_NETBSD
++#define MOZC_OS_DEFINED
++#endif  // OS_NETBSD
++
+ #ifndef MOZC_OS_DEFINED
+ #error "OS_XXX (e.g., OS_WIN) must be defined."
+ #endif  // !MOZC_OS_DEFINED
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-base_process.cc
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-base_process.cc:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-base_process.cc     Sat Feb 10 01:20:46 2024
@@ -0,0 +1,73 @@
+$NetBSD: patch-base_process.cc,v 1.1 2024/02/10 01:20:46 ryoon Exp $
+
+* NetBSD support
+
+--- base/process.cc.orig       2021-02-15 03:48:53.000000000 +0000
++++ base/process.cc
+@@ -46,12 +46,12 @@
+ #include "base/mac_process.h"
+ #endif  // __APPLE__
+ 
+-#if defined(OS_LINUX) || defined(OS_ANDROID)
++#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_NETBSD)
+ #include <fcntl.h>
+ #include <signal.h>
+ #include <spawn.h>  // for posix_spawn().
+ #include <sys/types.h>
+-#endif  // OS_LINUX || OS_ANDROID
++#endif  // OS_LINUX || OS_ANDROID || OS_NETBSD
+ 
+ #include <cstdlib>
+ #include <memory>
+@@ -98,12 +98,12 @@ bool Process::OpenBrowser(const std::str
+   return WinUtil::ShellExecuteInSystemDir(L"open", wurl.c_str(), nullptr);
+ #endif
+ 
+-#if defined(OS_LINUX) || defined(OS_ANDROID)
+-  static const char kBrowserCommand[] = "/usr/bin/xdg-open";
++#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_NETBSD)
++  static const char kBrowserCommand[] = "@PREFIX@/bin/xdg-open";
+   // xdg-open which uses kfmclient or gnome-open internally works both on KDE
+   // and GNOME environments.
+   return SpawnProcess(kBrowserCommand, url);
+-#endif  // OS_LINUX || OS_ANDROID
++#endif  // OS_LINUX || OS_ANDROID || OS_NETBSD
+ 
+ #ifdef __APPLE__
+   return MacProcess::OpenBrowserForMac(url);
+@@ -185,7 +185,7 @@ bool Process::SpawnProcess(const std::st
+   }
+ #endif
+ 
+-#if defined(OS_LINUX) || defined(OS_ANDROID)
++#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_NETBSD)
+   // Do not call posix_spawn() for obviously bad path.
+   if (!S_ISREG(statbuf.st_mode)) {
+     LOG(ERROR) << "Not a regular file: " << path;
+@@ -208,7 +208,7 @@ bool Process::SpawnProcess(const std::st
+   // (www.gnu.org/software/libc/manual/html_node/Heap-Consistency-Checking.html)
+   const int kOverwrite = 0;  // Do not overwrite.
+   ::setenv("MALLOC_CHECK_", "2", kOverwrite);
+-#endif  // OS_LINUX || OS_ANDROID
++#endif  // OS_LINUX || OS_ANDROID || OS_NETBSD
+   pid_t tmp_pid = 0;
+ 
+   // Spawn new process.
+@@ -383,7 +383,7 @@ bool Process::LaunchErrorMessageDialog(c
+   }
+ #endif  // OS_WIN
+ 
+-#if defined(OS_LINUX) || defined(OS_ANDROID)
++#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_NETBSD)
+   const char kMozcTool[] = "mozc_tool";
+   const std::string arg =
+       "--mode=error_message_dialog --error_type=" + error_type;
+@@ -392,7 +392,7 @@ bool Process::LaunchErrorMessageDialog(c
+     LOG(ERROR) << "cannot launch " << kMozcTool;
+     return false;
+   }
+-#endif  // OS_LINUX || OS_ANDROID
++#endif  // OS_LINUX || OS_ANDROID || OS_NETBSD
+ 
+   return true;
+ }
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-base_run__level.cc
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-base_run__level.cc:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-base_run__level.cc  Sat Feb 10 01:20:46 2024
@@ -0,0 +1,19 @@
+$NetBSD: patch-base_run__level.cc,v 1.1 2024/02/10 01:20:46 ryoon Exp $
+
+* NetBSD support
+
+--- base/run_level.cc.orig     2021-02-15 03:48:53.000000000 +0000
++++ base/run_level.cc
+@@ -38,10 +38,10 @@
+ #include <unistd.h>
+ #endif  // __APPLE__
+ 
+-#if defined(OS_LINUX) || defined(OS_ANDROID)
++#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_NETBSD)
+ #include <sys/types.h>
+ #include <unistd.h>
+-#endif  // OS_LINUX || OS_ANDROID
++#endif  // OS_LINUX || OS_ANDROID || OS_NETBSD
+ 
+ #include "base/const.h"
+ #include "base/logging.h"
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-base_system__util.cc
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-base_system__util.cc:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-base_system__util.cc        Sat Feb 10 01:20:46 2024
@@ -0,0 +1,87 @@
+$NetBSD: patch-base_system__util.cc,v 1.1 2024/02/10 01:20:46 ryoon Exp $
+
+--- base/system_util.cc.orig   2021-02-15 05:04:33.000000000 +0000
++++ base/system_util.cc
+@@ -275,7 +275,7 @@ std::string UserProfileDirectoryImpl::Ge
+ # endif  //  GOOGLE_JAPANESE_INPUT_BUILD
+ 
+ 
+-#elif defined(OS_LINUX)
++#elif defined(OS_LINUX) || defined(OS_NETBSD)
+   // 1. If "$HOME/.mozc" already exists,
+   //    use "$HOME/.mozc" for backward compatibility.
+   // 2. If $XDG_CONFIG_HOME is defined
+@@ -422,7 +422,7 @@ std::string SystemUtil::GetServerDirecto
+   return MacUtil::GetServerDirectory();
+ #endif  // __APPLE__
+ 
+-#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM)
++#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM) || defined(OS_NETBSD)
+ # if defined(MOZC_SERVER_DIRECTORY)
+   return MOZC_SERVER_DIRECTORY;
+ # else
+@@ -499,12 +499,12 @@ std::string SystemUtil::GetUserNameAsStr
+   return ppw->pw_name;
+ #endif  // OS_ANDROID
+ 
+-#if defined(__APPLE__) || defined(OS_LINUX) || defined(OS_WASM)
++#if defined(__APPLE__) || defined(OS_LINUX) || defined(OS_WASM) || defined(OS_NETBSD)
+   struct passwd pw, *ppw;
+   char buf[1024];
+   CHECK_EQ(0, getpwuid_r(geteuid(), &pw, buf, sizeof(buf), &ppw));
+   return pw.pw_name;
+-#endif  // __APPLE__ || OS_LINUX || OS_WASM
++#endif  // __APPLE__ || OS_LINUX || OS_WASM || OS_NETBSD
+ 
+   // If none of the above platforms is specified, the compiler raises an error
+   // because of no return value.
+@@ -662,13 +662,13 @@ string GetSessionIdString() {
+ #endif  // OS_WIN
+ 
+ std::string SystemUtil::GetDesktopNameAsString() {
+-#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM)
++#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM) || defined(OS_NETBSD)
+   const char *display = Environ::GetEnv("DISPLAY");
+   if (display == nullptr) {
+     return "";
+   }
+   return display;
+-#endif  // OS_LINUX || OS_ANDROID || OS_WASM
++#endif  // OS_LINUX || OS_ANDROID || OS_WASM || OS_NETBSD
+ 
+ #if defined(__APPLE__)
+   return "";
+@@ -862,10 +862,13 @@ std::string SystemUtil::GetOSVersionStri
+ #elif defined(OS_LINUX)
+   const std::string ret = "Linux";
+   return ret;
+-#else   // !OS_WIN && !__APPLE__ && !OS_LINUX
++#elif defined(OS_NETBSD)
++  const std::string ret = "NetBSD";
++  return ret;
++#else   // !OS_WIN && !__APPLE__ && !OS_LINUX && !OS_NETBSD
+   const string ret = "Unknown";
+   return ret;
+-#endif  // OS_WIN, __APPLE__, OS_LINUX
++#endif  // OS_WIN, __APPLE__, OS_LINUX, OS_NETBSD
+ }
+ 
+ void SystemUtil::DisableIME() {
+@@ -901,7 +904,7 @@ uint64 SystemUtil::GetTotalPhysicalMemor
+   return total_memory;
+ #endif  // __APPLE__
+ 
+-#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM)
++#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM) || defined(OS_NETBSD)
+ # if defined(_SC_PAGESIZE) && defined(_SC_PHYS_PAGES)
+   const int32 page_size = sysconf(_SC_PAGESIZE);
+   const int32 number_of_phyisical_pages = sysconf(_SC_PHYS_PAGES);
+@@ -914,7 +917,7 @@ uint64 SystemUtil::GetTotalPhysicalMemor
+ # else   // defined(_SC_PAGESIZE) && defined(_SC_PHYS_PAGES)
+   return 0;
+ # endif  // defined(_SC_PAGESIZE) && defined(_SC_PHYS_PAGES)
+-#endif   // OS_LINUX || OS_ANDROID || OS_WASM
++#endif   // OS_LINUX || OS_ANDROID || OS_WASM || OS_NETBSD
+ 
+   // If none of the above platforms is specified, the compiler raises an error
+   // because of no return value.
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-base_thread.cc
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-base_thread.cc:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-base_thread.cc      Sat Feb 10 01:20:46 2024
@@ -0,0 +1,20 @@
+$NetBSD: patch-base_thread.cc,v 1.1 2024/02/10 01:20:46 ryoon Exp $
+
+* tweak for NetBSD pthread_setname_np(3)
+
+--- base/thread.cc.orig        2021-02-15 03:48:53.000000000 +0000
++++ base/thread.cc
+@@ -145,9 +145,11 @@ void Thread::Start(const std::string &th
+     // WASM doesn't support setname?
+ #elif defined(__APPLE__)  // !OS_WASM
+     pthread_setname_np(thread_name.c_str());
+-#else                     // !(OS_WASM | __APPLE__)
++#elif defined(OS_NETBSD)
++    pthread_setname_np(*state_->handle, "%s", (void *)thread_name.c_str());
++#else                     // !(OS_WASM | __APPLE__ | OS_NETBSD)
+     pthread_setname_np(*state_->handle, thread_name.c_str());
+-#endif                    // !(OS_WASM | __APPLE__)
++#endif                    // !(OS_WASM | __APPLE__ | OS_NETBSD)
+   }
+ }
+ 
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-build__mozc.py
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-build__mozc.py:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-build__mozc.py      Sat Feb 10 01:20:46 2024
@@ -0,0 +1,73 @@
+$NetBSD: patch-build__mozc.py,v 1.1 2024/02/10 01:20:46 ryoon Exp $
+
+* NetBSD support
+
+--- build_mozc.py.orig 2021-02-15 03:48:53.000000000 +0000
++++ build_mozc.py
+@@ -55,6 +55,7 @@ from build_tools.util import CopyFile
+ from build_tools.util import GetNumberOfProcessors
+ from build_tools.util import IsLinux
+ from build_tools.util import IsMac
++from build_tools.util import IsNetBSD
+ from build_tools.util import IsWindows
+ from build_tools.util import PrintErrorAndExit
+ from build_tools.util import RemoveDirectoryRecursively
+@@ -96,6 +97,7 @@ def GetBuildShortBaseName(target_platfor
+       'Windows': 'out_win',
+       'Mac': 'out_mac',
+       'Linux': 'out_linux',
++      'NetBSD': 'out_bsd',
+       'iOS': 'out_ios',
+   }
+ 
+@@ -155,7 +157,7 @@ def GetGypFileNames(options):
+   # Include subdirectory of win32 and breakpad for Windows
+   if options.target_platform == 'Windows':
+     gyp_file_names.extend(glob.glob('%s/win32/*/*.gyp' % SRC_DIR))
+-  elif options.target_platform == 'Linux':
++  elif options.target_platform == 'Linux' or options.target_platform == 'NetBSD':
+     gyp_file_names.extend(glob.glob('%s/unix/*/*.gyp' % SRC_DIR))
+     # Add ibus.gyp if ibus version is >=1.4.1.
+     if not PkgExists('ibus-1.0 >= 1.4.1'):
+@@ -182,6 +184,8 @@ def ParseVerbose(unused_option, unused_o
+ def AddTargetPlatformOption(parser):
+   if IsLinux():
+     default_target = 'Linux'
++  if IsNetBSD():
++    default_target = 'NetBSD'
+   elif IsWindows():
+     default_target = 'Windows'
+   elif IsMac():
+@@ -269,6 +273,12 @@ def ExpandMetaTarget(options, meta_targe
+                SRC_DIR + '/gui/gui.gyp:mozc_tool']
+     if PkgExists('ibus-1.0 >= 1.4.1'):
+       targets.append(SRC_DIR + '/unix/ibus/ibus.gyp:ibus_mozc')
++  elif target_platform == 'NetBSD':
++    targets = [SRC_DIR + '/server/server.gyp:mozc_server',
++               SRC_DIR + '/renderer/renderer.gyp:mozc_renderer',
++               SRC_DIR + '/gui/gui.gyp:mozc_tool']
++    if PkgExists('ibus-1.0 >= 1.4.1'):
++      targets.append(SRC_DIR + '/unix/ibus/ibus.gyp:ibus_mozc')
+   elif target_platform == 'Mac':
+     targets = [SRC_DIR + '/mac/mac.gyp:codesign_DiskImage']
+   elif target_platform == 'Windows':
+@@ -441,7 +451,8 @@ def GypMain(options, unused_args):
+   if options.noqt:
+     gyp_options.extend(['-D', 'use_qt=NO'])
+     gyp_options.extend(['-D', 'qt_dir='])
+-  elif target_platform == 'Linux':
++  elif (target_platform == 'Linux' or
++       target_platform == 'NetBSD'):
+     gyp_options.extend(['-D', 'use_qt=YES'])
+     gyp_options.extend(['-D', 'qt_dir='])
+ 
+@@ -482,7 +493,8 @@ def GypMain(options, unused_args):
+   if IsWindows():
+     gyp_options.extend(['-G', 'msvs_version=2017'])
+ 
+-  if (target_platform == 'Linux' and
++  if ((target_platform == 'Linux' or
++       target_platform == 'NetBSD') and
+       '%s/unix/ibus/ibus.gyp' % SRC_DIR in gyp_file_names):
+     gyp_options.extend(['-D', 'use_libibus=1'])
+ 
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-build__tools_mozc__version.py
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-build__tools_mozc__version.py:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-build__tools_mozc__version.py       Sat Feb 10 01:20:46 2024
@@ -0,0 +1,14 @@
+$NetBSD: patch-build__tools_mozc__version.py,v 1.1 2024/02/10 01:20:46 ryoon Exp $
+
+* NetBSD support
+
+--- build_tools/mozc_version.py.orig   2021-02-15 03:48:53.000000000 +0000
++++ build_tools/mozc_version.py
+@@ -69,6 +69,7 @@ TARGET_PLATFORM_TO_DIGIT = {
+     'iOS': '6',
+     'iOS_sim': '6',
+     'Wasm': '7',
++    'NetBSD': '8',
+ }
+ 
+ VERSION_PROPERTIES = [
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-build__tools_util.py
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-build__tools_util.py:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-build__tools_util.py        Sat Feb 10 01:20:46 2024
@@ -0,0 +1,18 @@
+$NetBSD: patch-build__tools_util.py,v 1.1 2024/02/10 01:20:46 ryoon Exp $
+
+* NetBSD support
+
+--- build_tools/util.py.orig   2016-05-15 08:11:10.000000000 +0000
++++ build_tools/util.py
+@@ -59,6 +59,11 @@ def IsLinux():
+   return os.name == 'posix' and os.uname()[0] == 'Linux'
+ 
+ 
++def IsNetBSD():
++  """Returns true if the platform is NetBSD."""
++  return os.name == 'posix' and os.uname()[0] == 'NetBSD'
++
++
+ def GetNumberOfProcessors():
+   """Returns the number of CPU cores available.
+ 
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-client_client.cc
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-client_client.cc:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-client_client.cc    Sat Feb 10 01:20:46 2024
@@ -0,0 +1,24 @@
+$NetBSD: patch-client_client.cc,v 1.1 2024/02/10 01:20:46 ryoon Exp $
+
+* NetBSD support
+
+--- client/client.cc.orig      2021-02-15 03:48:53.000000000 +0000
++++ client/client.cc
+@@ -867,7 +867,7 @@ bool Client::LaunchTool(const std::strin
+     return false;
+   }
+ 
+-#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_ANDROID)
++#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_NETBSD)
+   std::string arg = "--mode=" + mode;
+   if (!extra_arg.empty()) {
+     arg += " ";
+@@ -877,7 +877,7 @@ bool Client::LaunchTool(const std::strin
+     LOG(ERROR) << "Cannot execute: " << kMozcTool << " " << arg;
+     return false;
+   }
+-#endif  // OS_WIN || OS_LINUX || OS_ANDROID
++#endif  // OS_WIN || OS_LINUX || OS_ANDROID || OS_NETBSD
+ 
+   // TODO(taku): move MacProcess inside SpawnMozcProcess.
+   // TODO(taku): support extra_arg.
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-config.bzl
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-config.bzl:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-config.bzl  Sat Feb 10 01:20:46 2024
@@ -0,0 +1,19 @@
+$NetBSD: patch-config.bzl,v 1.1 2024/02/10 01:20:46 ryoon Exp $
+
+* For pkgsrc layout.
+
+--- config.bzl.orig    2021-02-15 05:04:34.000000000 +0000
++++ config.bzl
+@@ -30,9 +30,9 @@
+ 
+ BRANDING = "Mozc"
+ 
+-LINUX_MOZC_SERVER_DIRECTORY = "/usr/lib/mozc"
+-IBUS_MOZC_ICON_PATH = "/usr/share/ibus-mozc/product_icon.png"
+-IBUS_MOZC_PATH = "/usr/lib/ibus-mozc/ibus-engine-mozc"
++LINUX_MOZC_SERVER_DIRECTORY = "@PREFIX@/libexec"
++IBUS_MOZC_ICON_PATH = "@PREFIX@/share/ibus-mozc/product_icon.png"
++IBUS_MOZC_PATH = "@PREFIX@/libexec/ibus-engine-mozc"
+ 
+ MACOS_BUNDLE_ID_PREFIX = "org.mozc.inputmethod.Japanese"
+ MACOS_MIN_OS_VER = "10.12"
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-config_stats__config__util__test.cc
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-config_stats__config__util__test.cc:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-config_stats__config__util__test.cc Sat Feb 10 01:20:47 2024
@@ -0,0 +1,20 @@
+$NetBSD: patch-config_stats__config__util__test.cc,v 1.1 2024/02/10 01:20:47 ryoon Exp $
+
+* NetBSD support
+
+--- config/stats_config_util_test.cc.orig      2021-02-15 03:48:53.000000000 +0000
++++ config/stats_config_util_test.cc
+@@ -685,11 +685,11 @@ TEST(StatsConfigUtilTestAndroid, Default
+ }
+ #endif  // OS_ANDROID
+ 
+-#if defined(OS_LINUX)
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+ TEST(StatsConfigUtilTestLinux, DefaultValueTest) {
+   EXPECT_FALSE(StatsConfigUtil::IsEnabled());
+ }
+-#endif  // OS_LINUX
++#endif  // OS_LINUX || OS_NETBSD
+ 
+ #else  // !GOOGLE_JAPANESE_INPUT_BUILD
+ TEST(StatsConfigUtilTestNonOfficialBuild, DefaultValueTest) {
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-gui_config__dialog_config__dialog.cc
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-gui_config__dialog_config__dialog.cc:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-gui_config__dialog_config__dialog.cc        Sat Feb 10 01:20:47 2024
@@ -0,0 +1,50 @@
+$NetBSD: patch-gui_config__dialog_config__dialog.cc,v 1.1 2024/02/10 01:20:47 ryoon Exp $
+
+* NetBSD support
+
+--- gui/config_dialog/config_dialog.cc.orig    2021-02-15 03:48:53.000000000 +0000
++++ gui/config_dialog/config_dialog.cc
+@@ -104,21 +104,21 @@ ConfigDialog::ConfigDialog()
+   setWindowTitle(tr("%1 Preferences").arg(GuiUtil::ProductName()));
+ #endif  // __APPLE__
+ 
+-#if defined(OS_LINUX)
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+   miscDefaultIMEWidget->setVisible(false);
+   miscAdministrationWidget->setVisible(false);
+   miscStartupWidget->setVisible(false);
+-#endif  // OS_LINUX
++#endif  // OS_LINUX || OS_NETBSD
+ 
+ #ifdef MOZC_NO_LOGGING
+   // disable logging options
+   miscLoggingWidget->setVisible(false);
+ 
+-#if defined(OS_LINUX)
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+   // The last "misc" tab has no valid configs on Linux
+   const int kMiscTabIndex = 6;
+   configDialogTabWidget->removeTab(kMiscTabIndex);
+-#endif  // OS_LINUX
++#endif  // OS_LINUX || OS_NETBSD
+ #endif  // MOZC_NO_LOGGING
+ 
+   suggestionsSizeSpinBox->setRange(1, 9);
+@@ -280,7 +280,7 @@ ConfigDialog::ConfigDialog()
+   dictionaryPreloadingAndUACLabel->setVisible(false);
+ #endif  // OS_WIN
+ 
+-#ifdef OS_LINUX
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+   // On Linux, disable all fields for UsageStats
+   usageStatsLabel->setEnabled(false);
+   usageStatsLabel->setVisible(false);
+@@ -290,7 +290,7 @@ ConfigDialog::ConfigDialog()
+   usageStatsMessage->setVisible(false);
+   usageStatsCheckBox->setEnabled(false);
+   usageStatsCheckBox->setVisible(false);
+-#endif  // OS_LINUX
++#endif  // OS_LINUX || OS_NETBSD
+ 
+   GuiUtil::ReplaceWidgetLabels(this);
+ 
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-gui_config__dialog_keybinding__editor.cc
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-gui_config__dialog_keybinding__editor.cc:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-gui_config__dialog_keybinding__editor.cc    Sat Feb 10 01:20:47 2024
@@ -0,0 +1,24 @@
+$NetBSD: patch-gui_config__dialog_keybinding__editor.cc,v 1.1 2024/02/10 01:20:47 ryoon Exp $
+
+* NetBSD support
+
+--- gui/config_dialog/keybinding_editor.cc.orig        2021-02-15 03:48:53.000000000 +0000
++++ gui/config_dialog/keybinding_editor.cc
+@@ -381,7 +381,7 @@ KeyBindingFilter::KeyState KeyBindingFil
+       return Encode(result);
+     }
+   }
+-#elif OS_LINUX
++#elif defined(OS_LINUX) || defined(OS_NETBSD)
+   // The XKB defines three types of logical key code: "xkb::Hiragana",
+   // "xkb::Katakana" and "xkb::Hiragana_Katakana".
+   // On most of Linux distributions, any key event against physical
+@@ -478,7 +478,7 @@ bool KeyBindingFilter::eventFilter(QObje
+ KeyBindingEditor::KeyBindingEditor(QWidget *parent, QWidget *trigger_parent)
+     : QDialog(parent), trigger_parent_(trigger_parent) {
+   setupUi(this);
+-#if defined(OS_LINUX)
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+   // Workaround for the issue https://github.com/google/mozc/issues/9
+   // Seems that even after clicking the button for the keybinding dialog,
+   // the edit is not raised. This might be a bug of setFocusProxy.
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-gui_dictionary__tool_dictionary__tool.cc
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-gui_dictionary__tool_dictionary__tool.cc:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-gui_dictionary__tool_dictionary__tool.cc    Sat Feb 10 01:20:47 2024
@@ -0,0 +1,15 @@
+$NetBSD: patch-gui_dictionary__tool_dictionary__tool.cc,v 1.1 2024/02/10 01:20:47 ryoon Exp $
+
+* NetBSD support
+
+--- gui/dictionary_tool/dictionary_tool.cc.orig        2014-05-21 10:51:22.000000000 +0000
++++ gui/dictionary_tool/dictionary_tool.cc
+@@ -347,7 +347,7 @@ DictionaryTool::DictionaryTool(QWidget *
+ #endif  // !ENABLE_CLOUD_SYNC
+ 
+   // main window
+-#ifndef OS_LINUX
++#if !defined(OS_LINUX) && !defined(OS_NETBSD)
+   // For some reason setCentralWidget crashes the dictionary_tool on Linux
+   // TODO(taku): investigate the cause of the crashes
+   setCentralWidget(splitter_);
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-gui_qt__libraries.gypi
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-gui_qt__libraries.gypi:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-gui_qt__libraries.gypi      Sat Feb 10 01:20:47 2024
@@ -0,0 +1,15 @@
+$NetBSD: patch-gui_qt__libraries.gypi,v 1.1 2024/02/10 01:20:47 ryoon Exp $
+
+* NetBSD support
+
+--- gui/qt_libraries.gypi.orig 2017-11-02 13:32:47.000000000 +0000
++++ gui/qt_libraries.gypi
+@@ -98,7 +98,7 @@
+         '$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
+       ]
+     }],
+-    ['target_platform=="Linux"', {
++    ['target_platform=="Linux" or target_platform=="NetBSD"', {
+       'cflags': ['<!@(pkg-config --cflags Qt5Widgets Qt5Gui Qt5Core)'],
+       'libraries': ['<!@(pkg-config --libs Qt5Widgets Qt5Gui Qt5Core)'],
+     }],
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-gui_qt__moc.gypi
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-gui_qt__moc.gypi:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-gui_qt__moc.gypi    Sat Feb 10 01:20:47 2024
@@ -0,0 +1,15 @@
+$NetBSD: patch-gui_qt__moc.gypi,v 1.1 2024/02/10 01:20:47 ryoon Exp $
+
+* NetBSD support
+
+--- gui/qt_moc.gypi.orig       2017-11-02 13:32:47.000000000 +0000
++++ gui/qt_moc.gypi
+@@ -33,7 +33,7 @@
+ 
+   'variables': {
+     'conditions': [
+-      ['target_platform=="Linux"', {
++      ['target_platform=="Linux" or target_platform=="NetBSD"', {
+         'moc_path': '<!(pkg-config --variable=host_bins Qt5Core)/moc',
+       }, 'qt_dir', {
+         'moc_path': '<(qt_dir)/bin/moc<(EXECUTABLE_SUFFIX)',
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-gui_qt__rcc.gypi
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-gui_qt__rcc.gypi:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-gui_qt__rcc.gypi    Sat Feb 10 01:20:47 2024
@@ -0,0 +1,15 @@
+$NetBSD: patch-gui_qt__rcc.gypi,v 1.1 2024/02/10 01:20:47 ryoon Exp $
+
+* NetBSD support
+
+--- gui/qt_rcc.gypi.orig       2017-11-02 13:32:47.000000000 +0000
++++ gui/qt_rcc.gypi
+@@ -33,7 +33,7 @@
+ 
+   'variables': {
+     'conditions': [
+-      ['target_platform=="Linux"', {
++      ['target_platform=="Linux" or target_platform=="NetBSD"', {
+         'rcc_path': '<!(pkg-config --variable=host_bins Qt5Core)/rcc',
+       }, 'qt_dir', {
+         'rcc_path': '<(qt_dir)/bin/rcc<(EXECUTABLE_SUFFIX)',
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-gui_qt__uic.gypi
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-gui_qt__uic.gypi:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-gui_qt__uic.gypi    Sat Feb 10 01:20:47 2024
@@ -0,0 +1,15 @@
+$NetBSD: patch-gui_qt__uic.gypi,v 1.1 2024/02/10 01:20:47 ryoon Exp $
+
+* NetBSD support
+
+--- gui/qt_uic.gypi.orig       2017-11-02 13:32:47.000000000 +0000
++++ gui/qt_uic.gypi
+@@ -33,7 +33,7 @@
+ 
+   'variables': {
+     'conditions': [
+-      ['target_platform=="Linux"', {
++      ['target_platform=="Linux" or target_platform=="NetBSD"', {
+         'uic_path': '<!(pkg-config --variable=host_bins Qt5Core)/uic',
+       }, 'qt_dir', {
+         'uic_path': '<(qt_dir)/bin/uic<(EXECUTABLE_SUFFIX)',
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-gui_word__register__dialog_word__register__dialog.cc
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-gui_word__register__dialog_word__register__dialog.cc:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-gui_word__register__dialog_word__register__dialog.cc        Sat Feb 10 01:20:47 2024
@@ -0,0 +1,19 @@
+$NetBSD: patch-gui_word__register__dialog_word__register__dialog.cc,v 1.1 2024/02/10 01:20:47 ryoon Exp $
+
+* NetBSD support
+* Fix from https://github.com/google/mozc/issues/460
+
+--- gui/word_register_dialog/word_register_dialog.cc.orig      2021-02-15 03:48:53.000000000 +0000
++++ gui/word_register_dialog/word_register_dialog.cc
+@@ -97,9 +97,9 @@ QString GetEnv(const char *envname) {
+   }
+   return QLatin1String("");
+ #endif  // OS_WIN
+-#if defined(__APPLE__) || defined(OS_LINUX)
++#if defined(__APPLE__) || defined(OS_LINUX) || defined(OS_NETBSD)
+   return QString::fromUtf8(::getenv(envname));
+-#endif  // __APPLE__ or OS_LINUX
++#endif  // __APPLE__ or OS_LINUX or OS_NETBSD
+   // TODO(team): Support other platforms.
+   return QLatin1String("");
+ }
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-gyp_common.gypi
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-gyp_common.gypi:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-gyp_common.gypi     Sat Feb 10 01:20:47 2024
@@ -0,0 +1,68 @@
+$NetBSD: patch-gyp_common.gypi,v 1.1 2024/02/10 01:20:47 ryoon Exp $
+
+* NetBSD support
+
+--- gyp/common.gypi.orig       2021-02-15 05:04:33.000000000 +0000
++++ gyp/common.gypi
+@@ -93,6 +93,14 @@
+       '-fstack-protector',
+       '--param=ssp-buffer-size=4',
+     ],
++    # netbsd_cflags will be used for NetBSD.
++    'netbsd_cflags': [
++      '<@(gcc_cflags)',
++      '-fPIC',
++      '-D_NETBSD_SOURCE',
++      '-fno-exceptions',
++      '<!(echo $CFLAGS)',
++    ],
+     # mac_cflags will be used in Mac.
+     # Xcode 4.5 which we are currently using does not support ssp-buffer-size.
+     # TODO(horo): When we can use Xcode 4.6 which supports ssp-buffer-size,
+@@ -128,6 +136,12 @@
+         'compiler_host': 'clang',
+         'compiler_host_version_int': 304,  # Clang 3.4 or higher
+       }],
++      ['target_platform=="NetBSD"', {
++        'compiler_target': 'gcc',
++        'compiler_target_version_int': 409,  # GCC 4.9 or higher
++        'compiler_host': 'gcc',
++        'compiler_host_version_int': 409,  # GCC 4.9 or higher
++      }],
+     ],
+   },
+   'target_defaults': {
+@@ -318,6 +332,24 @@
+           }],
+         ],
+       }],
++      ['OS=="netbsd"', {
++        'defines': [
++          'OS_NETBSD',
++        ],
++        'cflags': [
++          '<@(netbsd_cflags)',
++          '-fPIC',
++          '-fno-exceptions',
++        ],
++        'cflags_cc': [
++          # We use deprecated <hash_map> and <hash_set> instead of upcoming
++          # <unordered_map> and <unordered_set>.
++          '-Wno-deprecated',
++        ],
++        'ldflags': [
++          '-pthread',
++        ],
++      }],
+       ['OS=="mac"', {
+         'defines': [
+           '__APPLE__',
+@@ -410,7 +442,7 @@
+     ],
+   },
+   'conditions': [
+-    ['target_platform=="Linux"', {
++    ['target_platform=="Linux" or target_platform=="NetBSD"', {
+       'make_global_settings': [
+         ['AR', '<!(which ar)'],
+         ['CC', '<!(which clang)'],
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-gyp_directories.gypi
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-gyp_directories.gypi:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-gyp_directories.gypi        Sat Feb 10 01:20:47 2024
@@ -0,0 +1,13 @@
+$NetBSD: patch-gyp_directories.gypi,v 1.1 2024/02/10 01:20:47 ryoon Exp $
+
+--- gyp/directories.gypi.orig  2021-02-15 05:04:33.000000000 +0000
++++ gyp/directories.gypi
+@@ -43,7 +43,7 @@
+ 
+     # server_dir represents the directory where mozc_server is
+     # installed. This option is only for Linux.
+-    'server_dir%': '/usr/lib/mozc',
++    'server_dir%': '@PREFIX@/libexec',
+ 
+     # Represents the directory where the source code of protobuf is
+     # extracted. This value is ignored when 'use_libprotobuf' is 1.
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-ipc_ipc__path__manager.cc
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-ipc_ipc__path__manager.cc:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-ipc_ipc__path__manager.cc   Sat Feb 10 01:20:47 2024
@@ -0,0 +1,42 @@
+$NetBSD: patch-ipc_ipc__path__manager.cc,v 1.1 2024/02/10 01:20:47 ryoon Exp $
+
+* NetBSD support
+
+--- ipc/ipc_path_manager.cc.orig       2021-02-15 03:48:53.000000000 +0000
++++ ipc/ipc_path_manager.cc
+@@ -53,6 +53,11 @@
+ #endif  // __APPLE__
+ #endif  // OS_WIN
+ 
++#if defined(OS_NETBSD)
++#include <sys/param.h>
++#include <sys/sysctl.h>
++#endif
++
+ #include <cstdlib>
+ #include <map>
+ #ifdef OS_WIN
+@@ -425,6 +430,23 @@ bool IPCPathManager::IsValidServer(uint3
+     return true;
+   }
+ 
++#if defined(OS_NETBSD)
++  int name[] = { CTL_KERN, KERN_PROC_ARGS, static_cast<int>(pid) };
++  size_t data_len = 0;
++  if (sysctl(name, arraysize(name), NULL,
++             &data_len, NULL, 0) < 0) {
++    LOG(ERROR) << "sysctl KERN_PROC_ARGS failed";
++    return false;
++  }
++
++  server_path_.resize(data_len);
++  if (sysctl(name, arraysize(name), &server_path_[0],
++             &data_len, NULL, 0) < 0) {
++    LOG(ERROR) << "sysctl KERN_PROC_ARGS failed";
++    return false;
++  }
++#endif // OS_NETBSD
++
+ #ifdef OS_LINUX
+   if ((server_path + " (deleted)") == server_path_) {
+     LOG(WARNING) << server_path << " on disk is modified";
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-ipc_ipc__path__manager__test.cc
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-ipc_ipc__path__manager__test.cc:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-ipc_ipc__path__manager__test.cc     Sat Feb 10 01:20:47 2024
@@ -0,0 +1,15 @@
+$NetBSD: patch-ipc_ipc__path__manager__test.cc,v 1.1 2024/02/10 01:20:47 ryoon Exp $
+
+* NetBSD support
+
+--- ipc/ipc_path_manager_test.cc.orig  2013-07-17 02:37:50.000000000 +0000
++++ ipc/ipc_path_manager_test.cc
+@@ -103,7 +103,7 @@ TEST_F(IPCPathManagerTest, IPCPathManage
+   EXPECT_FALSE(manager->GetServerProductVersion().empty());
+   EXPECT_GT(manager->GetServerProcessId(), 0);
+   EXPECT_EQ(t.path(), path);
+-#ifdef OS_LINUX
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+   // On Linux, |path| should be abstract (see man unix(7) for details.)
+   ASSERT_FALSE(path.empty());
+   EXPECT_EQ('\0', path[0]);
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-ipc_named__event.cc
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-ipc_named__event.cc:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-ipc_named__event.cc Sat Feb 10 01:20:47 2024
@@ -0,0 +1,15 @@
+$NetBSD: patch-ipc_named__event.cc,v 1.1 2024/02/10 01:20:47 ryoon Exp $
+
+* sem_open(..., 0) is not supported for NetBSD at least.
+
+--- ipc/named_event.cc.orig    2021-02-15 03:48:53.000000000 +0000
++++ ipc/named_event.cc
+@@ -325,7 +325,7 @@ int NamedEventListener::WaitEventOrProce
+ 
+ NamedEventNotifier::NamedEventNotifier(const char *name) : sem_(SEM_FAILED) {
+   const std::string key_filename = NamedEventUtil::GetEventPath(name);
+-  sem_ = ::sem_open(key_filename.c_str(), 0);
++  sem_ = ::sem_open(key_filename.c_str(), O_CREAT);
+   if (sem_ == SEM_FAILED) {
+     LOG(ERROR) << "sem_open failed: " << ::strerror(errno);
+   }
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-ipc_unix__ipc.cc
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-ipc_unix__ipc.cc:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-ipc_unix__ipc.cc    Sat Feb 10 01:20:47 2024
@@ -0,0 +1,55 @@
+$NetBSD: patch-ipc_unix__ipc.cc,v 1.1 2024/02/10 01:20:47 ryoon Exp $
+
+* NetBSD support
+
+--- ipc/unix_ipc.cc.orig       2021-02-15 03:48:53.000000000 +0000
++++ ipc/unix_ipc.cc
+@@ -28,7 +28,7 @@
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ 
+ // OS_LINUX only. Note that OS_ANDROID/OS_WASM don't reach here.
+-#if defined(OS_LINUX)
++#if defined(OS_LINUX) || defined(OS_NETBSD)
+ 
+ #include <arpa/inet.h>
+ #include <fcntl.h>
+@@ -125,7 +125,7 @@ bool IsPeerValid(int socket, pid_t *pid)
+   // sometimes doesn't support the getsockopt(sock, SOL_SOCKET, SO_PEERCRED)
+   // system call.
+   // TODO(yusukes): Add implementation for ARM Linux.
+-#ifndef __arm__
++#if !defined(__arm__) && !defined(OS_NETBSD)
+   struct ucred peer_cred;
+   int peer_cred_len = sizeof(peer_cred);
+   if (getsockopt(socket, SOL_SOCKET, SO_PEERCRED,
+@@ -141,7 +141,23 @@ bool IsPeerValid(int socket, pid_t *pid)
+   }
+ 
+   *pid = peer_cred.pid;
+-#endif  // __arm__
++#endif  // __arm__ || OS_NETBSD
++
++#if defined(OS_NETBSD)
++  struct unpcbid peer_cred;
++  int peer_cred_len = sizeof(peer_cred);
++  if (getsockopt(socket, 0, LOCAL_PEEREID,
++                 reinterpret_cast<void *>(&peer_cred),
++                 reinterpret_cast<socklen_t *>(&peer_cred_len)) < 0) {
++    LOG(ERROR) << "cannot get peer credential. Not a Unix socket?";
++    return false;
++  }
++
++  if (peer_cred.unp_euid!= ::geteuid()) {
++    LOG(WARNING) << "uid mismatch." << peer_cred.unp_euid << "!=" << ::geteuid();
++    return false;
++  }
++#endif
+ 
+   return true;
+ }
+@@ -468,4 +484,4 @@ void IPCServer::Terminate() { server_thr
+ 
+ }  // namespace mozc
+ 
+-#endif  // OS_LINUX
++#endif  // OS_LINUX || OS_NETBSD
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-protobuf_protobuf.gyp
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-protobuf_protobuf.gyp:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-protobuf_protobuf.gyp       Sat Feb 10 01:20:47 2024
@@ -0,0 +1,17 @@
+$NetBSD: patch-protobuf_protobuf.gyp,v 1.1 2024/02/10 01:20:47 ryoon Exp $
+
+* Pass LDFLAGS from pkgsrc.
+  Fix -lprotobuf is not found error.
+
+--- protobuf/protobuf.gyp.orig 2021-02-15 05:04:33.000000000 +0000
++++ protobuf/protobuf.gyp
+@@ -156,6 +156,9 @@
+             'libraries': [
+               '-lprotobuf',
+             ],
++            'ldflags': [
++              '<!(echo $LDFLAGS)',
++            ],
+           },
+         },
+         {  # else
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-renderer_renderer.gyp
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-renderer_renderer.gyp:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-renderer_renderer.gyp       Sat Feb 10 01:20:47 2024
@@ -0,0 +1,24 @@
+$NetBSD: patch-renderer_renderer.gyp,v 1.1 2024/02/10 01:20:47 ryoon Exp $
+
+* Support NetBSD.
+
+--- renderer/renderer.gyp.orig 2021-02-15 05:04:33.000000000 +0000
++++ renderer/renderer.gyp
+@@ -193,7 +193,7 @@
+             'win32_renderer_core_test',
+           ],
+         }],
+-        ['target_platform=="Linux" and enable_gtk_renderer==1', {
++        ['(target_platform=="Linux" or target_platform=="NetBSD") and enable_gtk_renderer==1', {
+           'dependencies': [
+             'gtk_renderer_test',
+           ],
+@@ -518,7 +518,7 @@
+         },
+       ],
+     }],
+-    ['target_platform=="Linux" and enable_gtk_renderer==1', {
++    ['(target_platform=="Linux" or target_platform=="NetBSD") and enable_gtk_renderer==1', {
+       'targets': [
+         {
+           # Meta target to set up build environment for gtk+-2.0.
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-session_session.cc
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-session_session.cc:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-session_session.cc  Sat Feb 10 01:20:47 2024
@@ -0,0 +1,36 @@
+$NetBSD: patch-session_session.cc,v 1.1 2024/02/10 01:20:47 ryoon Exp $
+
+* NetBSD support
+
+--- session/session.cc.orig    2021-02-15 03:48:53.000000000 +0000
++++ session/session.cc
+@@ -230,9 +230,9 @@ void Session::InitContext(ImeContext *co
+   context->SetConfig(&context->GetConfig());
+ 
+ #if defined(OS_ANDROID) || defined(OS_IOS) || defined(OS_LINUX) || \
+-    defined(OS_WASM)
++    defined(OS_WASM) || defined(OS_NETBSD)
+   context->mutable_converter()->set_use_cascading_window(false);
+-#endif  // OS_ANDROID || OS_IOS || OS_LINUX || OS_WASM
++#endif  // OS_ANDROID || OS_IOS || OS_LINUX || OS_WASM || OS_NETBSD
+ }
+ 
+ void Session::PushUndoContext() {
+@@ -964,14 +964,14 @@ void Session::UpdatePreferences(commands
+   }
+ 
+ #if defined(OS_ANDROID) || defined(OS_IOS) || defined(OS_LINUX) || \
+-    defined(OS_WASM)
++    defined(OS_WASM) || defined(OS_NETBSD)
+   context_->mutable_converter()->set_use_cascading_window(false);
+-#else   // OS_LINUX || OS_ANDROID || OS_WASM
++#else   // OS_LINUX || OS_ANDROID || OS_WASM || OS_NETBSD
+   if (config.has_use_cascading_window()) {
+     context_->mutable_converter()->set_use_cascading_window(
+         config.use_cascading_window());
+   }
+-#endif  // OS_ANDROID || OS_IOS || OS_LINUX || OS_WASM
++#endif  // OS_ANDROID || OS_IOS || OS_LINUX || OS_WASM || OS_NETBSD
+ }
+ 
+ bool Session::IMEOn(commands::Command *command) {
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-session_session__test.cc
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-session_session__test.cc:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-session_session__test.cc    Sat Feb 10 01:20:47 2024
@@ -0,0 +1,71 @@
+$NetBSD: patch-session_session__test.cc,v 1.1 2024/02/10 01:20:47 ryoon Exp $
+
+* NetBSD support
+
+--- session/session_test.cc.orig       2021-02-15 03:48:53.000000000 +0000
++++ session/session_test.cc
+@@ -1974,11 +1974,11 @@ TEST_F(SessionTest, UpdatePreferences) {
+   const size_t cascading_cand_size =
+       command.output().candidates().candidate_size();
+ 
+-#if defined(OS_LINUX) || defined(OS_ANDROID) || OS_WASM
++#if defined(OS_LINUX) || defined(OS_ANDROID) || OS_WASM || defined(OS_NETBSD)
+   EXPECT_EQ(no_cascading_cand_size, cascading_cand_size);
+-#else   // defined(OS_LINUX) || defined(OS_ANDROID) || OS_WASM
++#else   // defined(OS_LINUX) || defined(OS_ANDROID) || OS_WASM || defined(OS_NETBSD)
+   EXPECT_GT(no_cascading_cand_size, cascading_cand_size);
+-#endif  // defined(OS_LINUX) || defined(OS_ANDROID) || OS_WASM
++#endif  // defined(OS_LINUX) || defined(OS_ANDROID) || OS_WASM || defined(OS_NETBSD)
+ 
+   command.Clear();
+   session->ConvertCancel(&command);
+@@ -2149,7 +2149,7 @@ TEST_F(SessionTest, OutputAllCandidateWo
+ 
+     EXPECT_EQ(0, output.all_candidate_words().focused_index());
+     EXPECT_EQ(commands::CONVERSION, output.all_candidate_words().category());
+-#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM)
++#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM) || defined(OS_NETBSD)
+     // Cascading window is not supported on Linux, so the size of
+     // candidate words is different from other platform.
+     // TODO(komatsu): Modify the client for Linux to explicitly change
+@@ -2159,13 +2159,13 @@ TEST_F(SessionTest, OutputAllCandidateWo
+     //   "aiueo"  (t13n), "AIUEO" (t13n), "Aieuo" (t13n),
+     //   "アイウエオ" (t13n) ]
+     EXPECT_EQ(9, output.all_candidate_words().candidates_size());
+-#else   // OS_LINUX || OS_ANDROID || OS_WASM
++#else   // OS_LINUX || OS_ANDROID || OS_WASM || OS_NETBSD
+     // [ "あいうえお", "アイウエオ", "アイウエオ" (t13n), "あいうえお" (t13n),
+     //   "aiueo" (t13n), "AIUEO" (t13n), "Aieuo" (t13n),
+     //   "aiueo"  (t13n), "AIUEO" (t13n), "Aieuo" (t13n),
+     //   "アイウエオ" (t13n) ]
+     EXPECT_EQ(11, output.all_candidate_words().candidates_size());
+-#endif  // OS_LINUX || OS_ANDROID || OS_WASM
++#endif  // OS_LINUX || OS_ANDROID || OS_WASM || OS_NETBSD
+   }
+ 
+   command.Clear();
+@@ -2177,7 +2177,7 @@ TEST_F(SessionTest, OutputAllCandidateWo
+ 
+     EXPECT_EQ(1, output.all_candidate_words().focused_index());
+     EXPECT_EQ(commands::CONVERSION, output.all_candidate_words().category());
+-#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM)
++#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM) || defined(OS_NETBSD)
+     // Cascading window is not supported on Linux, so the size of
+     // candidate words is different from other platform.
+     // TODO(komatsu): Modify the client for Linux to explicitly change
+@@ -2187,13 +2187,13 @@ TEST_F(SessionTest, OutputAllCandidateWo
+     //   "aiueo"  (t13n), "AIUEO" (t13n), "Aieuo" (t13n),
+     //   "アイウエオ" (t13n) ]
+     EXPECT_EQ(9, output.all_candidate_words().candidates_size());
+-#else   // OS_LINUX || OS_ANDROID || OS_WASM
++#else   // OS_LINUX || OS_ANDROID || OS_WASM || OS_NETBSD
+     // [ "あいうえお", "アイウエオ",
+     //   "aiueo" (t13n), "AIUEO" (t13n), "Aieuo" (t13n),
+     //   "aiueo"  (t13n), "AIUEO" (t13n), "Aieuo" (t13n),
+     //   "アイウエオ" (t13n) ]
+     EXPECT_EQ(11, output.all_candidate_words().candidates_size());
+-#endif  // OS_LINUX || OS_ANDROID || OS_WASM
++#endif  // OS_LINUX || OS_ANDROID || OS_WASM || OS_NETBSD
+   }
+ }
+ 
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-third__party_abseil-cpp_absl_base_config.h
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-third__party_abseil-cpp_absl_base_config.h:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-third__party_abseil-cpp_absl_base_config.h  Sat Feb 10 01:20:47 2024
@@ -0,0 +1,15 @@
+$NetBSD: patch-third__party_abseil-cpp_absl_base_config.h,v 1.1 2024/02/10 01:20:47 ryoon Exp $
+
+* Support NetBSD.
+
+--- third_party/abseil-cpp/absl/base/config.h.orig     2021-02-15 05:04:34.000000000 +0000
++++ third_party/abseil-cpp/absl/base/config.h
+@@ -364,7 +364,7 @@ static_assert(ABSL_INTERNAL_INLINE_NAMES
+ #elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) ||   \
+     defined(__ros__) || defined(__native_client__) || defined(__asmjs__) || \
+     defined(__wasm__) || defined(__Fuchsia__) || defined(__sun) || \
+-    defined(__ASYLO__)
++    defined(__ASYLO__) || defined(__NetBSD__)
+ #define ABSL_HAVE_MMAP 1
+ #endif
+ 
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-third__party_protobuf_post__process__dist.sh
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-third__party_protobuf_post__process__dist.sh:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-third__party_protobuf_post__process__dist.sh        Sat Feb 10 01:20:47 2024
@@ -0,0 +1,15 @@
+$NetBSD: patch-third__party_protobuf_post__process__dist.sh,v 1.1 2024/02/10 01:20:47 ryoon Exp $
+
+* appease pkglint
+
+--- third_party/protobuf/post_process_dist.sh.orig     2017-11-02 13:35:43.000000000 +0000
++++ third_party/protobuf/post_process_dist.sh
+@@ -15,7 +15,7 @@
+ #    non-testdata .txt files are converted to Windows-style line endings.
+ # 5) Cleans up after itself.
+ 
+-if [ "$1" == "" ]; then
++if [ "$1" = "" ]; then
+   echo "USAGE:  $0 DISTFILE" >&2
+   exit 1
+ fi
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-uim-mozc
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-uim-mozc:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-uim-mozc    Sat Feb 10 01:20:47 2024
@@ -0,0 +1,2974 @@
+$NetBSD: patch-uim-mozc,v 1.1 2024/02/10 01:20:47 ryoon Exp $
+
+* From Debian sid.
+
+From 0758147463701aa40bc622c9b93c177f2cc5b3e3 Mon Sep 17 00:00:00 2001
+From: Nobuhiro Iwamatsu <iwamatsu%debian.org@localhost>
+Date: Tue, 3 Apr 2018 08:27:47 +0900
+Subject: [PATCH ] Update uim-mozc to
+ c979f127acaeb7b35d3344e8b1e40848e1a68d54
+
+Description: Support uim framewor
+Origin: macuim project: https://github.com/e-kato/macuim.git c979f127acaeb7b35d3344e8b1e40848e1a68d54
+Forwarded: http://code.google.com/p/mozc/issues/detail?id=13
+Author: uim Project http://code.google.com/p/uim/
+Last-Update: 2020-12-28
+
+* Fix mozc::InitMozc
+* Use Utf8SubString instead of SubString
+
+Signed-off-by: Nobuhiro Iwamatsu <iwamatsu%debian.org@localhost>
+---
+ src/unix/uim/key_translator.cc       |  441 ++++++++++
+ src/unix/uim/key_translator.h        |  111 +++
+ src/unix/uim/mozc.cc                 | 1219 ++++++++++++++++++++++++++
+ src/unix/uim/scm/mozc-custom.scm     |  396 +++++++++
+ src/unix/uim/scm/mozc-key-custom.scm |   74 ++
+ src/unix/uim/scm/mozc.scm            |  566 ++++++++++++
+ src/unix/uim/uim.gyp                 |   85 ++
+ 7 files changed, 2892 insertions(+)
+ create mode 100644 src/unix/uim/key_translator.cc
+ create mode 100644 src/unix/uim/key_translator.h
+ create mode 100644 src/unix/uim/mozc.cc
+ create mode 100644 src/unix/uim/scm/mozc-custom.scm
+ create mode 100644 src/unix/uim/scm/mozc-key-custom.scm
+ create mode 100644 src/unix/uim/scm/mozc.scm
+ create mode 100644 src/unix/uim/uim.gyp
+
+diff --git a/src/unix/uim/key_translator.cc b/src/unix/uim/key_translator.cc
+new file mode 100644
+index 00000000..b1c9be85
+--- /dev/null
++++ unix/uim/key_translator.cc
+@@ -0,0 +1,441 @@
++// Copyright 2010, Google Inc.
++// Copyright (c) 2010-2012 uim Project http://code.google.com/p/uim/
++// All rights reserved.
++//
++// Redistribution and use in source and binary forms, with or without
++// modification, are permitted provided that the following conditions are
++// met:
++//
++//     * Redistributions of source code must retain the above copyright
++// notice, this list of conditions and the following disclaimer.
++//     * Redistributions in binary form must reproduce the above
++// copyright notice, this list of conditions and the following disclaimer
++// in the documentation and/or other materials provided with the
++// distribution.
++//     * Neither the name of authors nor the names of its
++// contributors may be used to endorse or promote products derived from
++// this software without specific prior written permission.
++//
++// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++
++#include "unix/uim/key_translator.h"
++
++#include <uim.h>
++
++#include "base/logging.h"
++
++namespace {
++
++const struct SpecialKeyMap {
++  unsigned int from;
++  mozc::commands::KeyEvent::SpecialKey to;
++} special_key_map[] = {
++  {0x20, mozc::commands::KeyEvent::SPACE},
++  {UKey_Return, mozc::commands::KeyEvent::ENTER},
++  {UKey_Left, mozc::commands::KeyEvent::LEFT},
++  {UKey_Right, mozc::commands::KeyEvent::RIGHT},
++  {UKey_Up, mozc::commands::KeyEvent::UP},
++  {UKey_Down, mozc::commands::KeyEvent::DOWN},
++  {UKey_Escape, mozc::commands::KeyEvent::ESCAPE},
++  {UKey_Delete, mozc::commands::KeyEvent::DEL},
++  {UKey_Backspace, mozc::commands::KeyEvent::BACKSPACE},
++  {UKey_Insert, mozc::commands::KeyEvent::INSERT},
++  {UKey_Henkan, mozc::commands::KeyEvent::HENKAN},
++  {UKey_Muhenkan, mozc::commands::KeyEvent::MUHENKAN},
++  {UKey_Hiragana, mozc::commands::KeyEvent::KANA},
++  {UKey_Katakana, mozc::commands::KeyEvent::KANA},
++  {UKey_Eisu_toggle, mozc::commands::KeyEvent::EISU},
++  {UKey_Home, mozc::commands::KeyEvent::HOME},
++  {UKey_End, mozc::commands::KeyEvent::END},
++  {UKey_Tab, mozc::commands::KeyEvent::TAB},
++  {UKey_F1, mozc::commands::KeyEvent::F1},
++  {UKey_F2, mozc::commands::KeyEvent::F2},
++  {UKey_F3, mozc::commands::KeyEvent::F3},
++  {UKey_F4, mozc::commands::KeyEvent::F4},
++  {UKey_F5, mozc::commands::KeyEvent::F5},
++  {UKey_F6, mozc::commands::KeyEvent::F6},
++  {UKey_F7, mozc::commands::KeyEvent::F7},
++  {UKey_F8, mozc::commands::KeyEvent::F8},
++  {UKey_F9, mozc::commands::KeyEvent::F9},
++  {UKey_F10, mozc::commands::KeyEvent::F10},
++  {UKey_F11, mozc::commands::KeyEvent::F11},
++  {UKey_F12, mozc::commands::KeyEvent::F12},
++  {UKey_F13, mozc::commands::KeyEvent::F13},
++  {UKey_F14, mozc::commands::KeyEvent::F14},
++  {UKey_F15, mozc::commands::KeyEvent::F15},
++  {UKey_F16, mozc::commands::KeyEvent::F16},
++  {UKey_F17, mozc::commands::KeyEvent::F17},
++  {UKey_F18, mozc::commands::KeyEvent::F18},
++  {UKey_F19, mozc::commands::KeyEvent::F19},
++  {UKey_F20, mozc::commands::KeyEvent::F20},
++  {UKey_F21, mozc::commands::KeyEvent::F21},
++  {UKey_F22, mozc::commands::KeyEvent::F22},
++  {UKey_F23, mozc::commands::KeyEvent::F23},
++  {UKey_F24, mozc::commands::KeyEvent::F24},
++  {UKey_Prior, mozc::commands::KeyEvent::PAGE_UP},
++  {UKey_Next, mozc::commands::KeyEvent::PAGE_DOWN},
++};
++
++const struct ModifierKeyMap {
++  unsigned int from;
++  mozc::commands::KeyEvent::ModifierKey to;
++} modifier_key_map[] = {
++  {UKey_Shift, mozc::commands::KeyEvent::SHIFT},
++  {UKey_Control, mozc::commands::KeyEvent::CTRL},
++  {UKey_Alt, mozc::commands::KeyEvent::ALT},
++};
++
++const struct ModifierMaskMap {
++  unsigned int from;
++  mozc::commands::KeyEvent::ModifierKey to;
++} modifier_mask_map[] = {
++  {UMod_Shift, mozc::commands::KeyEvent::SHIFT},
++  {UMod_Control, mozc::commands::KeyEvent::CTRL},
++  {UMod_Alt, mozc::commands::KeyEvent::ALT},
++};
++
++// TODO:Add kana_map_dv to support Dvoraklayout.
++const struct KanaMap {
++  unsigned int code;
++  const char *no_shift;
++  const char *shift;
++} kana_map_jp[] = {
++  { '1' , "\xe3\x81\xac", "\xe3\x81\xac" },  // "ぬ", "ぬ"
++  { '!' , "\xe3\x81\xac", "\xe3\x81\xac" },  // "ぬ", "ぬ"
++  { '2' , "\xe3\x81\xb5", "\xe3\x81\xb5" },  // "ふ", "ふ"
++  { '\"', "\xe3\x81\xb5", "\xe3\x81\xb5" },  // "ふ", "ふ"
++  { '3' , "\xe3\x81\x82", "\xe3\x81\x81" },  // "あ", "ぁ"
++  { '#' , "\xe3\x81\x81", "\xe3\x81\x81" },  // "ぁ", "ぁ"
++  { '4' , "\xe3\x81\x86", "\xe3\x81\x85" },  // "う", "ぅ"
++  { '$' , "\xe3\x81\x85", "\xe3\x81\x85" },  // "ぅ", "ぅ"
++  { '5' , "\xe3\x81\x88", "\xe3\x81\x87" },  // "え", "ぇ"
++  { '%' , "\xe3\x81\x87", "\xe3\x81\x87" },  // "ぇ", "ぇ"
++  { '6' , "\xe3\x81\x8a", "\xe3\x81\x89" },  // "お", "ぉ"
++  { '&' , "\xe3\x81\x89", "\xe3\x81\x89" },  // "ぉ", "ぉ"
++  { '7' , "\xe3\x82\x84", "\xe3\x82\x83" },  // "や", "ゃ"
++  { '\'', "\xe3\x82\x83", "\xe3\x82\x83" },  // "ゃ", "ゃ"
++  { '8' , "\xe3\x82\x86", "\xe3\x82\x85" },  // "ゆ", "ゅ"
++  { '(' , "\xe3\x82\x85", "\xe3\x82\x85" },  // "ゅ", "ゅ"
++  { '9' , "\xe3\x82\x88", "\xe3\x82\x87" },  // "よ", "ょ"
++  { ')' , "\xe3\x82\x87", "\xe3\x82\x87" },  // "ょ", "ょ"
++  { '0' , "\xe3\x82\x8f", "\xe3\x82\x92" },  // "わ", "を"
++  { '-' , "\xe3\x81\xbb", "\xe3\x81\xbb" },  // "ほ", "ほ"
++  { '=' , "\xe3\x81\xbb", "\xe3\x81\xbb" },  // "ほ", "ほ"
++  { '^' , "\xe3\x81\xb8", "\xe3\x81\xb8" },  // "へ", "へ"
++  { '~' , "\xe3\x82\x92", "\xe3\x82\x92" },  // "を", "を"
++  { '|' , "\xe3\x83\xbc", "\xe3\x83\xbc" },  // "ー", "ー"
++  { 'q' , "\xe3\x81\x9f", "\xe3\x81\x9f" },  // "た", "た"
++  { 'Q' , "\xe3\x81\x9f", "\xe3\x81\x9f" },  // "た", "た"
++  { 'w' , "\xe3\x81\xa6", "\xe3\x81\xa6" },  // "て", "て"
++  { 'W' , "\xe3\x81\xa6", "\xe3\x81\xa6" },  // "て", "て"
++  { 'e' , "\xe3\x81\x84", "\xe3\x81\x83" },  // "い", "ぃ"
++  { 'E' , "\xe3\x81\x83", "\xe3\x81\x83" },  // "ぃ", "ぃ"
++  { 'r' , "\xe3\x81\x99", "\xe3\x81\x99" },  // "す", "す"
++  { 'R' , "\xe3\x81\x99", "\xe3\x81\x99" },  // "す", "す"
++  { 't' , "\xe3\x81\x8b", "\xe3\x81\x8b" },  // "か", "か"
++  { 'T' , "\xe3\x81\x8b", "\xe3\x81\x8b" },  // "か", "か"
++  { 'y' , "\xe3\x82\x93", "\xe3\x82\x93" },  // "ん", "ん"
++  { 'Y' , "\xe3\x82\x93", "\xe3\x82\x93" },  // "ん", "ん"
++  { 'u' , "\xe3\x81\xaa", "\xe3\x81\xaa" },  // "な", "な"
++  { 'U' , "\xe3\x81\xaa", "\xe3\x81\xaa" },  // "な", "な"
++  { 'i' , "\xe3\x81\xab", "\xe3\x81\xab" },  // "に", "に"
++  { 'I' , "\xe3\x81\xab", "\xe3\x81\xab" },  // "に", "に"
++  { 'o' , "\xe3\x82\x89", "\xe3\x82\x89" },  // "ら", "ら"
++  { 'O' , "\xe3\x82\x89", "\xe3\x82\x89" },  // "ら", "ら"
++  { 'p' , "\xe3\x81\x9b", "\xe3\x81\x9b" },  // "せ", "せ"
++  { 'P' , "\xe3\x81\x9b", "\xe3\x81\x9b" },  // "せ", "せ"
++  { '@' , "\xe3\x82\x9b", "\xe3\x82\x9b" },  // "゛", "゛"
++  { '`' , "\xe3\x82\x9b", "\xe3\x82\x9b" },  // "゛", "゛"
++  { '[' , "\xe3\x82\x9c", "\xe3\x80\x8c" },  // "゜", "「"
++  { '{' , "\xe3\x82\x9c", "\xe3\x80\x8c" },  // "゜", "「"
++  { 'a' , "\xe3\x81\xa1", "\xe3\x81\xa1" },  // "ち", "ち"
++  { 'A' , "\xe3\x81\xa1", "\xe3\x81\xa1" },  // "ち", "ち"
++  { 's' , "\xe3\x81\xa8", "\xe3\x81\xa8" },  // "と", "と"
++  { 'S' , "\xe3\x81\xa8", "\xe3\x81\xa8" },  // "と", "と"
++  { 'd' , "\xe3\x81\x97", "\xe3\x81\x97" },  // "し", "し"
++  { 'D' , "\xe3\x81\x97", "\xe3\x81\x97" },  // "し", "し"
++  { 'f' , "\xe3\x81\xaf", "\xe3\x81\xaf" },  // "は", "は"
++  { 'F' , "\xe3\x81\xaf", "\xe3\x81\xaf" },  // "は", "は"
++  { 'g' , "\xe3\x81\x8d", "\xe3\x81\x8d" },  // "き", "き"
++  { 'G' , "\xe3\x81\x8d", "\xe3\x81\x8d" },  // "き", "き"
++  { 'h' , "\xe3\x81\x8f", "\xe3\x81\x8f" },  // "く", "く"
++  { 'H' , "\xe3\x81\x8f", "\xe3\x81\x8f" },  // "く", "く"
++  { 'j' , "\xe3\x81\xbe", "\xe3\x81\xbe" },  // "ま", "ま"
++  { 'J' , "\xe3\x81\xbe", "\xe3\x81\xbe" },  // "ま", "ま"
++  { 'k' , "\xe3\x81\xae", "\xe3\x81\xae" },  // "の", "の"
++  { 'K' , "\xe3\x81\xae", "\xe3\x81\xae" },  // "の", "の"
++  { 'l' , "\xe3\x82\x8a", "\xe3\x82\x8a" },  // "り", "り"
++  { 'L' , "\xe3\x82\x8a", "\xe3\x82\x8a" },  // "り", "り"
++  { ';' , "\xe3\x82\x8c", "\xe3\x82\x8c" },  // "れ", "れ"
++  { '+' , "\xe3\x82\x8c", "\xe3\x82\x8c" },  // "れ", "れ"
++  { ':' , "\xe3\x81\x91", "\xe3\x81\x91" },  // "け", "け"
++  { '*' , "\xe3\x81\x91", "\xe3\x81\x91" },  // "け", "け"
++  { ']' , "\xe3\x82\x80", "\xe3\x80\x8d" },  // "む", "」"
++  { '}' , "\xe3\x80\x8d", "\xe3\x80\x8d" },  // "」", "」"
++  { 'z' , "\xe3\x81\xa4", "\xe3\x81\xa3" },  // "つ", "っ"
++  { 'Z' , "\xe3\x81\xa3", "\xe3\x81\xa3" },  // "っ", "っ"
++  { 'x' , "\xe3\x81\x95", "\xe3\x81\x95" },  // "さ", "さ"
++  { 'X' , "\xe3\x81\x95", "\xe3\x81\x95" },  // "さ", "さ"
++  { 'c' , "\xe3\x81\x9d", "\xe3\x81\x9d" },  // "そ", "そ"
++  { 'C' , "\xe3\x81\x9d", "\xe3\x81\x9d" },  // "そ", "そ"
++  { 'v' , "\xe3\x81\xb2", "\xe3\x81\xb2" },  // "ひ", "ひ"
++  { 'V' , "\xe3\x81\xb2", "\xe3\x81\xb2" },  // "ひ", "ひ"
++  { 'b' , "\xe3\x81\x93", "\xe3\x81\x93" },  // "こ", "こ"
++  { 'B' , "\xe3\x81\x93", "\xe3\x81\x93" },  // "こ", "こ"
++  { 'n' , "\xe3\x81\xbf", "\xe3\x81\xbf" },  // "み", "み"
++  { 'N' , "\xe3\x81\xbf", "\xe3\x81\xbf" },  // "み", "み"
++  { 'm' , "\xe3\x82\x82", "\xe3\x82\x82" },  // "も", "も"
++  { 'M' , "\xe3\x82\x82", "\xe3\x82\x82" },  // "も", "も"
++  { ',' , "\xe3\x81\xad", "\xe3\x80\x81" },  // "ね", "、"
++  { '<' , "\xe3\x80\x81", "\xe3\x80\x81" },  // "、", "、"
++  { '.' , "\xe3\x82\x8b", "\xe3\x80\x82" },  // "る", "。"
++  { '>' , "\xe3\x80\x82", "\xe3\x80\x82" },  // "。", "。"
++  { '/' , "\xe3\x82\x81", "\xe3\x83\xbb" },  // "め", "・"
++  { '?' , "\xe3\x83\xbb", "\xe3\x83\xbb" },  // "・", "・"
++  { '_' , "\xe3\x82\x8d", "\xe3\x82\x8d" },  // "ろ", "ろ"
++  // uim distinguishes backslash key and yen key
++  { '\\', "\xe3\x82\x8d", "\xe3\x82\x8d" },  // "ろ", "ろ"
++  { UKey_Yen, "\xe3\x83\xbc", "\xe3\x83\xbc" }, // "ー", "ー"
++}, kana_map_us[] = {
++  { '`' , "\xe3\x82\x8d", "\xe3\x82\x8d" },  // "ろ", "ろ"
++  { '~' , "\xe3\x82\x8d", "\xe3\x82\x8d" },  // "ろ", "ろ"
++  { '1' , "\xe3\x81\xac", "\xe3\x81\xac" },  // "ぬ", "ぬ"
++  { '!' , "\xe3\x81\xac", "\xe3\x81\xac" },  // "ぬ", "ぬ"
++  { '2' , "\xe3\x81\xb5", "\xe3\x81\xb5" },  // "ふ", "ふ"
++  { '@' , "\xe3\x81\xb5", "\xe3\x81\xb5" },  // "ふ", "ふ"
++  { '3' , "\xe3\x81\x82", "\xe3\x81\x81" },  // "あ", "ぁ"
++  { '#' , "\xe3\x81\x81", "\xe3\x81\x81" },  // "ぁ", "ぁ"
++  { '4' , "\xe3\x81\x86", "\xe3\x81\x85" },  // "う", "ぅ"
++  { '$' , "\xe3\x81\x85", "\xe3\x81\x85" },  // "ぅ", "ぅ"
++  { '5' , "\xe3\x81\x88", "\xe3\x81\x87" },  // "え", "ぇ"
++  { '%' , "\xe3\x81\x87", "\xe3\x81\x87" },  // "ぇ", "ぇ"
++  { '6' , "\xe3\x81\x8a", "\xe3\x81\x89" },  // "お", "ぉ"
++  { '^' , "\xe3\x81\x89", "\xe3\x81\x89" },  // "ぉ", "ぉ"
++  { '7' , "\xe3\x82\x84", "\xe3\x82\x83" },  // "や", "ゃ"
++  { '&' , "\xe3\x82\x83", "\xe3\x82\x83" },  // "ゃ", "ゃ"
++  { '8' , "\xe3\x82\x86", "\xe3\x82\x85" },  // "ゆ", "ゅ"
++  { '*' , "\xe3\x82\x85", "\xe3\x82\x85" },  // "ゅ", "ゅ"
++  { '9' , "\xe3\x82\x88", "\xe3\x82\x87" },  // "よ", "ょ"
++  { '(' , "\xe3\x82\x87", "\xe3\x82\x87" },  // "ょ", "ょ"
++  { '0' , "\xe3\x82\x8f", "\xe3\x82\x92" },  // "わ", "を"
++  { ')' , "\xe3\x82\x92", "\xe3\x82\x92" },  // "を", "を"
++  { '-' , "\xe3\x81\xbb", "\xe3\x83\xbc" },  // "ほ", "ー"
++  { '_' , "\xe3\x83\xbc", "\xe3\x83\xbc" },  // "ー", "ー"
++  { '=' , "\xe3\x81\xb8", "\xe3\x81\xb8" },  // "へ", "へ"
++  { '+' , "\xe3\x81\xb8", "\xe3\x81\xb8" },  // "へ", "へ"
++  { 'q' , "\xe3\x81\x9f", "\xe3\x81\x9f" },  // "た", "た"
++  { 'Q' , "\xe3\x81\x9f", "\xe3\x81\x9f" },  // "た", "た"
++  { 'w' , "\xe3\x81\xa6", "\xe3\x81\xa6" },  // "て", "て"
++  { 'W' , "\xe3\x81\xa6", "\xe3\x81\xa6" },  // "て", "て"
++  { 'e' , "\xe3\x81\x84", "\xe3\x81\x83" },  // "い", "ぃ"
++  { 'E' , "\xe3\x81\x83", "\xe3\x81\x83" },  // "ぃ", "ぃ"
++  { 'r' , "\xe3\x81\x99", "\xe3\x81\x99" },  // "す", "す"
++  { 'R' , "\xe3\x81\x99", "\xe3\x81\x99" },  // "す", "す"
++  { 't' , "\xe3\x81\x8b", "\xe3\x81\x8b" },  // "か", "か"
++  { 'T' , "\xe3\x81\x8b", "\xe3\x81\x8b" },  // "か", "か"
++  { 'y' , "\xe3\x82\x93", "\xe3\x82\x93" },  // "ん", "ん"
++  { 'Y' , "\xe3\x82\x93", "\xe3\x82\x93" },  // "ん", "ん"
++  { 'u' , "\xe3\x81\xaa", "\xe3\x81\xaa" },  // "な", "な"
++  { 'U' , "\xe3\x81\xaa", "\xe3\x81\xaa" },  // "な", "な"
++  { 'i' , "\xe3\x81\xab", "\xe3\x81\xab" },  // "に", "に"
++  { 'I' , "\xe3\x81\xab", "\xe3\x81\xab" },  // "に", "に"
++  { 'o' , "\xe3\x82\x89", "\xe3\x82\x89" },  // "ら", "ら"
++  { 'O' , "\xe3\x82\x89", "\xe3\x82\x89" },  // "ら", "ら"
++  { 'p' , "\xe3\x81\x9b", "\xe3\x81\x9b" },  // "せ", "せ"
++  { 'P' , "\xe3\x81\x9b", "\xe3\x81\x9b" },  // "せ", "せ"
++  { '[' , "\xe3\x82\x9b", "\xe3\x82\x9b" },  // "゛", "゛"
++  { '{' , "\xe3\x82\x9b", "\xe3\x82\x9b" },  // "゛", "゛"
++  { ']' , "\xe3\x82\x9c", "\xe3\x80\x8c" },  // "゜", "「"
++  { '}' , "\xe3\x80\x8c", "\xe3\x80\x8c" },  // "「", "「"
++  { '\\', "\xe3\x82\x80", "\xe3\x80\x8d" },  // "む", "」"
++  { '|' , "\xe3\x80\x8d", "\xe3\x80\x8d" },  // "」", "」"
++  { 'a' , "\xe3\x81\xa1", "\xe3\x81\xa1" },  // "ち", "ち"
++  { 'A' , "\xe3\x81\xa1", "\xe3\x81\xa1" },  // "ち", "ち"
++  { 's' , "\xe3\x81\xa8", "\xe3\x81\xa8" },  // "と", "と"
++  { 'S' , "\xe3\x81\xa8", "\xe3\x81\xa8" },  // "と", "と"
++  { 'd' , "\xe3\x81\x97", "\xe3\x81\x97" },  // "し", "し"
++  { 'D' , "\xe3\x81\x97", "\xe3\x81\x97" },  // "し", "し"
++  { 'f' , "\xe3\x81\xaf", "\xe3\x81\xaf" },  // "は", "は"
++  { 'F' , "\xe3\x81\xaf", "\xe3\x81\xaf" },  // "は", "は"
++  { 'g' , "\xe3\x81\x8d", "\xe3\x81\x8d" },  // "き", "き"
++  { 'G' , "\xe3\x81\x8d", "\xe3\x81\x8d" },  // "き", "き"
++  { 'h' , "\xe3\x81\x8f", "\xe3\x81\x8f" },  // "く", "く"
++  { 'H' , "\xe3\x81\x8f", "\xe3\x81\x8f" },  // "く", "く"
++  { 'j' , "\xe3\x81\xbe", "\xe3\x81\xbe" },  // "ま", "ま"
++  { 'J' , "\xe3\x81\xbe", "\xe3\x81\xbe" },  // "ま", "ま"
++  { 'k' , "\xe3\x81\xae", "\xe3\x81\xae" },  // "の", "の"
++  { 'K' , "\xe3\x81\xae", "\xe3\x81\xae" },  // "の", "の"
++  { 'l' , "\xe3\x82\x8a", "\xe3\x82\x8a" },  // "り", "り"
++  { 'L' , "\xe3\x82\x8a", "\xe3\x82\x8a" },  // "り", "り"
++  { ';' , "\xe3\x82\x8c", "\xe3\x82\x8c" },  // "れ", "れ"
++  { ':' , "\xe3\x82\x8c", "\xe3\x82\x8c" },  // "れ", "れ"
++  { '\'', "\xe3\x81\x91", "\xe3\x81\x91" },  // "け", "け"
++  { '\"', "\xe3\x81\x91", "\xe3\x81\x91" },  // "け", "け"
++  { 'z' , "\xe3\x81\xa4", "\xe3\x81\xa3" },  // "つ", "っ"
++  { 'Z' , "\xe3\x81\xa3", "\xe3\x81\xa3" },  // "っ", "っ"
++  { 'x' , "\xe3\x81\x95", "\xe3\x81\x95" },  // "さ", "さ"
++  { 'X' , "\xe3\x81\x95", "\xe3\x81\x95" },  // "さ", "さ"
++  { 'c' , "\xe3\x81\x9d", "\xe3\x81\x9d" },  // "そ", "そ"
++  { 'C' , "\xe3\x81\x9d", "\xe3\x81\x9d" },  // "そ", "そ"
++  { 'v' , "\xe3\x81\xb2", "\xe3\x81\xb2" },  // "ひ", "ひ"
++  { 'V' , "\xe3\x81\xb2", "\xe3\x81\xb2" },  // "ひ", "ひ"
++  { 'b' , "\xe3\x81\x93", "\xe3\x81\x93" },  // "こ", "こ"
++  { 'B' , "\xe3\x81\x93", "\xe3\x81\x93" },  // "こ", "こ"
++  { 'n' , "\xe3\x81\xbf", "\xe3\x81\xbf" },  // "み", "み"
++  { 'N' , "\xe3\x81\xbf", "\xe3\x81\xbf" },  // "み", "み"
++  { 'm' , "\xe3\x82\x82", "\xe3\x82\x82" },  // "も", "も"
++  { 'M' , "\xe3\x82\x82", "\xe3\x82\x82" },  // "も", "も"
++  { ',' , "\xe3\x81\xad", "\xe3\x80\x81" },  // "ね", "、"
++  { '<' , "\xe3\x80\x81", "\xe3\x80\x81" },  // "、", "、"
++  { '.' , "\xe3\x82\x8b", "\xe3\x80\x82" },  // "る", "。"
++  { '>' , "\xe3\x80\x82", "\xe3\x80\x82" },  // "。", "。"
++  { '/' , "\xe3\x82\x81", "\xe3\x83\xbb" },  // "め", "・"
++  { '?' , "\xe3\x83\xbb", "\xe3\x83\xbb" },  // "・", "・"
++  { UKey_Yen, "\xe3\x83\xbc", "\xe3\x83\xbc" }, // "ー", "ー"
++};
++
++}  // namespace
++
++namespace mozc {
++namespace uim {
++
++KeyTranslator::KeyTranslator() {
++  Init();
++}
++
++KeyTranslator::~KeyTranslator() {
++}
++
++bool KeyTranslator::Translate(unsigned int keyval,
++                              unsigned int keycode,
++                              unsigned int modifiers,
++                              config::Config::PreeditMethod method,
++                              bool layout_is_jp,
++                              commands::KeyEvent *out_event) const {
++  DCHECK(out_event) << "out_event is NULL";
++  out_event->Clear();
++
++  string kana_key_string;
++  if ((method == config::Config::KANA) && IsKanaAvailable(
++          keyval, keycode, modifiers, layout_is_jp, &kana_key_string)) {
++    out_event->set_key_code(keyval);
++    out_event->set_key_string(kana_key_string);
++  } else if (IsAscii(keyval, keycode, modifiers)) {
++    out_event->set_key_code(keyval);
++  } else if (IsModifierKey(keyval, keycode, modifiers)) {
++    ModifierKeyMap::const_iterator i = modifier_key_map_.find(keyval);
++    DCHECK(i != modifier_key_map_.end());
++    out_event->add_modifier_keys((*i).second);
++  } else if (IsSpecialKey(keyval, keycode, modifiers)) {
++    SpecialKeyMap::const_iterator i = special_key_map_.find(keyval);
++    DCHECK(i != special_key_map_.end());
++    out_event->set_special_key((*i).second);
++  } else if ((method == config::Config::ROMAN) && keyval == UKey_Yen) {
++    /* regards yen key as backslash */
++    out_event->set_key_code('\\');
++  } else {
++    VLOG(1) << "Unknown keyval: " << keyval;
++    return false;
++  }
++
++  for (ModifierKeyMap::const_iterator i = modifier_mask_map_.begin();
++       i != modifier_mask_map_.end();
++       ++i) {
++    // Do not set a SHIFT modifier when |keyval| is a printable key by following
++    // the Mozc's rule.
++    if (((*i).second == commands::KeyEvent::SHIFT) &&
++        IsAscii(keyval, keycode, modifiers)) {
++      continue;
++    }
++
++    if ((*i).first & modifiers) {
++      out_event->add_modifier_keys((*i).second);
++    }
++  }
++
++  return true;
++}
++
++void KeyTranslator::Init() {
++  for (int i = 0; i < arraysize(special_key_map); ++i) {
++    CHECK(special_key_map_.insert(
++        std::make_pair(special_key_map[i].from,
++                       special_key_map[i].to)).second);
++  }
++  for (int i = 0; i < arraysize(modifier_key_map); ++i) {
++    CHECK(modifier_key_map_.insert(
++        std::make_pair(modifier_key_map[i].from,
++                       modifier_key_map[i].to)).second);
++  }
++  for (int i = 0; i < arraysize(modifier_mask_map); ++i) {
++    CHECK(modifier_mask_map_.insert(
++        std::make_pair(modifier_mask_map[i].from,
++                       modifier_mask_map[i].to)).second);
++  }
++  for (int i = 0; i < arraysize(kana_map_jp); ++i) {
++    CHECK(kana_map_jp_.insert(
++        std::make_pair(kana_map_jp[i].code,
++                       std::make_pair(kana_map_jp[i].no_shift,    
++                                      kana_map_jp[i].shift))).second);
++  }
++  for (int i = 0; i < arraysize(kana_map_us); ++i) {
++    CHECK(kana_map_us_.insert(
++        std::make_pair(kana_map_us[i].code,
++                       std::make_pair(kana_map_us[i].no_shift,
++                                      kana_map_us[i].shift))).second);
++  }
++}
++
++bool KeyTranslator::IsModifierKey(unsigned int keyval,
++                                  unsigned int keycode,
++                                  unsigned int modifiers) const {
++  return modifier_key_map_.find(keyval) != modifier_key_map_.end();
++}
++
++bool KeyTranslator::IsSpecialKey(unsigned int keyval,
++                                 unsigned int keycode,
++                                 unsigned int modifiers) const {
++  return special_key_map_.find(keyval) != special_key_map_.end();
++}
++
++bool KeyTranslator::IsKanaAvailable(unsigned int keyval,
++                                    unsigned int keycode,
++                                    unsigned int modifiers,
++                                    bool layout_is_jp,
++                                    string *out) const {
++  if ((modifiers & UMod_Control) || (modifiers & UMod_Alt)) {
++    return false;
++  }
++  const KanaMap &kana_map = layout_is_jp ? kana_map_jp_ : kana_map_us_;
++  KanaMap::const_iterator iter = kana_map.find(keyval);
++  if (iter == kana_map.end()) {
++    return false;
++  }
++
++  if (out)
++      *out = (modifiers & UMod_Shift) ?
++          iter->second.second : iter->second.first;
++
++  return true;
++}
++
++bool KeyTranslator::IsAscii(unsigned int keyval,
++                            unsigned int keycode,
++                            unsigned int modifiers) {
++  return (keyval > 0x20 &&
++          // Note: Space key (0x20) is a special key in Mozc.
++          keyval <= 0x7e);  // ~
++}
++
++}  // namespace uim
++}  // namespace mozc
+diff --git a/src/unix/uim/key_translator.h b/src/unix/uim/key_translator.h
+new file mode 100644
+index 00000000..2649cc5e
+--- /dev/null
++++ unix/uim/key_translator.h
+@@ -0,0 +1,111 @@
++// Copyright 2010, Google Inc.
++// Copyright (c) 2010-2012 uim Project http://code.google.com/p/uim/
++// All rights reserved.
++//
++// Redistribution and use in source and binary forms, with or without
++// modification, are permitted provided that the following conditions are
++// met:
++//
++//     * Redistributions of source code must retain the above copyright
++// notice, this list of conditions and the following disclaimer.
++//     * Redistributions in binary form must reproduce the above
++// copyright notice, this list of conditions and the following disclaimer
++// in the documentation and/or other materials provided with the
++// distribution.
++//     * Neither the name of authors nor the names of its
++// contributors may be used to endorse or promote products derived from
++// this software without specific prior written permission.
++//
++// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
++// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
++// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
++// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
++// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
++// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
++// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++
++#ifndef MOZC_UNIX_UIM_KEY_TRANSLATOR_H_
++#define MOZC_UNIX_UIM_KEY_TRANSLATOR_H_
++
++#include <uim.h>
++
++#include <map>
++#include <ext/hash_map>
++using __gnu_cxx::hash_map;
++
++#include "base/port.h"
++#include "protocol/commands.pb.h"
++
++namespace mozc {
++namespace uim {
++
++// This class is responsible for converting key code sent from ibus-daemon
++// (defined in /usr/include/ibus-1.0/ibuskeysyms.h) to a KeyEvent object for
++// the input of session_interface.
++class KeyTranslator {
++ public:
++  KeyTranslator();
++  virtual ~KeyTranslator();
++
++  // Converts ibus keycode to Mozc key code and stores them on |out_event|.
++  // Returns true if ibus keycode is successfully converted to Mozc key code.
++  bool Translate(unsigned int keyval,
++                 unsigned int keycode,
++                 unsigned int modifiers,
++                 config::Config::PreeditMethod method,
++                 bool layout_is_jp,
++                 commands::KeyEvent *out_event) const;
++
++ private:
++  typedef hash_map<unsigned int, commands::KeyEvent::SpecialKey> SpecialKeyMap;
++  typedef std::map<unsigned int, commands::KeyEvent::ModifierKey> ModifierKeyMap;
++  typedef std::map<unsigned int, std::pair<string, string> > KanaMap;
++
++  // Returns true iff key is modifier key such as SHIFT, ALT, or CAPSLOCK.
++  bool IsModifierKey(unsigned int keyval,
++                     unsigned int keycode,
++                     unsigned int modifiers) const;
++
++  // Returns true iff key is special key such as ENTER, ESC, or PAGE_UP.
++  bool IsSpecialKey(unsigned int keyval,
++                    unsigned int keycode,
++                    unsigned int modifiers) const;
++  // Returns true iff |keyval| is a key with a kana assigned.
++  bool IsKanaAvailable(unsigned int keyval,
++                       unsigned int keycode,
++                       unsigned int modifiers,
++                       bool layout_is_jp,
++                       string *out) const;
++
++
++  // Returns true iff key is ASCII such as '0', 'A', or '!'.
++  static bool IsAscii(unsigned int keyval,
++                      unsigned int keycode,
++                      unsigned int modifiers);
++
++  // Initializes private fields.
++  void Init();
++
++  // Stores a mapping from ibus keys to Mozc's special keys.
++  SpecialKeyMap special_key_map_;
++  // Stores a mapping from ibus modifier keys to Mozc's modifier keys.
++  ModifierKeyMap modifier_key_map_;
++  // Stores a mapping from ibus modifier masks to Mozc's modifier keys.
++  ModifierKeyMap modifier_mask_map_;
++  // Stores a mapping from ASCII to Kana character. For example, ASCII character
++  // '4' is mapped to Japanese 'Hiragana Letter U' (without Shift modifier) and
++  // 'Hiragana Letter Small U' (with Shift modifier).
++  KanaMap kana_map_jp_;  // mapping for JP keyboard.
++  KanaMap kana_map_us_;  // mapping for US keyboard.
++
++  DISALLOW_COPY_AND_ASSIGN(KeyTranslator);
++};
++
++}  // namespace uim
++}  // namespace mozc
++
++#endif  // MOZC_UNIX_UIM_KEY_TRANSLATOR_H_
+diff --git a/src/unix/uim/mozc.cc b/src/unix/uim/mozc.cc
+new file mode 100644
+index 00000000..ceb16bd8
+--- /dev/null
++++ unix/uim/mozc.cc
+@@ -0,0 +1,1219 @@
++/*
++
++  Copyright (c) 2010-2013 uim Project http://code.google.com/p/uim/
++
++  All rights reserved.
++
++  Redistribution and use in source and binary forms, with or without
++  modification, are permitted provided that the following conditions
++  are met:
++
++  1. Redistributions of source code must retain the above copyright
++     notice, this list of conditions and the following disclaimer.
++  2. Redistributions in binary form must reproduce the above copyright
++     notice, this list of conditions and the following disclaimer in the
++     documentation and/or other materials provided with the distribution.
++  3. Neither the name of authors nor the names of its contributors
++     may be used to endorse or promote products derived from this software
++     without specific prior written permission.
++
++  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
++  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++  ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
++  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++  SUCH DAMAGE.
++
++*/
++
++//#include <config.h>
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <ctype.h>
++
++#include "uim.h"
++#include "uim-scm.h"
++#include "uim-scm-abbrev.h"
++#include "uim-util.h"
++#if UIM_VERSION_REQUIRE(1, 6, 0)
++# include "dynlib.h"
++#else
++# include "plugin.h"
++#endif
++
++#include "base/port.h"
++#include "base/util.h"
++#include "base/init_mozc.h"
++#include "protocol/config.pb.h"
++#include "protocol/commands.pb.h"
++#include "client/client.h"
++#include "unix/uim/key_translator.h"
++
++// use server/client session
++#include "base/util.h"
++
++#define USE_CASCADING_CANDIDATES      0
++
++#include <map>
++#include <ext/hash_map>
++using __gnu_cxx::hash_map;
++static char **argv;
++
++// for every 5 minutes, call SyncData
++const uint64 kSyncDataInterval = 5 * 60;
++#if USE_CASCADING_CANDIDATES
++// An ID for a candidate which is not associated with a text.
++const int32 kBadCandidateId = -1;
++#endif
++
++uint64 GetTime() {
++  return static_cast<uint64>(time(NULL));
++}
++
++namespace mozc {
++
++namespace client {
++class ClientInterface;
++}
++namespace uim {
++
++static int nr_contexts;
++static struct context_slot_ {
++  client::ClientInterface *session;
++  commands::Output *output; 
++  commands::CompositionMode currentMode;
++  bool has_preedit_before;
++  bool need_cand_reactivate;
++  int prev_page;
++  int cand_nr_before;
++  uint64 last_sync_time;
++#if USE_CASCADING_CANDIDATES
++  vector<int32> *unique_candidate_ids;
++#endif
++  config::Config::PreeditMethod preedit_method;
++} *context_slot;
++
++static KeyTranslator *keyTranslator;
++static bool enable_reconversion;
++static void update_all(uim_lisp mc_, int id);
++
++static int
++unused_context_id(void)
++{
++  int i;
++
++  for (i = 0; i < nr_contexts; i++) {
++    if (!context_slot[i].session)
++      return i;
++  }
++
++  nr_contexts++;
++  context_slot = (context_slot_ *)uim_realloc(context_slot, sizeof(struct context_slot_) * (nr_contexts));
++
++  return i;
++}
++
++static void
++SyncData(int id, bool force)
++{
++  if (context_slot[id].session == NULL)
++    return;
++
++  const uint64 current_time = GetTime();
++  if (force ||
++      (current_time >= context_slot[id].last_sync_time &&
++       current_time - context_slot[id].last_sync_time >= kSyncDataInterval)) {
++    context_slot[id].session->SyncData();
++    context_slot[id].last_sync_time = current_time;
++  }
++}
++
++static void
++update_deletion_range(uim_lisp mc_, int id)
++{
++  commands::Output *output = context_slot[id].output;
++  int offset, length;
++
++  if (!enable_reconversion)
++    return;
++
++  if (!output->has_deletion_range())
++    return;
++
++  offset = output->deletion_range().offset();
++  length = output->deletion_range().length();
++
++  if (offset + length < 0)
++    return;
++
++  uim_scm_callf("im-delete-text", "oyyii", mc_, "primary", "cursor", -offset, offset + length);
++}
++
++static void
++update_result(uim_lisp mc_, int id)
++{
++  commands::Output *output = context_slot[id].output;
++
++  if (!output->has_result())
++    return;
++
++  const char *str = output->result().value().c_str();
++  uim_scm_callf("im-commit", "os", mc_, str);
++}
++
++static uim_lisp
++insert_cursor(uim_lisp segs, const commands::Preedit::Segment &segment, int attr, int pos)
++{
++  size_t len = segment.value_length();
++
++  auto former = string(Util::Utf8SubString(segment.value(), 0, pos));
++  auto latter = string(Util::Utf8SubString(segment.value(), pos, len));
++
++  uim_lisp seg_f, seg_c, seg_l;
++  if (pos == 0) {
++    seg_f = uim_scm_null(); /* not used */
++    seg_c = CONS(MAKE_INT(UPreeditAttr_Cursor), MAKE_STR(""));
++    seg_l = CONS(MAKE_INT(attr), MAKE_STR(latter.c_str()));
++
++    segs = CONS(seg_c, segs);
++    segs = CONS(seg_l, segs);
++  } else {
++    seg_f = CONS(MAKE_INT(attr), MAKE_STR(former.c_str()));
++    seg_c = CONS(MAKE_INT(UPreeditAttr_Cursor), MAKE_STR(""));
++    seg_l = CONS(MAKE_INT(attr), MAKE_STR(latter.c_str()));
++
++    segs = CONS(seg_f, segs);
++    segs = CONS(seg_c, segs);
++    segs = CONS(seg_l, segs);
++  }
++
++  return segs;
++}
++
++static uim_lisp
++compose_preedit(const commands::Output *output)
++{
++  const commands::Preedit &preedit = output->preedit();
++  uim_lisp segs = uim_scm_null();
++  uim_lisp separator = uim_scm_callf("mozc-separator", "");
++  int cursorPos;
++  int count = 0;
++  int seg_count = preedit.segment_size();
++  
++  cursorPos = output->preedit().cursor();
++
++  for (int i = 0; i < seg_count; ++i) {
++    const commands::Preedit::Segment segment = preedit.segment(i);
++    const char *str = segment.value().c_str();
++    int attr;
++    int prev_count = count;
++    uim_lisp seg;
++    count += segment.value_length();
++
++    switch (segment.annotation()) {
++    case commands::Preedit::Segment::NONE:
++      attr = UPreeditAttr_None;
++      break;
++    case commands::Preedit::Segment::UNDERLINE:
++      attr = UPreeditAttr_UnderLine;
++      break;
++    case commands::Preedit::Segment::HIGHLIGHT:
++      attr = UPreeditAttr_Reverse | UPreeditAttr_Cursor;
++      break;
++    default:
++      attr = UPreeditAttr_None;
++      break;
++    }
++
++    if (((prev_count < cursorPos) && (count > cursorPos)) || cursorPos == 0) {
++      uim_lisp new_segs;
++      if ((new_segs = insert_cursor(segs, segment, attr, cursorPos - prev_count)) != uim_scm_null()) {
++         segs = new_segs;
++         continue;
++      }
++    }
++
++    seg = CONS(MAKE_INT(attr), MAKE_STR(str));
++
++    if (TRUEP(separator) && i > 0)
++      segs = CONS(separator, segs);
++    segs = CONS(seg, segs);
++
++    if (count == cursorPos && !output->preedit().has_highlighted_position()) {
++      seg = CONS(MAKE_INT(UPreeditAttr_Cursor), MAKE_STR(""));
++      segs = CONS(seg, segs);
++    }
++  }
++
++  return uim_scm_callf("reverse", "o", segs);
++}
++
++static void
++update_preedit(uim_lisp mc_, int id)
++{
++  uim_lisp preedit;
++  commands::Output *output = context_slot[id].output;
++
++  if (!output->has_preedit()) {
++    if (context_slot[id].has_preedit_before) {
++      uim_scm_callf("context-update-preedit", "oo", mc_, uim_scm_null());
++    }
++    context_slot[id].has_preedit_before = false;
++
++    return;
++  } else {
++    preedit = compose_preedit(output);
++    context_slot[id].has_preedit_before = true;
++  }
++  uim_scm_callf("context-update-preedit", "oo", mc_, preedit);
++}
++
++static void
++update_candidates(uim_lisp mc_, int id)
++{
++  commands::Output *output = context_slot[id].output;
++
++  if (!output->has_candidates()) {
++    uim_scm_callf("im-deactivate-candidate-selector", "o", mc_);
++    context_slot[id].cand_nr_before = 0;
++
++    return;
++  }
++
++  const commands::Candidates &candidates = output->candidates();
++  bool first_time = false;
++  bool has_focused_index = candidates.has_focused_index();
++  int current_page = has_focused_index ? candidates.focused_index() / 9 : 0;
++
++  if ((context_slot[id].cand_nr_before != candidates.size()) || !has_focused_index)
++    first_time = true;
++
++  if (first_time || (context_slot[id].need_cand_reactivate && current_page != context_slot[id].prev_page)) {
++    uim_scm_callf("im-activate-candidate-selector", "oii", mc_, candidates.size(), 9);
++    // cope with issue #6
++    if (current_page != 0)
++      context_slot[id].need_cand_reactivate = true;
++    else
++      context_slot[id].need_cand_reactivate = false;
++  }
++  context_slot[id].prev_page = current_page;
++
++  if (has_focused_index) {
++    int index = candidates.focused_index();
++    uim_scm_callf("im-select-candidate", "oi", mc_, index);
++  }
++  context_slot[id].cand_nr_before = candidates.size();
++
++#if USE_CASCADING_CANDIDATES
++  if (first_time || (candidates.has_focused_index() && candidates.focused_index() % 9 == 0)) {
++    context_slot[id].unique_candidate_ids->clear();
++    for (int i = 0; i < candidates.candidate_size(); ++i) {
++      if (candidates.candidate(i).has_id()) {
++        const int32 cand_id = candidates.candidate(i).id();
++        context_slot[id].unique_candidate_ids->push_back(cand_id);
++      } else {
++        // The parent node of the cascading window does not have an id since the
++        // node does not contain a candidate word.
++        context_slot[id].unique_candidate_ids->push_back(kBadCandidateId);
++      }
++    }
++  }
++#endif
++}
++
++static void
++update_composition_mode(uim_lisp mc_, int id)
++{
++  commands::Output *output = context_slot[id].output;
++  
++  if (!output->has_mode())
++    return;
++
++  const commands::CompositionMode newMode = output->mode();
++  if (context_slot[id].currentMode == newMode)
++    return;
++
++  context_slot[id].currentMode = newMode;
++}
++
++static void
++execute_callback(uim_lisp mc_, int id)
++{
++  commands::Output *output = context_slot[id].output;
++  
++  if (!enable_reconversion)
++    return;
++
++  if (!output->has_callback())
++    return;
++
++  if (!output->callback().has_session_command())
++    return;
++
++  const commands::SessionCommand &command = output->callback().session_command();
++  if (!command.has_type())
++    return;
++
++  const commands::SessionCommand::CommandType type = command.type();
++  commands::SessionCommand session_command;
++  session_command.set_type(type);
++  int use_primary_text = 0;
++
++  switch (type) {
++  case commands::SessionCommand::UNDO:
++    // do nothing.
++    break;
++  case commands::SessionCommand::CONVERT_REVERSE:
++    {
++      // try selected text first
++      uim_lisp ustr = uim_scm_callf("im-acquire-text", "oyyiy", mc_, "selection", "beginning", 0, "full");
++      uim_lisp latter;
++
++      if (TRUEP(ustr) &&
++        !NULLP(latter = uim_scm_callf("ustr-latter-seq", "o", ustr))) {
++        uim_lisp str = CAR(latter);
++
++          string text = REFER_C_STR(str);
++          session_command.set_text(text);
++      } else {
++#if 0
++      // then primary text
++        uim_lisp former;
++        ustr = uim_scm_callf("im-acquire-text", "oyyyi", mc_, "primary", "cursor", "line", 0);
++      if (TRUEP(ustr) && !NULLP(former = uim_scm_callf("ustr-former-seq", "o", ustr))) {
++        uim_lisp str = CAR(former);
++        string text = REFER_C_STR(str);
++        session_command.set_text(text);
++        use_primary_text = 1;
++      } else
++        return;
++#else
++        // UNDO if no selection
++        session_command.set_type(commands::SessionCommand::UNDO);
++#endif
++      }
++    }
++    break;
++  default:
++    return;
++  }
++
++  if (!context_slot[id].session->SendCommand(session_command, context_slot[id].output)) {
++    // callback command failed
++    return;
++  }
++
++  if (type == commands::SessionCommand::CONVERT_REVERSE) {
++    if (use_primary_text)
++      uim_scm_callf("im-delete-text", "oyyyi", mc_, "primary", "cursor", "line", 0);
++    else
++      uim_scm_callf("im-delete-text", "oyyiy", mc_, "selection", "beginning", 0, "full");
++  }
++  update_all(mc_, id);
++}
++
++static void
++update_all(uim_lisp mc_, int id)
++{
++  update_deletion_range(mc_, id);
++  update_result(mc_, id);
++  update_preedit(mc_, id);
++  update_candidates(mc_, id);
++  update_composition_mode(mc_, id);
++  execute_callback(mc_, id);
++}
++
++static uim_lisp
++create_context(uim_lisp mc_)
++{
++  int id;
++
++  client::ClientInterface *session = new client::Client;
++  commands::Output *output = new commands::Output;
++  if (!keyTranslator)
++    keyTranslator = new KeyTranslator;
++
++  id = unused_context_id();
++  context_slot[id].session = session;
++  context_slot[id].output = output;
++  context_slot[id].currentMode = commands::HIRAGANA;
++  context_slot[id].has_preedit_before = false;
++  context_slot[id].need_cand_reactivate = false;
++  context_slot[id].cand_nr_before = 0;
++  context_slot[id].prev_page = 0;
++#if USE_CASCADING_CANDIDATES
++  context_slot[id].unique_candidate_ids = new vector<int32>;
++#endif
++
++  // Launch mozc_server
++  // or should I call this with mozc-on-key?
++  session->EnsureConnection();
++#if !USE_CASCADING_CANDIDATES
++  session->EnableCascadingWindow(false);
++#endif
++
++  if (!enable_reconversion) {
++    if (!FALSEP(uim_scm_callf("symbol-bound?", "y", "mozc-check-uim-version")))
++      enable_reconversion = (bool)C_BOOL(uim_scm_callf("mozc-check-uim-version", "iii", 1, 7, 2));
++  }
++
++  if (enable_reconversion) {
++    commands::Capability capability;
++    capability.set_text_deletion(commands::Capability::DELETE_PRECEDING_TEXT);
++    session->set_client_capability(capability);
++  }
++
++
++  return MAKE_INT(id);
++}
++
++static uim_lisp
++release_context(uim_lisp id_)
++{
++  int id = C_INT(id_);
++
++  if (id < nr_contexts) {
++    SyncData(id, true);
++    delete context_slot[id].session;
++    delete context_slot[id].output;
++#if USE_CASCADING_CANDIDATES
++    delete context_slot[id].unique_candidate_ids;
++#endif
++    context_slot[id].session = NULL;
++    context_slot[id].output = NULL;
++  }
++
++  return uim_scm_f();
++}
++
++static uim_lisp
++reset_context(uim_lisp id_)
++{
++  return uim_scm_t();
++}
++
++static uim_lisp
++press_key(uim_lisp mc_, uim_lisp id_, uim_lisp key_, uim_lisp state_)
++{
++  client::ClientInterface *session;
++  commands::KeyEvent key;
++  int id;
++  int keyval, keycode, modifiers;
++  config::Config::PreeditMethod preedit_method;
++  char *keyboard;
++  bool layout_is_jp;
++
++  id = C_INT(id_);
++  session = context_slot[id].session;
++  preedit_method = context_slot[id].preedit_method;
++  keyboard = uim_scm_symbol_value_str("mozc-keyboard-type-for-kana-input-method");
++  layout_is_jp = keyboard && !strcmp(keyboard, "jp-keyboard") ? true : false;
++  free(keyboard);
++
++  keyval = C_INT(key_);
++  modifiers = C_INT(state_);
++  keycode = 0; /* XXX */
++
++  if (!(*keyTranslator).Translate(keyval, keycode, modifiers, preedit_method, layout_is_jp, &key))
++    return uim_scm_f();
++
++  if (uim_scm_symbol_value_bool("mozc-use-context-aware-conversion?")) {
++    commands::Context context;
++    uim_lisp ustr = uim_scm_callf("im-acquire-text", "oyyyy", mc_, "primary", "cursor", "line", "line");
++    uim_lisp former, latter, str;
++    if (TRUEP(ustr)) {
++      if(!NULLP(former = uim_scm_callf("ustr-former-seq", "o", ustr))) {
++        str = CAR(former);
++      context.set_preceding_text(REFER_C_STR(str));
++      }
++      if(!NULLP(latter = uim_scm_callf("ustr-latter-seq", "o", ustr))) {
++        str = CAR(latter);
++      context.set_following_text(REFER_C_STR(str));
++      }
++    }
++    if (!(*session).SendKeyWithContext(key, context, context_slot[id].output))
++      return uim_scm_f();
++  } else {
++    if (!(*session).SendKey(key, context_slot[id].output))
++      return uim_scm_f();
++  }
++
++  update_all(mc_, id);
++
++  const bool consumed = context_slot[id].output->consumed();
++#if 0
++  fprintf(stderr, "debugstring %s\n", output.DebugString().c_str());
++  fprintf(stderr, "consumed %d\n", consumed ? 1 : 0);
++#endif
++
++  return consumed ? uim_scm_t() : uim_scm_f();
++}
++
++static uim_lisp
++release_key(uim_lisp id_, uim_lisp key_, uim_lisp state_)
++{
++  return uim_scm_f();
++}
++
++static uim_lisp
++get_nr_candidates(uim_lisp id_)
++{
++  int id = C_INT(id_);
++  commands::Output *output = context_slot[id].output;
++
++  return MAKE_INT(output->candidates().size());
++}
++
++static uim_lisp
++get_nth_candidate(uim_lisp id_, uim_lisp nth_)
++{
++  int id = C_INT(id_);
++  commands::Output *output = context_slot[id].output;
++  const commands::Candidates &candidates = output->candidates();
++  const char *cand, *prefix, *suffix;
++  char *s;
++
++  int nth;
++  int idx;
++  int nr;
++  int page_nr;
++  
++  nth = C_INT(nth_);
++  nr = candidates.size();
++  page_nr = candidates.candidate_size();
++
++  if (nth < nr) {
++    idx = nth % 9;
++
++    if (idx < page_nr) {
++      prefix = candidates.candidate(idx).annotation().prefix().c_str();
++      cand = candidates.candidate(idx).value().c_str();
++      suffix = candidates.candidate(idx).annotation().suffix().c_str();
++      if (asprintf(&s, "%s%s%s", prefix, cand, suffix) == -1)
++        s = strdup("");
++    } else {
++      s = strdup("");
++    }
++  } else
++    s = strdup("");
++
++  return MAKE_STR_DIRECTLY(s);
++}
++
++static uim_lisp
++get_nth_label(uim_lisp id_, uim_lisp nth_)
++{
++  int id = C_INT(id_);
++  commands::Output *output = context_slot[id].output;
++  const commands::Candidates &candidates = output->candidates();
++  const char *label;
++
++  int nth;
++  int idx;
++  int nr;
++  int page_nr;
++  
++  nth = C_INT(nth_);
++  nr = candidates.size();
++  page_nr = candidates.candidate_size();
++
++  if (nth < nr) {
++    idx = nth % 9;
++    if (idx < page_nr)
++      label = candidates.candidate(idx).annotation().shortcut().c_str();
++    else
++      label = "";
++  } else
++    label = "";
++
++  return MAKE_STR(label);
++}
++
++static uim_lisp
++get_nth_annotation(uim_lisp id_, uim_lisp nth_)
++{
++  int id = C_INT(id_);
++  commands::Output *output = context_slot[id].output;
++  const commands::Candidates &candidates = output->candidates();
++  const char *annotation;
++
++  int nth;
++  int idx;
++  int nr;
++  int page_nr;
++  
++  nth = C_INT(nth_);
++  nr = candidates.size();
++  page_nr = candidates.candidate_size();
++
++  if (nth < nr) {
++    idx = nth % 9;
++    if (idx < page_nr)
++      annotation = candidates.candidate(idx).annotation().description().c_str();
++    else
++      annotation = "";
++
++  } else
++    annotation = "";
++
++  return MAKE_STR(annotation);
++}
++
++/* from uim-key.c */
++static struct key_entry {
++  int key;
++  const char *str;
++} key_tab[] = {
++  {UKey_Yen, "yen"},
++  {UKey_Backspace, "backspace"},
++  {UKey_Delete, "delete"},
++  {UKey_Escape, "escape"},
++  {UKey_Return, "return"},
++  {UKey_Tab, "tab"},
++  {UKey_Left, "left"},
++  {UKey_Up, "up"},
++  {UKey_Right, "right"},
++  {UKey_Down, "down"},
++  {UKey_Prior, "prior"},
++  {UKey_Next, "next"},
++  {UKey_Home, "home"},
++  {UKey_End, "end"},
++  {UKey_Insert, "insert"},
++  {UKey_Multi_key, "Multi_key"},
++  {UKey_Codeinput, "codeinput"},
++  {UKey_SingleCandidate, "single-candidate"},
++  {UKey_MultipleCandidate, "multiple-candidate"},
++  {UKey_PreviousCandidate, "previous-candidate"},
++  {UKey_Mode_switch, "Mode_switch"},
++  {UKey_Kanji, "Kanji"},
++  {UKey_Muhenkan, "Muhenkan"},
++  {UKey_Henkan_Mode, "Henkan_Mode"},
++  {UKey_Romaji, "romaji"},
++  {UKey_Hiragana, "hiragana"},
++  {UKey_Katakana, "katakana"},
++  {UKey_Hiragana_Katakana, "hiragana-katakana"},
++  {UKey_Zenkaku, "zenkaku"},
++  {UKey_Hankaku, "hankaku"},
++  {UKey_Zenkaku_Hankaku, "zenkaku-hankaku"},
++  {UKey_Touroku, "touroku"},
++  {UKey_Massyo, "massyo"},
++  {UKey_Kana_Lock, "kana-lock"},
++  {UKey_Kana_Shift, "kana-shift"},
++  {UKey_Eisu_Shift, "eisu-shift"},
++  {UKey_Eisu_toggle, "eisu-toggle"},
++
++  {UKey_Hangul, "hangul"},
++  {UKey_Hangul_Start, "hangul-start"},
++  {UKey_Hangul_End, "hangul-end"},
++  {UKey_Hangul_Hanja, "hangul-hanja"},
++  {UKey_Hangul_Jamo, "hangul-jamo"},
++  {UKey_Hangul_Romaja, "hangul-romaja"},
++  {UKey_Hangul_Codeinput, "hangul-codeinput"},
++  {UKey_Hangul_Jeonja, "hangul-jeonja"},
++  {UKey_Hangul_Banja, "hangul-banja"},
++  {UKey_Hangul_PreHanja, "hangul-prehanja"},
++  {UKey_Hangul_PostHanja, "hangul-posthanja"},
++  {UKey_Hangul_SingleCandidate, "hangul-single-candidate"},
++  {UKey_Hangul_MultipleCandidate, "hangul-multiple-candidate"},
++  {UKey_Hangul_PreviousCandidate, "hangul-previous-candidate"},
++  {UKey_Hangul_Special, "hangul-special"},
++
++  {UKey_F1, "F1"},
++  {UKey_F2, "F2"},
++  {UKey_F3, "F3"},
++  {UKey_F4, "F4"},
++  {UKey_F5, "F5"},
++  {UKey_F6, "F6"},
++  {UKey_F7, "F7"},
++  {UKey_F8, "F8"},
++  {UKey_F9, "F9"},
++  {UKey_F10, "F10"},
++  {UKey_F11, "F11"},
++  {UKey_F12, "F12"},
++  {UKey_F13, "F13"},
++  {UKey_F14, "F14"},
++  {UKey_F15, "F15"},
++  {UKey_F16, "F16"},
++  {UKey_F17, "F17"},
++  {UKey_F18, "F18"},
++  {UKey_F19, "F19"},
++  {UKey_F20, "F20"},
++  {UKey_F21, "F21"},
++  {UKey_F22, "F22"},
++  {UKey_F23, "F23"},
++  {UKey_F24, "F24"},
++  {UKey_F25, "F25"},
++  {UKey_F26, "F26"},
++  {UKey_F27, "F27"},
++  {UKey_F28, "F28"},
++  {UKey_F29, "F29"},
++  {UKey_F30, "F30"},
++  {UKey_F31, "F31"},
++  {UKey_F32, "F32"},
++  {UKey_F33, "F33"},
++  {UKey_F34, "F34"},
++  {UKey_F35, "F35"},
++
++  {UKey_Dead_Grave, "dead-grave"},
++  {UKey_Dead_Acute, "dead-acute"},
++  {UKey_Dead_Circumflex, "dead-circumflex"},
++  {UKey_Dead_Tilde, "dead-tilde"},
++  {UKey_Dead_Macron, "dead-macron"},
++  {UKey_Dead_Breve, "dead-breve"},
++  {UKey_Dead_Abovedot, "dead-abovedot"},
++  {UKey_Dead_Diaeresis, "dead-diaeresis"},
++  {UKey_Dead_Abovering, "dead-abovering"},
++  {UKey_Dead_Doubleacute, "dead-doubleacute"},
++  {UKey_Dead_Caron, "dead-caron"},
++  {UKey_Dead_Cedilla, "dead-cedilla"},
++  {UKey_Dead_Ogonek, "dead-ogonek"},
++  {UKey_Dead_Iota, "dead-iota"},
++  {UKey_Dead_VoicedSound, "dead-voiced-sound"},
++  {UKey_Dead_SemivoicedSound, "dead-semivoiced-sound"},
++  {UKey_Dead_Belowdot, "dead-belowdot"},
++  {UKey_Dead_Hook, "dead-hook"},
++  {UKey_Dead_Horn, "dead-horn"},
++
++  {UKey_Kana_Fullstop, "kana-fullstop"},
++  {UKey_Kana_OpeningBracket, "kana-opening-bracket"},
++  {UKey_Kana_ClosingBracket, "kana-closing-bracket"},
++  {UKey_Kana_Comma, "kana-comma"},
++  {UKey_Kana_Conjunctive, "kana-conjunctive"},
++  {UKey_Kana_WO, "kana-WO"},
++  {UKey_Kana_a, "kana-a"},
++  {UKey_Kana_i, "kana-i"},
++  {UKey_Kana_u, "kana-u"},
++  {UKey_Kana_e, "kana-e"},
++  {UKey_Kana_o, "kana-o"},
++  {UKey_Kana_ya, "kana-ya"},
++  {UKey_Kana_yu, "kana-yu"},
++  {UKey_Kana_yo, "kana-yo"},
++  {UKey_Kana_tsu, "kana-tsu"},
++  {UKey_Kana_ProlongedSound, "kana-prolonged-sound"},
++  {UKey_Kana_A, "kana-A"},
++  {UKey_Kana_I, "kana-I"},
++  {UKey_Kana_U, "kana-U"},
++  {UKey_Kana_E, "kana-E"},
++  {UKey_Kana_O, "kana-O"},
++  {UKey_Kana_KA, "kana-KA"},
++  {UKey_Kana_KI, "kana-KI"},
++  {UKey_Kana_KU, "kana-KU"},
++  {UKey_Kana_KE, "kana-KE"},
++  {UKey_Kana_KO, "kana-KO"},
++  {UKey_Kana_SA, "kana-SA"},
++  {UKey_Kana_SHI, "kana-SHI"},
++  {UKey_Kana_SU, "kana-SU"},
++  {UKey_Kana_SE, "kana-SE"},
++  {UKey_Kana_SO, "kana-SO"},
++  {UKey_Kana_TA, "kana-TA"},
++  {UKey_Kana_CHI, "kana-CHI"},
++  {UKey_Kana_TSU, "kana-TSU"},
++  {UKey_Kana_TE, "kana-TE"},
++  {UKey_Kana_TO, "kana-TO"},
++  {UKey_Kana_NA, "kana-NA"},
++  {UKey_Kana_NI, "kana-NI"},
++  {UKey_Kana_NU, "kana-NU"},
++  {UKey_Kana_NE, "kana-NE"},
++  {UKey_Kana_NO, "kana-NO"},
++  {UKey_Kana_HA, "kana-HA"},
++  {UKey_Kana_HI, "kana-HI"},
++  {UKey_Kana_FU, "kana-FU"},
++  {UKey_Kana_HE, "kana-HE"},
++  {UKey_Kana_HO, "kana-HO"},
++  {UKey_Kana_MA, "kana-MA"},
++  {UKey_Kana_MI, "kana-MI"},
++  {UKey_Kana_MU, "kana-MU"},
++  {UKey_Kana_ME, "kana-ME"},
++  {UKey_Kana_MO, "kana-MO"},
++  {UKey_Kana_YA, "kana-YA"},
++  {UKey_Kana_YU, "kana-YU"},
++  {UKey_Kana_YO, "kana-YO"},
++  {UKey_Kana_RA, "kana-RA"},
++  {UKey_Kana_RI, "kana-RI"},
++  {UKey_Kana_RU, "kana-RU"},
++  {UKey_Kana_RE, "kana-RE"},
++  {UKey_Kana_RO, "kana-RO"},
++  {UKey_Kana_WA, "kana-WA"},
++  {UKey_Kana_N, "kana-N"},
++  {UKey_Kana_VoicedSound, "kana-voiced-sound"},
++  {UKey_Kana_SemivoicedSound, "kana-semivoiced-sound"},
++
++  {UKey_Private1, "Private1"},
++  {UKey_Private2, "Private2"},
++  {UKey_Private3, "Private3"},
++  {UKey_Private4, "Private4"},
++  {UKey_Private5, "Private5"},
++  {UKey_Private6, "Private6"},
++  {UKey_Private7, "Private7"},
++  {UKey_Private8, "Private8"},
++  {UKey_Private9, "Private9"},
++  {UKey_Private10, "Private10"},
++  {UKey_Private11, "Private11"},
++  {UKey_Private12, "Private12"},
++  {UKey_Private13, "Private13"},
++  {UKey_Private14, "Private14"},
++  {UKey_Private15, "Private15"},
++  {UKey_Private16, "Private16"},
++  {UKey_Private17, "Private17"},
++  {UKey_Private18, "Private18"},
++  {UKey_Private19, "Private19"},
++  {UKey_Private20, "Private20"},
++  {UKey_Private21, "Private21"},
++  {UKey_Private22, "Private22"},
++  {UKey_Private23, "Private23"},
++  {UKey_Private24, "Private24"},
++  {UKey_Private25, "Private25"},
++  {UKey_Private26, "Private26"},
++  {UKey_Private27, "Private27"},
++  {UKey_Private28, "Private28"},
++  {UKey_Private29, "Private29"},
++  {UKey_Private30, "Private30"},
++  {UKey_Shift_key, "Shift_key"},
++  {UKey_Alt_key, "Alt_key"},
++  {UKey_Control_key, "Control_key"},
++  {UKey_Meta_key, "Meta_key"},
++  {UKey_Super_key, "Super_key"},
++  {UKey_Hyper_key, "Hyper_key"},
++
++  {UKey_Caps_Lock, "caps-lock"},
++  {UKey_Num_Lock, "num-lock"},
++  {UKey_Scroll_Lock, "scroll-lock"},
++  /*  {UKey_Other, "other"},*/
++  {0, 0}
++};
++
++struct eqstr
++{
++  bool operator()(const char* s1, const char* s2) const
++  {
++    return strcmp(s1, s2) == 0;
++  }
++};
++
++typedef hash_map<const char *, int, __gnu_cxx::hash<const char *>, eqstr> KeyMap;
++static KeyMap key_map;
++
++static void install_keymap(void)
++{
++  int i;
++
++  for (i = 0; key_tab[i].key; i++)
++    key_map.insert(std::make_pair(key_tab[i].str, key_tab[i].key));
++}
++
++static uim_lisp
++keysym_to_int(uim_lisp sym_)
++{
++  const char *sym = uim_scm_refer_c_str(sym_);
++  int key = 0;
++
++  KeyMap::iterator it = key_map.find(sym);
++  if (it != key_map.end())
++    key = it->second;
++
++  return uim_scm_make_int(key);
++}
++
++static uim_lisp
++get_composition_mode(uim_lisp id_)
++{
++  int id = C_INT(id_);
++  const commands::CompositionMode mode = context_slot[id].currentMode;
++  int type = 0;
++
++  switch (mode) {
++  case commands::DIRECT:
++    type = -1;
++    break;
++  case commands::HIRAGANA:
++    type = 0;
++    break;
++  case commands::FULL_KATAKANA:
++    type = 1;
++    break;
++  case commands::HALF_KATAKANA:
++    type = 2;
++    break;
++  case commands::HALF_ASCII:
++    type = 3;
++    break;
++  case commands::FULL_ASCII:
++    type = 4;
++    break;
++  default:
++    type = -1;
++    break;
++  }
++
++  return MAKE_INT(type);
++}
++
++static uim_lisp
++set_composition_mode(uim_lisp mc_, uim_lisp id_, uim_lisp new_mode_)
++{
++  int id = C_INT(id_);
++  commands::CompositionMode mode;
++  commands::SessionCommand command;
++
++  switch (C_INT(new_mode_)) {
++  case -1:
++    mode = commands::DIRECT;
++    break;
++  case 0:
++    mode = commands::HIRAGANA;
++    break;
++  case 1:
++    mode = commands::FULL_KATAKANA;
++    break;
++  case 2:
++    mode = commands::HALF_KATAKANA;
++    break;
++  case 3:
++    mode = commands::HALF_ASCII;
++    break;
++  case 4:
++    mode = commands::FULL_ASCII;
++    break;
++  default:
++    mode = commands::HIRAGANA;
++    break;
++  }
++
++  if (mode == commands::DIRECT) {
++    command.set_type(commands::SessionCommand::SUBMIT);
++    context_slot[id].session->SendCommand(command, context_slot[id].output);
++    update_all(mc_, id);
++    uim_scm_callf("mozc-context-set-on!", "oo", mc_, uim_scm_f());
++  } else {
++    command.set_type(commands::SessionCommand::SWITCH_INPUT_MODE);
++    command.set_composition_mode(mode);
++    context_slot[id].session->SendCommand(command, context_slot[id].output);
++    context_slot[id].currentMode = mode; /* don't set this with DIRECT mode */
++    uim_scm_callf("mozc-context-set-on!", "oo", mc_, uim_scm_t());
++  }
++
++  return uim_scm_t();
++}
++ 
++static uim_lisp
++set_composition_on(uim_lisp id_)
++{
++  int id = C_INT(id_);
++  commands::SessionCommand command;
++
++  command.set_type(commands::SessionCommand::SWITCH_INPUT_MODE);
++  command.set_composition_mode(context_slot[id].currentMode);
++  context_slot[id].session->SendCommand(command, context_slot[id].output);
++
++  return uim_scm_t();
++}
++
++static uim_lisp
++has_preedit(uim_lisp id_)
++{
++  int id = C_INT(id_);
++  
++  return context_slot[id].has_preedit_before ? uim_scm_t() : uim_scm_f();
++}
++
++static uim_lisp
++select_candidate(uim_lisp mc_, uim_lisp id_, uim_lisp idx_)
++{
++  int id = C_INT(id_);
++  int idx = C_INT(idx_) % 9;
++  
++#if USE_CASCADING_CANDIDATES
++  if (idx >= context_slot[id].unique_candidate_ids->size())
++#else
++  if (idx >= context_slot[id].output->candidates().candidate_size())
++#endif
++    return uim_scm_f();
++
++#if USE_CASCADING_CANDIDATES
++  const int32 cand_id = (*context_slot[id].unique_candidate_ids)[idx];
++  if (cand_id == kBadCandidateId)
++    return uim_scm_f();
++#else
++  const int32 cand_id = context_slot[id].output->candidates().candidate(idx).id();
++#endif
++
++  commands::SessionCommand command;
++  command.set_type(commands::SessionCommand::SELECT_CANDIDATE);
++  command.set_id(cand_id);
++  context_slot[id].session->SendCommand(command, context_slot[id].output);
++  update_all(mc_, id);
++  
++  return uim_scm_t();
++}
++
++static uim_lisp
++get_input_rule(uim_lisp id_)
++{
++  int id = C_INT(id_);
++  const config::Config::PreeditMethod method = context_slot[id].preedit_method;
++  int rule = 0;
++
++  switch (method) {
++  case config::Config::ROMAN:
++    rule = 0;
++    break;
++  case config::Config::KANA:
++    rule = 1;
++    break;
++  default:
++    rule = 0;
++    break;
++  }
++
++  return MAKE_INT(rule);
++}
++
++static uim_lisp
++set_input_rule(uim_lisp mc_, uim_lisp id_, uim_lisp new_rule_)
++{
++  int id = C_INT(id_);
++  config::Config config;
++  config::Config::PreeditMethod method;
++
++  switch (C_INT(new_rule_)) {
++  case 0:
++    method = config::Config::ROMAN;
++    break;
++  case 1:
++    method = config::Config::KANA;
++    break;
++  default:
++    method = config::Config::ROMAN;
++    break;
++  }
++
++  if (!context_slot[id].session->GetConfig(&config))
++    return uim_scm_f();
++
++  config.set_preedit_method(method);
++
++  if (!context_slot[id].session->SetConfig(config))
++    return uim_scm_f();
++
++  context_slot[id].preedit_method = method;
++
++  return uim_scm_t();
++}
++
++static uim_lisp
++reconvert(uim_lisp mc_, uim_lisp id_)
++{
++  if (!enable_reconversion)
++    return uim_scm_f();
++
++  int id = C_INT(id_);
++  commands::SessionCommand session_command;
++  session_command.set_type(commands::SessionCommand::CONVERT_REVERSE);
++
++  // try selected text first, then primary text
++  uim_lisp ustr = uim_scm_callf("im-acquire-text", "oyyiy", mc_, "selection" , "beginning", 0, "full");
++  uim_lisp former, latter;
++  int use_primary_text = 0;
++
++  if (TRUEP(ustr) &&
++      !NULLP(latter = uim_scm_callf("ustr-latter-seq", "o", ustr))) {
++    uim_lisp str = CAR(latter);
++
++    string text = REFER_C_STR(str);
++    session_command.set_text(text);
++  } else {
++    ustr = uim_scm_callf("im-acquire-text", "oyyyi", mc_, "primary", "cursor", "line", 0);
++    if (TRUEP(ustr) &&
++      !NULLP(former = uim_scm_callf("ustr-former-seq", "o", ustr))) {
++      uim_lisp str = CAR(former);
++      string text = REFER_C_STR(str);
++      session_command.set_text(text);
++      use_primary_text = 1;
++    } else
++      return uim_scm_f();
++  }
++
++  if (!context_slot[id].session->SendCommand(session_command, context_slot[id].output))
++    return uim_scm_f();
++
++  if (use_primary_text)
++    uim_scm_callf("im-delete-text", "oyyyi", mc_, "primary", "cursor", "line", 0);
++  else
++    uim_scm_callf("im-delete-text", "oyyiy", mc_, "selection", "beginning", 0, "full");
++  update_all(mc_, id);
++
++  return uim_scm_t();
++}
++
++static uim_lisp
++submit(uim_lisp mc_, uim_lisp id_)
++{
++  int id = C_INT(id_);
++  commands::SessionCommand command;
++
++  command.set_type(commands::SessionCommand::SUBMIT);
++  context_slot[id].session->SendCommand(command, context_slot[id].output);
++  update_all(mc_, id);
++
++  return uim_scm_t();
++}
++
++} // namespace
++} // namespace
++
++
++
++void
++uim_plugin_instance_init(void)
++{
++  uim_scm_init_proc1("mozc-lib-alloc-context", mozc::uim::create_context);
++  uim_scm_init_proc1("mozc-lib-free-context", mozc::uim::release_context);
++  uim_scm_init_proc1("mozc-lib-reset", mozc::uim::reset_context);
++  uim_scm_init_proc4("mozc-lib-press-key", mozc::uim::press_key);
++  uim_scm_init_proc3("mozc-lib-release-key", mozc::uim::release_key);
++  uim_scm_init_proc1("mozc-lib-get-nr-candidates", mozc::uim::get_nr_candidates);
++  uim_scm_init_proc2("mozc-lib-get-nth-candidate", mozc::uim::get_nth_candidate);
++  uim_scm_init_proc2("mozc-lib-get-nth-label", mozc::uim::get_nth_label);
++  uim_scm_init_proc2("mozc-lib-get-nth-annotation", mozc::uim::get_nth_annotation);
++  uim_scm_init_proc1("keysym-to-int", mozc::uim::keysym_to_int);
++  uim_scm_init_proc1("mozc-lib-input-mode", mozc::uim::get_composition_mode);
++  uim_scm_init_proc3("mozc-lib-set-input-mode", mozc::uim::set_composition_mode);
++  uim_scm_init_proc1("mozc-lib-set-on", mozc::uim::set_composition_on);
++  uim_scm_init_proc1("mozc-lib-has-preedit?", mozc::uim::has_preedit);
++  uim_scm_init_proc3("mozc-lib-set-candidate-index", mozc::uim::select_candidate);
++  uim_scm_init_proc1("mozc-lib-input-rule", mozc::uim::get_input_rule);
++  uim_scm_init_proc3("mozc-lib-set-input-rule", mozc::uim::set_input_rule);
++  uim_scm_init_proc2("mozc-lib-reconvert", mozc::uim::reconvert);
++  uim_scm_init_proc2("mozc-lib-submit-composition", mozc::uim::submit);
++
++  int argc = 1;
++  static const char name[] = "uim-mozc";
++  argv = (char **)malloc(sizeof(char *) * 2);
++  argv[0] = (char *)name;
++  argv[1] =  NULL;
++
++  mozc::InitMozc((const char *)argv[0], &argc, (char ***)&argv);
++  mozc::uim::install_keymap();
++}
++
++void
++uim_plugin_instance_quit(void)
++{
++  mozc::uim::key_map.clear();
++  for (int i = 0; i < mozc::uim::nr_contexts; i++) {
++    if (mozc::uim::context_slot[i].session) {
++      delete mozc::uim::context_slot[i].session;
++      delete mozc::uim::context_slot[i].output;
++    }
++  }
++  delete mozc::uim::keyTranslator;
++  mozc::uim::keyTranslator = NULL;
++  free(argv);
++}
+diff --git a/src/unix/uim/scm/mozc-custom.scm b/src/unix/uim/scm/mozc-custom.scm
+new file mode 100644
+index 00000000..adfd65bd
+--- /dev/null
++++ unix/uim/scm/mozc-custom.scm
+@@ -0,0 +1,396 @@
++;;;
++;;; Copyright (c) 2010-2012 uim Project http://code.google.com/p/uim/
++;;;
++;;; All rights reserved.
++;;;
++;;; Redistribution and use in source and binary forms, with or without
++;;; modification, are permitted provided that the following conditions
++;;; are met:
++;;; 1. Redistributions of source code must retain the above copyright
++;;;    notice, this list of conditions and the following disclaimer.
++;;; 2. Redistributions in binary form must reproduce the above copyright
++;;;    notice, this list of conditions and the following disclaimer in the
++;;;    documentation and/or other materials provided with the distribution.
++;;; 3. Neither the name of authors nor the names of its contributors
++;;;    may be used to endorse or promote products derived from this software
++;;;    without specific prior written permission.
++;;;
++;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
++;;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++;;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++;;; ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
++;;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++;;; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++;;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++;;; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++;;; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++;;; SUCH DAMAGE.
++;;;;
++
++(require "i18n.scm")
++
++(define mozc-im-name-label (N_ "Mozc"))
++(define mozc-im-short-desc (N_ "Mozc Japanese engine"))
++
++(define-custom-group 'mozc
++                   (ugettext mozc-im-name-label)
++                   (ugettext mozc-im-short-desc))
++
++;;
++;; segment separator
++;;
++
++(define-custom 'mozc-show-segment-separator? #f
++  '(mozc segment-sep)
++  '(boolean)
++  (N_ "Show segment separator")
++  (N_ "long description will be here."))
++
++(define-custom 'mozc-segment-separator "|"
++  '(mozc segment-sep)
++  '(string ".*")
++  (N_ "Segment separator")
++  (N_ "long description will be here."))
++
++(custom-add-hook 'mozc-segment-separator
++                 'custom-activity-hooks
++                 (lambda ()
++                   mozc-show-segment-separator?))
++
++;;
++;; toolbar
++;;
++
++;; Can't be unified with action definitions in mozc.scm until uim
++;; 0.4.6.
++(define mozc-input-mode-indication-alist
++  (list
++   (list 'action_mozc_direct
++       'ja_direct
++       "-"
++       (N_ "Direct input")
++       (N_ "Direct input mode"))
++   (list 'action_mozc_hiragana
++       'ja_hiragana
++       "あ"
++       (N_ "Hiragana")
++       (N_ "Hiragana input mode"))
++   (list 'action_mozc_katakana
++       'ja_katakana
++       "ア"
++       (N_ "Katakana")
++       (N_ "Katakana input mode"))
++   (list 'action_mozc_halfkana
++       'ja_halfkana
++       "ア"
++       (N_ "Halfwidth Katakana")
++       (N_ "Halfwidth Katakana input mode"))
++   (list 'action_mozc_halfwidth_alnum
++       'ja_halfwidth_alnum
++       "a"
++       (N_ "Halfwidth Alphanumeric")
++       (N_ "Halfwidth Alphanumeric input mode"))
++   (list 'action_mozc_fullwidth_alnum
++       'ja_fullwidth_alnum
++       "A"
++       (N_ "Fullwidth Alphanumeric")
++       (N_ "Fullwidth Alphanumeric input mode"))))
++
++(define mozc-kana-input-method-indication-alist
++  (list
++   (list 'action_mozc_roma
++         'ja_romaji
++         "R"
++         (N_ "Romaji")
++         (N_ "Romaji input mode"))
++   (list 'action_mozc_kana
++         'ja_kana
++         "か"
++         (N_ "Kana")
++         (N_ "Kana input mode"))))
++
++(define mozc-tool-indication-alist
++  (list
++   (list 'action_mozc_tool_selector
++         'mozc_tool_selector
++         "T"
++         (N_ "MozcTool selector")
++         (N_ "MozcTool selector"))
++   (list 'action_mozc_tool_about_dialog
++         'mozc_tool_about_dialog
++         "A"
++         (N_ "About")
++         (N_ "About"))
++   (list 'action_mozc_tool_config_dialog
++         'mozc_tool_config_dialog
++         "C"
++         (N_ "Config dialog")
++         (N_ "Config dialog"))
++   (list 'action_mozc_tool_dictionary_tool
++         'mozc_tool_dictionary_tool
++         "D"
++         (N_ "Dictionary tool")
++         (N_ "Dictionary tool"))
++   (list 'action_mozc_tool_word_register_dialog
++         'mozc_tool_word_register_dialog
++         "W"
++         (N_ "Word register dialog")
++         (N_ "Word register dialog"))
++   (list 'action_mozc_tool_character_palette
++         'mozc_tool_character_palette
++         "P"
++         (N_ "Character palette")
++         (N_ "Character palette"))
++   (list 'action_mozc_tool_hand_writing
++         'mozc_tool_hand_writing
++         "H"
++         (N_ "Hand writing")
++         (N_ "Hand writing"))
++   (list 'action_mozc_reconvert
++         'mozc_reconvert
++         "R"
++         (N_ "Reconvert")
++         (N_ "Reconvert"))))
++
++
++;;; Buttons
++
++(define-custom 'mozc-widgets '(widget_mozc_input_mode
++                               widget_mozc_kana_input_method
++                               widget_mozc_tool)
++  '(mozc toolbar)
++  (list 'ordered-list
++      (list 'widget_mozc_input_mode
++            (_ "Input mode")
++            (_ "Input mode"))
++      (list 'widget_mozc_kana_input_method
++            (_ "Kana input method")
++            (_ "Kana input method"))
++      (list 'widget_mozc_tool
++            (_ "Mozc tool")
++            (_ "Mozc tool")))
++  (_ "Enabled toolbar buttons")
++  (_ "long description will be here."))
++
++;; dynamic reconfiguration
++;; mozc-configure-widgets is not defined at this point. So wrapping
++;; into lambda.
++(custom-add-hook 'mozc-widgets
++               'custom-set-hooks
++               (lambda ()
++                 (mozc-configure-widgets)))
++
++
++;;; Input mode
++
++(define-custom 'default-widget_mozc_input_mode 'action_mozc_direct
++  '(mozc toolbar)
++  (cons 'choice
++      (map indication-alist-entry-extract-choice
++           mozc-input-mode-indication-alist))
++  (_ "Default input mode")
++  (_ "long description will be here."))
++
++(define-custom 'mozc-input-mode-actions
++             (map car mozc-input-mode-indication-alist)
++  '(mozc toolbar)
++  (cons 'ordered-list
++      (map indication-alist-entry-extract-choice
++           mozc-input-mode-indication-alist))
++  (_ "Input mode menu items")
++  (_ "long description will be here."))
++
++;; value dependency
++(if custom-full-featured?
++    (custom-add-hook 'mozc-input-mode-actions
++                   'custom-set-hooks
++                   (lambda ()
++                     (custom-choice-range-reflect-olist-val
++                      'default-widget_mozc_input_mode
++                      'mozc-input-mode-actions
++                      mozc-input-mode-indication-alist))))
++
++;; activity dependency
++(custom-add-hook 'default-widget_mozc_input_mode
++               'custom-activity-hooks
++               (lambda ()
++                 (memq 'widget_mozc_input_mode mozc-widgets)))
++
++(custom-add-hook 'mozc-input-mode-actions
++               'custom-activity-hooks
++               (lambda ()
++                 (memq 'widget_mozc_input_mode mozc-widgets)))
++
++;; dynamic reconfiguration
++(custom-add-hook 'default-widget_mozc_input_mode
++               'custom-set-hooks
++               (lambda ()
++                 (mozc-configure-widgets)))
++
++(custom-add-hook 'mozc-input-mode-actions
++               'custom-set-hooks
++               (lambda ()
++                 (mozc-configure-widgets)))
++
++;;; Kana input method
++
++(define-custom 'default-widget_mozc_kana_input_method 'action_mozc_roma
++  '(mozc toolbar)
++  (cons 'choice
++        (map indication-alist-entry-extract-choice
++             mozc-kana-input-method-indication-alist))
++  (N_ "Default kana input method")
++  (N_ "long description will be here."))
++
++(define-custom 'mozc-kana-input-method-actions
++               (map car mozc-kana-input-method-indication-alist)
++  '(mozc toolbar)
++  (cons 'ordered-list
++        (map indication-alist-entry-extract-choice
++             mozc-kana-input-method-indication-alist))
++  (N_ "Kana input method menu items")
++  (N_ "long description will be here."))
++
++;; value dependency
++(if custom-full-featured?
++    (custom-add-hook 'mozc-kana-input-method-actions
++                     'custom-set-hooks
++                     (lambda ()
++                       (custom-choice-range-reflect-olist-val
++                        'default-widget_mozc_kana_input_method
++                        'mozc-kana-input-method-actions
++                        mozc-kana-input-method-indication-alist))))
++
++;; activity dependency
++(custom-add-hook 'default-widget_mozc_kana_input_method
++                 'custom-activity-hooks
++                 (lambda ()
++                   (memq 'widget_mozc_kana_input_method mozc-widgets
++)))
++
++(custom-add-hook 'mozc-kana-input-method-actions
++                 'custom-activity-hooks
++                 (lambda ()
++                   (memq 'widget_mozc_kana_input_method mozc-widgets
++)))
++
++;; dynamic reconfiguration
++(custom-add-hook 'default-widget_mozc_kana_input_method
++                 'custom-set-hooks
++                 (lambda ()
++                   (mozc-configure-widgets)))
++
++(custom-add-hook 'mozc-kana-input-method-actions
++                 'custom-set-hooks
++                 (lambda ()
++                   (mozc-configure-widgets)))
++
++
++;;; Mozc tool
++(define mozc-tool-actions (map car mozc-tool-indication-alist))
++
++
++
++
++
++(define-custom 'mozc-use-with-vi? #f
++  '(mozc special-op)
++  '(boolean)
++  (N_ "Enable vi-cooperative mode")
++  (N_ "long description will be here."))
++
++(define-custom 'mozc-use-context-aware-conversion? #f
++  '(mozc special-op)
++  '(boolean)
++  (N_ "Use text input with context awareness")
++  (N_ "long description will be here."))
++
++(define-custom 'mozc-keyboard-type-for-kana-input-method 'jp-keyboard
++  '(mozc)
++  (list 'choice
++        (list 'jp-keyboard
++              (N_ "Japanese keyboard")
++              (N_ "long description will be here."))
++        (list 'us-keyboard
++              (N_ "US keyboard")
++              (N_ "long description will be here.")))
++  (N_ "Keyboard type for kana input method")
++  (N_ "long description will be here."))
++
++
++(define-custom-group 'mozc-tool
++                   (N_ "MozcTool")
++                   (N_ "MozcTool settings"))
++
++(define-custom 'mozc-tool-about-dialog-cmd "/usr/lib/mozc/mozc_tool"
++               '(mozc-tool)
++               '(pathname regular-file)
++               (N_ "Path of about dialog command")
++               (N_ "long description will be here."))
++
++(define-custom 'mozc-tool-about-dialog-cmd-option "--mode=about_dialog"
++               '(mozc-tool)
++               '(string ".*")
++               (N_ "Option for about dialog command")
++               (N_ "long description will be here."))
++
++(define-custom 'mozc-tool-config-dialog-cmd "/usr/lib/mozc/mozc_tool"
++               '(mozc-tool)
++               '(pathname regular-file)
++               (N_ "Path of config dialog command")
++               (N_ "long description will be here."))
++
++(define-custom 'mozc-tool-config-dialog-cmd-option "--mode=config_dialog"
++               '(mozc-tool)
++               '(string ".*")
++               (N_ "Option for config dialog command")
++               (N_ "long description will be here."))
++
++(define-custom 'mozc-tool-dictionary-tool-cmd "/usr/lib/mozc/mozc_tool"
++               '(mozc-tool)
++               '(pathname regular-file)
++               (N_ "Path of dictionary tool command")
++               (N_ "long description will be here."))
++
++(define-custom 'mozc-tool-dictionary-tool-cmd-option "--mode=dictionary_tool"
++               '(mozc-tool)
++               '(string ".*")
++               (N_ "Option for dictionary tool command")
++               (N_ "long description will be here."))
++
++(define-custom 'mozc-tool-word-register-dialog-cmd "/usr/lib/mozc/mozc_tool"
++               '(mozc-tool)
++               '(pathname regular-file)
++               (N_ "Path of word register dialog command")
++               (N_ "long description will be here."))
++
++(define-custom 'mozc-tool-word-register-dialog-cmd-option "--mode=word_register_dialog"
++               '(mozc-tool)
++               '(string ".*")
++               (N_ "Option for word register dialog command")
++               (N_ "long description will be here."))
++
++(define-custom 'mozc-tool-character-palette-cmd "/usr/lib/mozc/mozc_tool"
++               '(mozc-tool)
++               '(pathname regular-file)
++               (N_ "Path of character palette command")
++               (N_ "long description will be here."))
++
++(define-custom 'mozc-tool-character-palette-cmd-option "--mode=character_palette"
++               '(mozc-tool)
++               '(string ".*")
++               (N_ "Option for character palette command")
++               (N_ "long description will be here."))
++
++(define-custom 'mozc-tool-hand-writing-cmd "/usr/lib/mozc/mozc_tool"
++               '(mozc-tool)
++               '(pathname regular-file)
++               (N_ "Path of hand writing command")
++               (N_ "long description will be here."))
++
++(define-custom 'mozc-tool-hand-writing-cmd-option "--mode=hand_writing"
++               '(mozc-tool)
++               '(string ".*")
++               (N_ "Option for hand writing command")
++               (N_ "long description will be here."))
+diff --git a/src/unix/uim/scm/mozc-key-custom.scm b/src/unix/uim/scm/mozc-key-custom.scm
+new file mode 100644
+index 00000000..bcf85287
+--- /dev/null
++++ unix/uim/scm/mozc-key-custom.scm
+@@ -0,0 +1,74 @@
++;;;
++;;; Copyright (c) 2010-2012 uim Project http://code.google.com/p/uim/
++;;;
++;;; All rights reserved.
++;;;
++;;; Redistribution and use in source and binary forms, with or without
++;;; modification, are permitted provided that the following conditions
++;;; are met:
++;;; 1. Redistributions of source code must retain the above copyright
++;;;    notice, this list of conditions and the following disclaimer.
++;;; 2. Redistributions in binary form must reproduce the above copyright
++;;;    notice, this list of conditions and the following disclaimer in the
++;;;    documentation and/or other materials provided with the distribution.
++;;; 3. Neither the name of authors nor the names of its contributors
++;;;    may be used to endorse or promote products derived from this software
++;;;    without specific prior written permission.
++;;;
++;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
++;;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++;;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++;;; ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
++;;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++;;; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++;;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++;;; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++;;; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++;;; SUCH DAMAGE.
++;;;;
++
++(require "i18n.scm")
++
++(define-custom-group 'mozc-keys
++                   (_ "Mozc key bindings")
++                   (_ "long description will be here."))
++
++;;
++;; overriding generic keys
++;;
++(define-custom 'mozc-on-key '(generic-on-key)
++               '(mozc-keys)
++             '(key)
++             (_ "[Mozc] on")
++             (_ "long description will be here"))
++
++(define-custom 'mozc-off-key '(generic-off-key)
++               '(mozc-keys)
++             '(key)
++             (_ "[Mozc] off")
++             (_ "long description will be here"))
++
++(define-custom 'mozc-kana-toggle-key '()
++               '(mozc-keys)
++             '(key)
++             (_ "[Mozc] toggle hiragana/katakana mode")
++             (_ "long description will be here"))
++
++;;(define-custom 'mozc-cancel-key '(generic-cancel-key)
++;;               '(mozc-keys)
++;;           '(key)
++;;           (_ "[Mozc] cancel")
++;;           (_ "long description will be here"))
++;;
++;;(define-custom 'mozc-prev-segment-key '(generic-go-left-key)
++;;               '(mozc-keys)
++;;           '(key)
++;;           (_ "[Mozc] previous segment")
++;;           (_ "long description will be here"))
++
++(define-custom 'mozc-vi-escape-key '("escape" "<Control>[")
++               '(mozc-keys)
++             '(key)
++             (_ "[Mozc] ESC keys on vi-cooperative mode")
++             (_ "long description will be here"))
+diff --git a/src/unix/uim/scm/mozc.scm b/src/unix/uim/scm/mozc.scm
+new file mode 100644
+index 00000000..9938ec47
+--- /dev/null
++++ unix/uim/scm/mozc.scm
+@@ -0,0 +1,566 @@
++;;;
++;;; Copyright (c) 2010-2012 uim Project http://code.google.com/p/uim/
++;;;
++;;; All rights reserved.
++;;;
++;;; Redistribution and use in source and binary forms, with or without
++;;; modification, are permitted provided that the following conditions
++;;; are met:
++;;; 1. Redistributions of source code must retain the above copyright
++;;;    notice, this list of conditions and the following disclaimer.
++;;; 2. Redistributions in binary form must reproduce the above copyright
++;;;    notice, this list of conditions and the following disclaimer in the
++;;;    documentation and/or other materials provided with the distribution.
++;;; 3. Neither the name of authors nor the names of its contributors
++;;;    may be used to endorse or promote products derived from this software
++;;;    without specific prior written permission.
++;;;
++;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
++;;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++;;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++;;; ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
++;;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++;;; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++;;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++;;; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++;;; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++;;; SUCH DAMAGE.
++;;;;
++
++(require "util.scm")
++(require "process.scm")
++(require "japanese.scm")
++(require "ustr.scm")
++(require-custom "generic-key-custom.scm")
++(require-custom "mozc-custom.scm")
++(require-custom "mozc-key-custom.scm")
++
++;;; implementations
++
++(define mozc-type-direct          ja-type-direct)
++(define mozc-type-hiragana        ja-type-hiragana)
++(define mozc-type-katakana        ja-type-katakana)
++(define mozc-type-halfkana        ja-type-halfkana)
++(define mozc-type-halfwidth-alnum ja-type-halfwidth-alnum)
++(define mozc-type-fullwidth-alnum ja-type-fullwidth-alnum)
++
++(define mozc-input-rule-roma 0)
++(define mozc-input-rule-kana 1)
++
++(define mozc-prepare-input-mode-activation
++  (lambda (mc new-mode)
++    (let ((mid (mozc-context-mc-id mc)))
++      (if mid
++        (mozc-lib-set-input-mode mc mid new-mode)
++        #f))))
++
++(define mozc-prepare-input-rule-activation
++  (lambda (mc new-rule)
++    (let ((mid (mozc-context-mc-id mc)))
++      (if mid
++        (mozc-lib-set-input-rule mc mid new-rule)
++        #f))))
++
++(define (mozc-run-process file . args)
++  (let-optionals* args ((argv (list file)))
++    (let ((pid (process-fork)))
++      (cond ((< pid 0)
++             (begin
++               (uim-notify-fatal (N_ "cannot fork"))
++               #f))
++            ((= 0 pid) ;; child
++             (let ((pid2 (process-fork)))
++               (cond ((< pid2 0)
++                      (begin
++                        (uim-notify-fatal (N_ "cannot fork"))
++                        #f))
++                     ((= 0 pid2)
++                      (setenv "MALLOC_CHECK_" "0" 0)
++                      (setenv "GTK_IM_MODULE" "gtk-im-context-simple" 0)
++                      (if (= (process-execute file argv) -1)
++                        (uim-notify-fatal (format (N_ "cannot execute ~a") file)))
++                      (_exit 0))
++                     (else
++                       (_exit 0)))))
++            (else
++              (process-waitpid pid 0)
++              pid)))))
++
++(define mozc-tool-activate
++  (lambda (mc option)
++    (case option
++      ((mozc-tool-about-dialog)
++       (mozc-run-process mozc-tool-about-dialog-cmd (list mozc-tool-about-dialog-cmd mozc-tool-about-dialog-cmd-option)))
++      ((mozc-tool-config-dialog)
++       (mozc-run-process mozc-tool-config-dialog-cmd (list mozc-tool-config-dialog-cmd mozc-tool-config-dialog-cmd-option)))
++      ((mozc-tool-dictionary-tool)
++       (mozc-run-process mozc-tool-dictionary-tool-cmd (list mozc-tool-dictionary-tool-cmd mozc-tool-dictionary-tool-cmd-option)))
++      ((mozc-tool-word-register-dialog)
++       (mozc-run-process mozc-tool-word-register-dialog-cmd (list mozc-tool-word-register-dialog-cmd mozc-tool-word-register-dialog-cmd-option)))
++      ((mozc-tool-character-palette)
++       (mozc-run-process mozc-tool-character-palette-cmd (list mozc-tool-character-palette-cmd mozc-tool-character-palette-cmd-option)))
++      ((mozc-tool-hand-writing)
++       (mozc-run-process mozc-tool-hand-writing-cmd (list mozc-tool-hand-writing-cmd mozc-tool-hand-writing-cmd-option)))
++      (else
++        #f))))
++
++(define mozc-reconvert
++  (lambda (mc)
++    (let ((mid (mozc-context-mc-id mc)))
++      (if mid
++        (begin
++          (if (not (mozc-context-on mc))
++            (begin
++              (mozc-lib-set-on mid)
++              (mozc-context-set-on! mc #t)))
++          (mozc-lib-reconvert mc mid))
++        #f))))
++
++(register-action 'action_mozc_hiragana
++               (lambda (mc) ;; indication handler
++                   '(ja_hiragana
++                      "あ"
++                      "ひらがな"
++                      "ひらがな入力モード"))
++               (lambda (mc) ;; activity predicate
++                   (and
++                     (mozc-context-mc-id mc)
++                     (mozc-context-on mc)
++                   (= (mozc-lib-input-mode (mozc-context-mc-id mc)) mozc-type-hiragana)))
++               (lambda (mc) ;; action handler
++                   (mozc-prepare-input-mode-activation mc mozc-type-hiragana)))
++
++(register-action 'action_mozc_katakana
++               (lambda (mc)
++                   '(ja_katakana
++                      "ア"
++                      "カタカナ"
++                      "カタカナ入力モード"))
++               (lambda (mc)
++                   (and
++                     (mozc-context-mc-id mc)
++                     (mozc-context-on mc)
++                   (= (mozc-lib-input-mode (mozc-context-mc-id mc)) mozc-type-katakana)))
++               (lambda (mc)
++                   (mozc-prepare-input-mode-activation mc mozc-type-katakana)))
++
++(register-action 'action_mozc_halfkana
++               (lambda (mc)
++                   '(ja_halfkana
++                      "ア"
++                      "半角カタカナ"
++                      "半角カタカナ入力モード"))
++               (lambda (mc)
++                   (and
++                     (mozc-context-mc-id mc)
++                     (mozc-context-on mc)
++                   (= (mozc-lib-input-mode (mozc-context-mc-id mc)) mozc-type-halfkana)))
++               (lambda (mc)
++                   (mozc-prepare-input-mode-activation mc mozc-type-halfkana)))
++
++(register-action 'action_mozc_halfwidth_alnum
++               (lambda (mc)
++                   '(ja_halfwidth_alnum
++                      "a"
++                      "半角英数"
++                      "半角英数入力モード"))
++               (lambda (mc)
++                   (and
++                     (mozc-context-mc-id mc)
++                     (mozc-context-on mc)
++                   (= (mozc-lib-input-mode (mozc-context-mc-id mc)) mozc-type-halfwidth-alnum)))
++               (lambda (mc)
++                   (mozc-prepare-input-mode-activation mc mozc-type-halfwidth-alnum)))
++
++(register-action 'action_mozc_direct
++               (lambda (mc)
++                   '(ja_direct
++                      "-"
++                      "直接入力"
++                      "直接(無変換)入力モード"))
++               (lambda (mc)
++                 (not (mozc-context-on mc)))
++               (lambda (mc)
++                   (mozc-prepare-input-mode-activation mc mozc-type-direct)))
++
++(register-action 'action_mozc_fullwidth_alnum
++               (lambda (mc)
++                   '(ja_fullwidth_alnum
++                      "A"
++                      "全角英数"
++                      "全角英数入力モード"))
++               (lambda (mc)
++                   (and
++                     (mozc-context-mc-id mc)
++                     (mozc-context-on mc)
++                     (= (mozc-lib-input-mode (mozc-context-mc-id mc)) mozc-type-fullwidth-alnum)))
++               (lambda (mc)
++                   (mozc-prepare-input-mode-activation mc mozc-type-fullwidth-alnum)))
++
++(register-action 'action_mozc_roma
++;;               (indication-alist-indicator 'action_mozc_roma
++;;                                           mozc-kana-input-method-indication-alist)
++                 (lambda (mc)
++                   '(ja_romaji
++                     "R"
++                     "ローマ字"
++                     "ローマ字入力モード"))
++                 (lambda (mc)
++                   (and (mozc-context-mc-id mc)
++                        (= (mozc-lib-input-rule (mozc-context-mc-id mc))
++                           mozc-input-rule-roma)))
++                 (lambda (mc)
++                   (mozc-prepare-input-rule-activation mc mozc-input-rule-roma)
++))
++
++(register-action 'action_mozc_kana
++;;               (indication-alist-indicator 'action_mozc_kana
++;;                                           mozc-kana-input-method-indication-alist)
++                 (lambda (mc)
++                   '(ja_kana
++                     "か"
++                     "かな"
++                     "かな入力モード"))
++                 (lambda (mc)
++                   (and (mozc-context-mc-id mc)
++                        (= (mozc-lib-input-rule (mozc-context-mc-id mc))
++                           mozc-input-rule-kana)))
++                 (lambda (mc)
++                   (mozc-prepare-input-rule-activation mc mozc-input-rule-kana)
++                   ))
++
++(register-action 'action_mozc_tool_selector
++;;               (indication-alist-indicator 'action_mozc_tool_selector
++;;                                           mozc-tool-indication-alist)
++                 (lambda (mc)
++                   '(mozc_tool_selector
++                     "M"
++                     "MozcTool selector"
++                     "MozcTool selector"))
++                 (lambda (mc)
++                   #t)
++                 (lambda (mc)
++                   #f))
++
++(register-action 'action_mozc_tool_about_dialog
++;;               (indication-alist-indicator 'action_mozc_tool_about_dialog
++;;                                           mozc-tool-indication-alist)
++                 (lambda (mc)
++                   '(mozc_tool_about_dialog
++                     "A"
++                     "About"
++                     "About Mozc"))
++                 (lambda (mc)
++                   #f)
++                 (lambda (mc)
++                   (mozc-tool-activate mc 'mozc-tool-about-dialog)))
++
++(register-action 'action_mozc_tool_config_dialog
++;;               (indication-alist-indicator 'action_mozc_tool_config_dialog
++;;                                           mozc-tool-indication-alist)
++                 (lambda (mc)
++                   '(mozc_tool_config_dialog
++                     "C"
++                     "Config dialog"
++                     "Config dialog"))
++                 (lambda (mc)
++                   #f)
++                 (lambda (mc)
++                   (mozc-tool-activate mc 'mozc-tool-config-dialog)))
++
++(register-action 'action_mozc_tool_dictionary_tool
++;;               (indication-alist-indicator 'action_mozc_tool_dictionary_tool
++;;                                           mozc-tool-indication-alist)
++                 (lambda (mc)
++                   '(mozc_tool_dictionary_tool
++                     "D"
++                     "Dictionary tool"
++                     "Dictionary tool"))
++                 (lambda (mc)
++                   #f)
++                 (lambda (mc)
++                   (mozc-tool-activate mc 'mozc-tool-dictionary-tool)))
++
++(register-action 'action_mozc_tool_word_register_dialog
++;;               (indication-alist-indicator 'action_mozc_tool_word_register_dialog
++;;                                           mozc-tool-indication-alist)
++                 (lambda (mc)
++                   '(mozc_tool_word_register_dialog
++                     "W"
++                     "Word register dialog"
++                     "Word register dialog"))
++                 (lambda (mc)
++                   #f)
++                 (lambda (mc)
++                   (mozc-tool-activate mc 'mozc-tool-word-register-dialog)))
++
++(register-action 'action_mozc_tool_character_palette
++;;               (indication-alist-indicator 'action_mozc_tool_character_palette
++;;                                           mozc-tool-indication-alist)
++                 (lambda (mc)
++                   '(mozc_tool_character_palette
++                     "W"
++                     "Character palette"
++                     "Character palette"))
++                 (lambda (mc)
++                   #f)
++                 (lambda (mc)
++                   (mozc-tool-activate mc 'mozc-tool-character-palette)))
++
++(register-action 'action_mozc_tool_hand_writing
++;;               (indication-alist-indicator 'action_mozc_tool_hand_writing
++;;                                           mozc-tool-indication-alist)
++                 (lambda (mc)
++                   '(mozc_tool_hand_writing
++                     "W"
++                     "Hand writing"
++                     "Hand writing"))
++                 (lambda (mc)
++                   #f)
++                 (lambda (mc)
++                   (mozc-tool-activate mc 'mozc-tool-hand-writing)))
++
++(register-action 'action_mozc_reconvert
++;;               (indication-alist-indicator 'action_mozc_reconvert
++;;                                           mozc-tool-indication-alist)
++                 (lambda (mc)
++                   '(mozc_reconvert
++                     "R"
++                     "Reconvert"
++                     "Reconvert"))
++                 (lambda (mc)
++                   #f)
++                 (lambda (mc)
++                   (mozc-reconvert mc)))
++
++;; Update widget definitions based on action configurations. The
++;; procedure is needed for on-the-fly reconfiguration involving the
++;; custom API
++(define mozc-configure-widgets
++  (lambda ()
++    (register-widget 'widget_mozc_input_mode
++                   (activity-indicator-new mozc-input-mode-actions)
++                   (actions-new mozc-input-mode-actions))
++    (register-widget 'widget_mozc_kana_input_method
++                   (activity-indicator-new mozc-kana-input-method-actions)
++                   (actions-new mozc-kana-input-method-actions))
++    (register-widget 'widget_mozc_tool
++                   (activity-indicator-new mozc-tool-actions)
++                   (actions-new (remove (lambda (x) (eq? x 'action_mozc_tool_selector)) mozc-tool-actions)))
++    (context-list-replace-widgets! 'mozc mozc-widgets)))
++
++(define mozc-context-rec-spec
++  (append
++   context-rec-spec
++   ;; renamed from 'id' to avoid conflict with context-id
++   (list
++     (list 'mc-id             #f)
++     (list 'on                #f))))
++(define-record 'mozc-context mozc-context-rec-spec)
++(define mozc-context-new-internal mozc-context-new)
++
++(define mozc-context-new
++  (lambda (id im name)
++    (let* ((mc (mozc-context-new-internal id im))
++           (mid (if (symbol-bound? 'mozc-lib-alloc-context)
++                    (if (= (getuid) 0)
++                        #f
++                        (mozc-lib-alloc-context mc))
++                    (begin
++                      (uim-notify-info
++                       (N_ "libuim-mozc.so couldn't be loaded"))
++                      #f))))
++      (mozc-context-set-widgets! mc mozc-widgets)
++      (mozc-context-set-mc-id! mc mid)
++      mc)))
++
++(define mozc-separator
++  (lambda ()
++    (let ((attr (bitwise-ior preedit-separator
++                             preedit-underline)))
++      (if mozc-show-segment-separator?
++        (cons attr mozc-segment-separator)
++        #f))))
++
++(define mozc-proc-direct-state
++  (lambda (mc key key-state)
++   (if (mozc-on-key? key key-state)
++     (let ((mid (mozc-context-mc-id mc)))
++       (if mid
++         (mozc-lib-set-on mid))
++       (mozc-context-set-on! mc #t))
++     (im-commit-raw mc))))
++
++(define mozc-init-handler
++  (lambda (id im arg)
++    (mozc-context-new id im arg)))
++
++(define mozc-release-handler
++  (lambda (mc)
++    (let ((mid (mozc-context-mc-id mc)))
++      (if mid
++        (mozc-lib-free-context mid)
++        #f)
++    #f)))
++
++(define mozc-transpose-keys
++  (lambda (mid key key-state)
++    (let ((new (cons key key-state)))
++      ;; Since mozc_tool is now available, these key transposings
++      ;; are not needed usually.
++      ;;(if (mozc-lib-has-preedit? mid)
++      ;;  (cond
++      ;;    ((mozc-cancel-key? key key-state)
++      ;;     (set-car! new 'escape)
++      ;;     (set-cdr! new 0))
++      ;;    ((mozc-prev-segment-key? key key-state)
++      ;;     (set-car! new 'left)
++      ;;     (set-cdr! new 0))))
++      new)))
++
++(define mozc-kana-toggle
++  (lambda (mc mid)
++    (if mid
++      (let ((mode (mozc-lib-input-mode mid)))
++        (cond
++          ((= mode mozc-type-hiragana)
++           (mozc-lib-set-input-mode mc mid mozc-type-katakana))
++          ((= mode mozc-type-katakana)
++           (mozc-lib-set-input-mode mc mid mozc-type-hiragana))
++          (else
++            #f)))
++      #f)))
++
++(define mozc-proc-input-state
++  (lambda (mc key key-state)
++    (if (ichar-control? key)
++      (im-commit-raw mc)
++      (let ((mid (mozc-context-mc-id mc)))
++        (cond
++          ((and
++             mid
++             (mozc-off-key? key key-state)
++             (not (mozc-lib-has-preedit? mid)))
++           (mozc-lib-set-input-mode mc mid mozc-type-direct))
++          ;; non available modifiers on Mozc
++          ((or
++             (meta-key-mask key-state)
++             (super-key-mask key-state)
++             (hyper-key-mask key-state))
++           (if (and mid
++                    (mozc-lib-has-preedit? mid))
++             #f ;; ignore
++             (im-commit-raw mc))) ;; pass through
++          (else
++            (or
++              (and
++                (mozc-kana-toggle-key? key key-state)
++                (mozc-kana-toggle mc mid))
++              (let* ((new (mozc-transpose-keys mid key key-state))
++                     (nkey (car new))
++                     (nkey-state (cdr new)))
++                (if (and mid
++                         (mozc-lib-press-key mc mid (if (symbol? nkey)
++                                                      (keysym-to-int nkey) nkey)
++                                             nkey-state))
++                  #f ; Key event is consumed
++                  (begin
++                    (and mid
++                         mozc-use-with-vi?
++                         (mozc-vi-escape-key? key key-state)
++                         (mozc-lib-set-input-mode mc mid mozc-type-direct))
++                    (im-commit-raw mc)))))))))))
++
++(define mozc-press-key-handler
++  (lambda (mc key key-state)
++    (if (mozc-context-on mc)
++      (mozc-proc-input-state mc key key-state)
++      (mozc-proc-direct-state mc key key-state))))
++
++(define mozc-release-key-handler
++  (lambda (mc key key-state)
++    (if (or (ichar-control? key)
++            (not (mozc-context-on mc)))
++      (im-commit-raw mc))))
++
++(define mozc-reset-handler
++  (lambda (mc)
++    (let ((mid (mozc-context-mc-id mc)))
++      (and mid
++           (mozc-lib-reset mid)))))
++
++(define mozc-focus-in-handler
++  (lambda (mc)
++    (let ((mid (mozc-context-mc-id mc)))
++      ;(mozc-lib-focus-in mid)
++      )))
++
++(define mozc-focus-out-handler
++  (lambda (mc)
++    (let ((mid (mozc-context-mc-id mc)))
++      ;(mozc-lib-focus-out mid)
++      )))
++
++(define mozc-displace-handler
++  (lambda (mc)
++    (let ((mid (mozc-context-mc-id mc)))
++      (and mid
++           (mozc-lib-submit-composition mc mid)))))
++
++(define mozc-get-candidate-handler
++  (lambda (mc idx accel-enum-hint)
++    (let* ((mid (mozc-context-mc-id mc))
++         (cand
++             (mozc-lib-get-nth-candidate mid idx))
++           (label
++             (mozc-lib-get-nth-label mid idx))
++           (annotation
++             (mozc-lib-get-nth-annotation mid idx)))
++      (list cand label annotation))))
++
++(define mozc-set-candidate-index-handler
++  (lambda (mc idx)
++    (let ((mid (mozc-context-mc-id mc)))
++      (mozc-lib-set-candidate-index mc mid idx))))
++
++(define mozc-check-uim-version
++  (lambda (request-major request-minor request-patch)
++    (let* ((version (string-split (uim-version) "."))
++           (len (length version))
++           (major (if (>= len 1) (string->number (list-ref version 0)) 0))
++           (minor (if (>= len 2) (string->number (list-ref version 1)) 0))
++           (patch (if (>= len 3) (string->number (list-ref version 2)) 0)))
++      (or (> major request-major)
++          (and
++            (= major request-major)
++            (> minor request-minor))
++          (and
++            (= major request-major)
++            (= minor request-minor)
++            (>= patch request-patch))))))
++
++(mozc-configure-widgets)
++
++(register-im
++  'mozc
++  "ja"
++  "UTF-8"
++  mozc-im-name-label
++  mozc-im-short-desc
++  #f
++  mozc-init-handler
++  mozc-release-handler
++  context-mode-handler
++  mozc-press-key-handler
++  mozc-release-key-handler
++  mozc-reset-handler
++  mozc-get-candidate-handler
++  mozc-set-candidate-index-handler
++  context-prop-activate-handler
++  #f
++  #f ;mozc-focus-in-handler
++  #f ;mozc-focus-out-handler
++  #f
++  mozc-displace-handler
++)
+diff --git a/src/unix/uim/uim.gyp b/src/unix/uim/uim.gyp
+new file mode 100644
+index 00000000..bb1c602f
+--- /dev/null
++++ unix/uim/uim.gyp
+@@ -0,0 +1,85 @@
++#
++# Copyright (c) 2010-2012 uim Project http://code.google.com/p/uim/
++#
++# All rights reserved.
++#
++# Redistribution and use in source and binary forms, with or without
++# modification, are permitted provided that the following conditions
++# are met:
++# 1. Redistributions of source code must retain the above copyright
++#    notice, this list of conditions and the following disclaimer.
++# 2. Redistributions in binary form must reproduce the above copyright
++#    notice, this list of conditions and the following disclaimer in the
++#    documentation and/or other materials provided with the distribution.
++# 3. Neither the name of authors nor the names of its contributors
++#    may be used to endorse or promote products derived from this software
++#    without specific prior written permission.
++#
++# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
++# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++# ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
++# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++# SUCH DAMAGE.
++#
++
++{
++  'variables': {
++    'relative_dir': 'unix/uim',
++    'pkg_config_libs': [
++      'uim',
++    ],
++    'uim_dep_include_dirs': [
++    ],
++    'uim_dependencies': [
++      '../../base/base.gyp:base',
++      '../../client/client.gyp:client',
++    ],
++  },
++  'targets': [
++    {
++      'target_name': 'uim_mozc_lib',
++      'type': 'static_library',
++      'sources': [
++        'key_translator.cc',
++      ],
++      'dependencies': [
++        '../../protocol/protocol.gyp:commands_proto',
++      ],
++      'cflags': [
++        '<!@(pkg-config --cflags <@(pkg_config_libs))',
++      ],
++      'include_dirs': [
++        '<@(uim_dep_include_dirs)',
++      ],
++    },
++    {
++      'target_name': 'uim-mozc',
++      'type': 'loadable_module',
++      'sources': [
++        'mozc.cc',
++      ],
++      'dependencies': [
++        '<@(uim_dependencies)',
++        'uim_mozc_lib',
++      ],
++      'cflags': [
++        '<!@(pkg-config --cflags <@(pkg_config_libs))',
++      ],
++      'include_dirs': [
++        '<@(uim_dep_include_dirs)',
++      ],
++      'libraries': [
++        '<!@(pkg-config --libs-only-l <@(pkg_config_libs))',
++      ],
++      'ldflags': [
++        '<!@(pkg-config --libs-only-L <@(pkg_config_libs))',
++      ],
++    },
++  ],
++}
+-- 
+2.30.0.rc2
+
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-unix_ibus_ibus.gyp
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-unix_ibus_ibus.gyp:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-unix_ibus_ibus.gyp  Sat Feb 10 01:20:47 2024
@@ -0,0 +1,17 @@
+$NetBSD: patch-unix_ibus_ibus.gyp,v 1.1 2024/02/10 01:20:47 ryoon Exp $
+
+* use ${PREFIX} paths
+
+--- unix/ibus/ibus.gyp.orig    2017-11-02 13:32:47.000000000 +0000
++++ unix/ibus/ibus.gyp
+@@ -31,8 +31,8 @@
+   'variables': {
+     'relative_dir': 'unix/ibus',
+     'gen_out_dir': '<(SHARED_INTERMEDIATE_DIR)/<(relative_dir)',
+-    'ibus_mozc_icon_path%': '/usr/share/ibus-mozc/product_icon.png',
+-    'ibus_mozc_path%': '/usr/lib/ibus-mozc/ibus-engine-mozc',
++    'ibus_mozc_icon_path%': '@PREFIX@/share/ibus-mozc/product_icon.png',
++    'ibus_mozc_path%': '@PREFIX@/libexec/ibus-engine-mozc',
+     # enable_x11_selection_monitor represents if ibus_mozc uses X11 selection
+     # monitor or not.
+     'enable_x11_selection_monitor%': 1,
Index: pkgsrc/inputmethod/mozc-server226/patches/patch-unix_ibus_path__util.cc
diff -u /dev/null pkgsrc/inputmethod/mozc-server226/patches/patch-unix_ibus_path__util.cc:1.1
--- /dev/null   Sat Feb 10 01:20:47 2024
+++ pkgsrc/inputmethod/mozc-server226/patches/patch-unix_ibus_path__util.cc     Sat Feb 10 01:20:47 2024
@@ -0,0 +1,15 @@
+$NetBSD: patch-unix_ibus_path__util.cc,v 1.1 2024/02/10 01:20:47 ryoon Exp $
+
+* use ${PREFIX} path
+
+--- unix/ibus/path_util.cc.orig        2017-11-02 13:32:47.000000000 +0000
++++ unix/ibus/path_util.cc
+@@ -30,7 +30,7 @@
+ #include "unix/ibus/path_util.h"
+ 
+ namespace {
+-const char kInstalledDirectory[] = "/usr/share/ibus-mozc";
++const char kInstalledDirectory[] = "@PREFIX@/share/ibus-mozc";
+ }
+ 
+ namespace mozc {



Home | Main Index | Thread Index | Old Index