Merge tag 'upstream/0.3.1'
Upstream version 0.3.1
Conflicts:
.gitignore
YunQiang Su
11 years ago
1 | 1 | cmake_minimum_required(VERSION 2.6) |
2 | 2 | |
3 | 3 | set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) |
4 | find_package(Fcitx 4.2.6 REQUIRED) | |
4 | find_package(Fcitx 4.2.7 REQUIRED) | |
5 | 5 | find_package(PkgConfig REQUIRED) |
6 | find_package(Gettext REQUIRED) | |
7 | 6 | find_package(Libintl REQUIRED) |
8 | 7 | find_package(Libiconv REQUIRED) |
9 | 8 | find_package(Pthread REQUIRED) |
10 | 9 | |
11 | # uninstall target | |
12 | configure_file( | |
13 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" | |
14 | "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" | |
15 | IMMEDIATE @ONLY) | |
10 | _fcitx_add_uninstall_target() | |
16 | 11 | |
17 | 12 | set(CMAKE_C_FLAGS "-Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -fvisibility=hidden ${CMAKE_C_FLAGS}") |
18 | 13 | set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -fvisibility=hidden ${CMAKE_CXX_FLAGS}") |
19 | 14 | set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed ${CMAKE_SHARED_LINKER_FLAGS}") |
20 | 15 | set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--as-needed ${CMAKE_MODULE_LINKER_FLAGS}") |
21 | ||
22 | add_custom_target(uninstall | |
23 | COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) | |
24 | 16 | |
25 | 17 | pkg_check_modules(CURL "libcurl" REQUIRED) |
26 | 18 | |
30 | 22 | |
31 | 23 | enable_testing() |
32 | 24 | |
25 | add_subdirectory(po) | |
33 | 26 | add_subdirectory(src) |
34 | add_subdirectory(po) | |
35 | add_subdirectory(test)⏎ | |
27 | add_subdirectory(test) |
1 | 1 | Version 2, June 1991 |
2 | 2 | |
3 | 3 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. |
4 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
4 | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
5 | 5 | Everyone is permitted to copy and distribute verbatim copies |
6 | 6 | of this license document, but changing it is not allowed. |
7 | 7 | |
304 | 304 | |
305 | 305 | You should have received a copy of the GNU General Public License |
306 | 306 | along with this program; if not, write to the Free Software |
307 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
307 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
308 | 308 | |
309 | 309 | |
310 | 310 | Also add information on how to contact you by electronic and paper mail. |
0 | this is a standalone module for fcitx, it can use pinyin API on the internet | |
1 | to input. | |
2 | ||
3 | Requires Fcitx 4.1.0 (Currently is not released). | |
0 | Fcitx-Cloudpinyin is a standalone module for fcitx that uses web API to provide better pinyin result. |
8 | 8 | # present in libc. Must have more robust system for release, where Gettext |
9 | 9 | # functionality can also reside in standalone Gettext library, or the one |
10 | 10 | # embedded within kdelibs (cf. gettext.m4 from Gettext source). |
11 | ||
11 | ||
12 | 12 | # Copyright (c) 2006, Chusslove Illich, <caslav.ilic@gmx.net> |
13 | 13 | # Copyright (c) 2007, Alexander Neundorf, <neundorf@kde.org> |
14 | 14 | # |
15 | 15 | # Redistribution and use is allowed according to the terms of the BSD license. |
16 | 16 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. |
17 | ||
17 | ||
18 | 18 | if(LIBINTL_INCLUDE_DIR AND LIBINTL_LIB_FOUND) |
19 | 19 | set(Libintl_FIND_QUIETLY TRUE) |
20 | endif(LIBINTL_INCLUDE_DIR AND LIBINTL_LIB_FOUND) | |
21 | ||
20 | endif() | |
21 | ||
22 | 22 | find_path(LIBINTL_INCLUDE_DIR libintl.h) |
23 | ||
23 | ||
24 | 24 | set(LIBINTL_LIB_FOUND FALSE) |
25 | ||
25 | ||
26 | 26 | if(LIBINTL_INCLUDE_DIR) |
27 | 27 | include(CheckFunctionExists) |
28 | 28 | check_function_exists(dgettext LIBINTL_LIBC_HAS_DGETTEXT) |
29 | ||
30 | if (LIBINTL_LIBC_HAS_DGETTEXT) | |
29 | ||
30 | if(LIBINTL_LIBC_HAS_DGETTEXT) | |
31 | 31 | set(LIBINTL_LIBRARIES) |
32 | 32 | set(LIBINTL_LIB_FOUND TRUE) |
33 | else (LIBINTL_LIBC_HAS_DGETTEXT) | |
34 | find_library(LIBINTL_LIBRARIES NAMES intl libintl ) | |
33 | else() | |
34 | find_library(LIBINTL_LIBRARIES NAMES intl libintl) | |
35 | 35 | if(LIBINTL_LIBRARIES) |
36 | 36 | set(LIBINTL_LIB_FOUND TRUE) |
37 | endif(LIBINTL_LIBRARIES) | |
38 | endif (LIBINTL_LIBC_HAS_DGETTEXT) | |
39 | ||
37 | endif() | |
38 | endif() | |
40 | 39 | endif(LIBINTL_INCLUDE_DIR) |
41 | ||
40 | ||
42 | 41 | include(FindPackageHandleStandardArgs) |
43 | find_package_handle_standard_args(Libintl DEFAULT_MSG LIBINTL_INCLUDE_DIR LIBINTL_LIB_FOUND) | |
44 | ||
45 | mark_as_advanced(LIBINTL_INCLUDE_DIR LIBINTL_LIBRARIES LIBINTL_LIBC_HAS_DGETTEXT LIBINTL_LIB_FOUND)⏎ | |
42 | find_package_handle_standard_args(Libintl DEFAULT_MSG LIBINTL_INCLUDE_DIR | |
43 | LIBINTL_LIB_FOUND) | |
44 | ||
45 | mark_as_advanced(LIBINTL_INCLUDE_DIR LIBINTL_LIBRARIES | |
46 | LIBINTL_LIBC_HAS_DGETTEXT LIBINTL_LIB_FOUND) |
0 | file(GLOB PO_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.po) | |
1 | file(RELATIVE_PATH REL_SOURCE_ROOT ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}) | |
2 | if ("${REL_SOURCE_ROOT}" STREQUAL "") | |
3 | set(REL_SOURCE_ROOT ".") | |
4 | endif("${REL_SOURCE_ROOT}" STREQUAL "") | |
5 | ||
6 | set(POT_FILE fcitx-cloudpinyin.pot) | |
7 | ||
8 | configure_file(POTFILES.in.in ${CMAKE_CURRENT_BINARY_DIR}/POTFILES.in) | |
9 | ||
10 | extract_fcitx_addon_conf_postring() | |
11 | extract_fcitx_desc_file_postring() | |
12 | ||
13 | add_custom_target( | |
14 | pot | |
15 | COMMAND INTLTOOL_EXTRACT=${INTLTOOL_EXTRACT} srcdir=${CMAKE_CURRENT_BINARY_DIR} ${INTLTOOL_UPDATE} --gettext-package fcitx-cloudpinyin --pot | |
16 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | |
17 | DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/conf.po ${CMAKE_CURRENT_BINARY_DIR}/desc.po | |
18 | ) | |
19 | ||
20 | # Update .po files and compile them to binary .gmo files | |
21 | gettext_create_translations(${POT_FILE} ALL ${PO_FILES}) | |
22 | ||
0 | set(PO_LANGS zh_CN zh_TW) | |
1 | foreach(lang ${PO_LANGS}) | |
2 | fcitx_translate_add_po_file("${lang}" "${lang}.po") | |
3 | endforeach() | |
4 | fcitx_translate_set_pot_target(pot fcitx-cloudpinyin fcitx-cloudpinyin.pot) |
0 | # List of source files which contain translatable strings. | |
1 | ./po/desc.po | |
2 | ./po/conf.po | |
3 | @REL_SOURCE_ROOT@/src/cloudpinyin.c | |
4 | @REL_SOURCE_ROOT@/src/fcitx-cloudpinyin.conf.in⏎ |
6 | 6 | msgid "" |
7 | 7 | msgstr "" |
8 | 8 | "Project-Id-Version: PACKAGE VERSION\n" |
9 | "Report-Msgid-Bugs-To: \n" | |
10 | "POT-Creation-Date: 2012-08-29 18:07-0400\n" | |
9 | "Report-Msgid-Bugs-To: fcitx-dev@googlegroups.com\n" | |
10 | "POT-Creation-Date: 2012-12-01 18:57-0500\n" | |
11 | 11 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
12 | 12 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
13 | 13 | "Language-Team: LANGUAGE <LL@li.org>\n" |
14 | "Language: \n" | |
14 | "Language: LANG\n" | |
15 | 15 | "MIME-Version: 1.0\n" |
16 | "Content-Type: text/plain; charset=CHARSET\n" | |
16 | "Content-Type: text/plain; charset=utf-8\n" | |
17 | 17 | "Content-Transfer-Encoding: 8bit\n" |
18 | 18 | |
19 | #: /home/saber/Develop/fcitx-cloudpinyin/src/fcitx-cloudpinyin.desc:5 | |
19 | #: src/cloudpinyin.c:607 | |
20 | msgid " (via cloud)" | |
21 | msgstr "" | |
22 | ||
23 | #: src/fcitx-cloudpinyin.conf.in:3 | |
24 | msgid "Cloud Pinyin" | |
25 | msgstr "" | |
26 | ||
27 | #: src/fcitx-cloudpinyin.conf.in:4 | |
28 | msgid "Add Cloud Pinyin Support to Pinyin Input Method" | |
29 | msgstr "" | |
30 | ||
31 | #: src/fcitx-cloudpinyin.desc:1 src/fcitx-cloudpinyin.desc:7 | |
32 | #: src/fcitx-cloudpinyin.desc:13 src/fcitx-cloudpinyin.desc:18 | |
33 | msgid "CloudPinyin" | |
34 | msgstr "" | |
35 | ||
36 | #: src/fcitx-cloudpinyin.desc:5 | |
20 | 37 | msgid "Cloud Pinyin Candidate Word Order" |
21 | 38 | msgstr "" |
22 | 39 | |
23 | #: /home/saber/Develop/fcitx-cloudpinyin/src/fcitx-cloudpinyin.desc:11 | |
40 | #: src/fcitx-cloudpinyin.desc:11 | |
24 | 41 | msgid "Minimum Length of Pinyin To Trigger Cloud Pinyin" |
25 | 42 | msgstr "" |
26 | 43 | |
27 | #: /home/saber/Develop/fcitx-cloudpinyin/src/fcitx-cloudpinyin.desc:16 | |
44 | #: src/fcitx-cloudpinyin.desc:16 | |
28 | 45 | msgid "Don't Show the 'via cloud' hint" |
29 | 46 | msgstr "" |
30 | 47 | |
31 | #: /home/saber/Develop/fcitx-cloudpinyin/src/fcitx-cloudpinyin.desc:21 | |
48 | #: src/fcitx-cloudpinyin.desc:21 | |
32 | 49 | msgid "Cloud Pinyin Source" |
33 | 50 | msgstr "" |
34 | 51 | |
35 | # unknown | |
36 | msgid "CloudPinyin" | |
52 | #: src/fcitx-cloudpinyin.desc:23 | |
53 | msgid "Sogou" | |
37 | 54 | msgstr "" |
38 | 55 | |
39 | #: unknown | |
40 | msgid "Baidu" | |
56 | #: src/fcitx-cloudpinyin.desc:24 | |
57 | msgid "QQ" | |
41 | 58 | msgstr "" |
42 | 59 | |
43 | #: unknown | |
60 | #: src/fcitx-cloudpinyin.desc:25 | |
44 | 61 | msgid "Google" |
45 | 62 | msgstr "" |
46 | 63 | |
47 | #: unknown | |
48 | msgid "QQ" | |
64 | #: src/fcitx-cloudpinyin.desc:26 | |
65 | msgid "Baidu" | |
49 | 66 | msgstr "" |
50 | ||
51 | #: unknown | |
52 | msgid "Sogou" | |
53 | msgstr "" | |
54 | ||
55 | #: /home/saber/Develop/fcitx-cloudpinyin/build/po/tmp/fcitx-cloudpinyin.conf.in.h:1 | |
56 | msgid "Cloud Pinyin" | |
57 | msgstr "" | |
58 | ||
59 | #: /home/saber/Develop/fcitx-cloudpinyin/build/po/tmp/fcitx-cloudpinyin.conf.in.h:2 | |
60 | msgid "Add Cloud Pinyin Support to Pinyin Input Method" | |
61 | msgstr "" | |
62 | ||
63 | #: /home/saber/Develop/fcitx-cloudpinyin/build/po/../..//src/cloudpinyin.c:588 | |
64 | msgid " (via cloud)" | |
65 | msgstr "" |
0 | 0 | # SOME DESCRIPTIVE TITLE. |
1 | 1 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER |
2 | 2 | # This file is distributed under the same license as the PACKAGE package. |
3 | # | |
3 | # | |
4 | 4 | # Translators: |
5 | # Christopher Meng <cickumqt@gmail.com>, 2012. | |
5 | 6 | # Weng Xuetian <wengxt@gmail.com>, 2011. |
6 | 7 | msgid "" |
7 | 8 | msgstr "" |
8 | 9 | "Project-Id-Version: fcitx\n" |
9 | "Report-Msgid-Bugs-To: \n" | |
10 | "POT-Creation-Date: 2012-08-29 18:07-0400\n" | |
11 | "PO-Revision-Date: 2012-08-29 20:00-0400\n" | |
12 | "Last-Translator: Yichao Yu <yyc1992@gmail.com>\n" | |
10 | "Report-Msgid-Bugs-To: fcitx-dev@googlegroups.com\n" | |
11 | "POT-Creation-Date: 2012-12-01 18:57-0500\n" | |
12 | "PO-Revision-Date: 2012-09-02 06:46+0000\n" | |
13 | "Last-Translator: Xuetian Weng <wengxt@gmail.com>\n" | |
13 | 14 | "Language-Team: Chinese (China) <fcitx-dev@googlegroups.com>\n" |
14 | "Language: zh_CN\n" | |
15 | 15 | "MIME-Version: 1.0\n" |
16 | 16 | "Content-Type: text/plain; charset=UTF-8\n" |
17 | 17 | "Content-Transfer-Encoding: 8bit\n" |
18 | "Plural-Forms: nplurals=1; plural=0\n" | |
18 | "Language: zh_CN\n" | |
19 | "Plural-Forms: nplurals=1; plural=0;\n" | |
19 | 20 | |
20 | #: /home/saber/Develop/fcitx-cloudpinyin/build/po/../..//src/cloudpinyin.c:588 | |
21 | #: src/cloudpinyin.c:607 | |
21 | 22 | msgid " (via cloud)" |
22 | 23 | msgstr " (来自云)" |
23 | 24 | |
24 | #: /home/saber/Develop/fcitx-cloudpinyin/build/po/tmp/fcitx-cloudpinyin.conf.in.h:2 | |
25 | #: src/fcitx-cloudpinyin.conf.in:3 | |
26 | msgid "Cloud Pinyin" | |
27 | msgstr "云拼音" | |
28 | ||
29 | #: src/fcitx-cloudpinyin.conf.in:4 | |
25 | 30 | msgid "Add Cloud Pinyin Support to Pinyin Input Method" |
26 | 31 | msgstr "为拼音输入法加入云拼音支持" |
27 | 32 | |
28 | #: unknown | |
29 | msgid "Baidu" | |
30 | msgstr "百度" | |
31 | ||
32 | #: /home/saber/Develop/fcitx-cloudpinyin/build/po/tmp/fcitx-cloudpinyin.conf.in.h:1 | |
33 | msgid "Cloud Pinyin" | |
33 | #: src/fcitx-cloudpinyin.desc:1 src/fcitx-cloudpinyin.desc:7 | |
34 | #: src/fcitx-cloudpinyin.desc:13 src/fcitx-cloudpinyin.desc:18 | |
35 | msgid "CloudPinyin" | |
34 | 36 | msgstr "云拼音" |
35 | 37 | |
36 | #: /home/saber/Develop/fcitx-cloudpinyin/src/fcitx-cloudpinyin.desc:5 | |
38 | #: src/fcitx-cloudpinyin.desc:5 | |
37 | 39 | msgid "Cloud Pinyin Candidate Word Order" |
38 | 40 | msgstr "云拼音候选词顺序" |
39 | 41 | |
40 | #: /home/saber/Develop/fcitx-cloudpinyin/src/fcitx-cloudpinyin.desc:21 | |
42 | #: src/fcitx-cloudpinyin.desc:11 | |
43 | msgid "Minimum Length of Pinyin To Trigger Cloud Pinyin" | |
44 | msgstr "最小触发云拼音的拼音长度" | |
45 | ||
46 | #: src/fcitx-cloudpinyin.desc:16 | |
47 | msgid "Don't Show the 'via cloud' hint" | |
48 | msgstr "不显示‘来自云’提示" | |
49 | ||
50 | #: src/fcitx-cloudpinyin.desc:21 | |
41 | 51 | msgid "Cloud Pinyin Source" |
42 | 52 | msgstr "云拼音来源" |
43 | 53 | |
44 | # unknown | |
45 | msgid "CloudPinyin" | |
46 | msgstr "云拼音" | |
54 | #: src/fcitx-cloudpinyin.desc:23 | |
55 | msgid "Sogou" | |
56 | msgstr "搜狗" | |
47 | 57 | |
48 | #: /home/saber/Develop/fcitx-cloudpinyin/src/fcitx-cloudpinyin.desc:16 | |
49 | msgid "Don't Show the 'via cloud' hint" | |
50 | msgstr "不显示‘来自云’提示" | |
58 | #: src/fcitx-cloudpinyin.desc:24 | |
59 | msgid "QQ" | |
60 | msgstr "QQ" | |
51 | 61 | |
52 | #: unknown | |
62 | #: src/fcitx-cloudpinyin.desc:25 | |
53 | 63 | msgid "Google" |
54 | 64 | msgstr "Google" |
55 | 65 | |
56 | #: /home/saber/Develop/fcitx-cloudpinyin/src/fcitx-cloudpinyin.desc:11 | |
57 | msgid "Minimum Length of Pinyin To Trigger Cloud Pinyin" | |
58 | msgstr "最小触发云拼音的拼音长度" | |
59 | ||
60 | #: unknown | |
61 | msgid "QQ" | |
62 | msgstr "QQ" | |
63 | ||
64 | #: unknown | |
65 | msgid "Sogou" | |
66 | msgstr "搜狗" | |
67 | ||
68 | #~ msgid "Only use origin Pinyin to query the result" | |
69 | #~ msgstr "只使用原始拼音查询结果" | |
66 | #: src/fcitx-cloudpinyin.desc:26 | |
67 | msgid "Baidu" | |
68 | msgstr "百度" |
0 | 0 | # SOME DESCRIPTIVE TITLE. |
1 | 1 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER |
2 | 2 | # This file is distributed under the same license as the PACKAGE package. |
3 | # | |
3 | # | |
4 | 4 | # Translators: |
5 | # <alisha.4m@gmail.com>, 2012. | |
5 | 6 | # Alisha <alisha.4m@gmail.com>, 2012. |
6 | 7 | msgid "" |
7 | 8 | msgstr "" |
8 | 9 | "Project-Id-Version: fcitx\n" |
9 | "Report-Msgid-Bugs-To: \n" | |
10 | "POT-Creation-Date: 2012-08-29 18:07-0400\n" | |
11 | "PO-Revision-Date: 2012-01-26 16:05+0000\n" | |
10 | "Report-Msgid-Bugs-To: fcitx-dev@googlegroups.com\n" | |
11 | "POT-Creation-Date: 2012-12-01 18:57-0500\n" | |
12 | "PO-Revision-Date: 2012-09-11 00:12+0000\n" | |
12 | 13 | "Last-Translator: Alisha <alisha.4m@gmail.com>\n" |
13 | "Language-Team: Chinese (Taiwan) (http://www.transifex.net/projects/p/fcitx/" | |
14 | "language/zh_TW/)\n" | |
15 | "Language: zh_TW\n" | |
14 | "Language-Team: Chinese (Taiwan) (http://www.transifex.com/projects/p/fcitx/language/zh_TW/)\n" | |
16 | 15 | "MIME-Version: 1.0\n" |
17 | 16 | "Content-Type: text/plain; charset=UTF-8\n" |
18 | 17 | "Content-Transfer-Encoding: 8bit\n" |
19 | "Plural-Forms: nplurals=1; plural=0\n" | |
18 | "Language: zh_TW\n" | |
19 | "Plural-Forms: nplurals=1; plural=0;\n" | |
20 | 20 | |
21 | #: /home/saber/Develop/fcitx-cloudpinyin/build/po/../..//src/cloudpinyin.c:588 | |
21 | #: src/cloudpinyin.c:607 | |
22 | 22 | msgid " (via cloud)" |
23 | 23 | msgstr "(來自雲)" |
24 | 24 | |
25 | #: /home/saber/Develop/fcitx-cloudpinyin/build/po/tmp/fcitx-cloudpinyin.conf.in.h:2 | |
25 | #: src/fcitx-cloudpinyin.conf.in:3 | |
26 | msgid "Cloud Pinyin" | |
27 | msgstr "雲拼音" | |
28 | ||
29 | #: src/fcitx-cloudpinyin.conf.in:4 | |
26 | 30 | msgid "Add Cloud Pinyin Support to Pinyin Input Method" |
27 | 31 | msgstr "為拼音輸入法加入雲拼音支援" |
28 | 32 | |
29 | #: unknown | |
30 | msgid "Baidu" | |
31 | msgstr "" | |
32 | ||
33 | #: /home/saber/Develop/fcitx-cloudpinyin/build/po/tmp/fcitx-cloudpinyin.conf.in.h:1 | |
34 | msgid "Cloud Pinyin" | |
33 | #: src/fcitx-cloudpinyin.desc:1 src/fcitx-cloudpinyin.desc:7 | |
34 | #: src/fcitx-cloudpinyin.desc:13 src/fcitx-cloudpinyin.desc:18 | |
35 | msgid "CloudPinyin" | |
35 | 36 | msgstr "雲拼音" |
36 | 37 | |
37 | #: /home/saber/Develop/fcitx-cloudpinyin/src/fcitx-cloudpinyin.desc:5 | |
38 | #: src/fcitx-cloudpinyin.desc:5 | |
38 | 39 | msgid "Cloud Pinyin Candidate Word Order" |
39 | 40 | msgstr "雲拼音候選字順序" |
40 | 41 | |
41 | #: /home/saber/Develop/fcitx-cloudpinyin/src/fcitx-cloudpinyin.desc:21 | |
42 | #: src/fcitx-cloudpinyin.desc:11 | |
43 | msgid "Minimum Length of Pinyin To Trigger Cloud Pinyin" | |
44 | msgstr "最小觸發雲拼音的拼音長度" | |
45 | ||
46 | #: src/fcitx-cloudpinyin.desc:16 | |
47 | msgid "Don't Show the 'via cloud' hint" | |
48 | msgstr "不顯示「來自雲」提示" | |
49 | ||
50 | #: src/fcitx-cloudpinyin.desc:21 | |
42 | 51 | msgid "Cloud Pinyin Source" |
43 | 52 | msgstr "雲拼音來源" |
44 | 53 | |
45 | # unknown | |
46 | msgid "CloudPinyin" | |
47 | msgstr "雲拼音" | |
54 | #: src/fcitx-cloudpinyin.desc:23 | |
55 | msgid "Sogou" | |
56 | msgstr "搜狗" | |
48 | 57 | |
49 | #: /home/saber/Develop/fcitx-cloudpinyin/src/fcitx-cloudpinyin.desc:16 | |
50 | msgid "Don't Show the 'via cloud' hint" | |
51 | msgstr "不顯示「來自雲」提示" | |
58 | #: src/fcitx-cloudpinyin.desc:24 | |
59 | msgid "QQ" | |
60 | msgstr "QQ" | |
52 | 61 | |
53 | #: unknown | |
62 | #: src/fcitx-cloudpinyin.desc:25 | |
54 | 63 | msgid "Google" |
55 | 64 | msgstr "Google" |
56 | 65 | |
57 | #: /home/saber/Develop/fcitx-cloudpinyin/src/fcitx-cloudpinyin.desc:11 | |
58 | msgid "Minimum Length of Pinyin To Trigger Cloud Pinyin" | |
59 | msgstr "最小觸發雲拼音的拼音長度" | |
60 | ||
61 | #: unknown | |
62 | msgid "QQ" | |
63 | msgstr "QQ" | |
64 | ||
65 | #: unknown | |
66 | msgid "Sogou" | |
67 | msgstr "搜狗" | |
68 | ||
69 | #~ msgid "Only use origin Pinyin to query the result" | |
70 | #~ msgstr "只使用原始拼音查詢結果" | |
66 | #: src/fcitx-cloudpinyin.desc:26 | |
67 | msgid "Baidu" | |
68 | msgstr "百度" |
0 | 0 | include_directories( |
1 | ${PROJECT_BINARY_DIR} | |
2 | ${CMAKE_CURRENT_SOURCE_DIR} | |
3 | ${CURL_INCLUDE_DIRS} | |
4 | ${PTHREAD_INCLUDE_DIR} | |
5 | ${FCITX4_FCITX_INCLUDE_DIRS} | |
6 | ${FCITX4_FCITX_CONFIG_INCLUDE_DIRS} | |
7 | ${FCITX4_FCITX_UTILS_INCLUDE_DIRS} | |
8 | ${LIBINTL_INCLUDE_DIR} | |
9 | ) | |
1 | ${PROJECT_BINARY_DIR} | |
2 | ${CMAKE_CURRENT_SOURCE_DIR} | |
3 | ${CURL_INCLUDE_DIRS} | |
4 | ${PTHREAD_INCLUDE_DIR} | |
5 | ${FCITX4_FCITX_INCLUDE_DIRS} | |
6 | ${FCITX4_FCITX_CONFIG_INCLUDE_DIRS} | |
7 | ${FCITX4_FCITX_UTILS_INCLUDE_DIRS} | |
8 | ${LIBINTL_INCLUDE_DIR} | |
9 | ) | |
10 | 10 | |
11 | 11 | link_directories( |
12 | ${CURL_LIBRARY_DIRS} | |
13 | ) | |
12 | ${CURL_LIBRARY_DIRS} | |
13 | ) | |
14 | 14 | |
15 | 15 | set(FCITX_CLOUDPINYIN_SRCS |
16 | cloudpinyin.c | |
17 | cloudpinyinconifg.c | |
18 | fetch.c | |
19 | parse.c | |
20 | ) | |
16 | cloudpinyin.c | |
17 | cloudpinyinconifg.c | |
18 | fetch.c | |
19 | parse.c | |
20 | ) | |
21 | 21 | |
22 | fcitx_add_addon(fcitx-cloudpinyin ${FCITX_CLOUDPINYIN_SRCS}) | |
23 | target_link_libraries( fcitx-cloudpinyin | |
24 | ${CURL_LIBRARIES} | |
25 | ${LIBINTL_LIBRARIES} | |
26 | ${PTHREAD_LIBRARIES} | |
27 | ) | |
28 | ||
29 | fcitx_add_addon_conf_file(fcitx-cloudpinyin.conf) | |
30 | fcitx_add_configdesc_file(fcitx-cloudpinyin.desc) | |
22 | fcitx_add_addon_full(cloudpinyin DESC | |
23 | SOURCES ${FCITX_CLOUDPINYIN_SRCS} | |
24 | LINK_LIBS ${CURL_LIBRARIES} | |
25 | ${LIBINTL_LIBRARIES} | |
26 | ${PTHREAD_LIBRARIES}) |
32 | 32 | #include <fcitx-utils/log.h> |
33 | 33 | #include <fcitx/candidate.h> |
34 | 34 | #include <fcitx-config/xdg.h> |
35 | #include <fcitx/module/pinyin/pydef.h> | |
35 | #include <fcitx/module/pinyin/fcitx-pinyin.h> | |
36 | 36 | |
37 | 37 | #include "cloudpinyin.h" |
38 | 38 | #include "fetch.h" |
39 | 39 | #include "parse.h" |
40 | 40 | |
41 | #define CHECK_VALID_IM (im && \ | |
41 | DEFINE_GET_ADDON("fcitx-sunpinyin", SunPinyin) | |
42 | DEFINE_GET_ADDON("fcitx-libpinyin", LibPinyin) | |
43 | DEFINE_GET_ADDON("fcitx-sogoupinyin", SogouPinyin) | |
44 | DEFINE_GET_AND_INVOKE_FUNC(SunPinyin, GetFullPinyin, 0) | |
45 | DEFINE_GET_AND_INVOKE_FUNC(SunPinyin, AddWord, 1) | |
46 | ||
47 | // Maybe not the right name, but doesn't matter.... | |
48 | DEFINE_GET_AND_INVOKE_FUNC(LibPinyin, AddWord, 0) | |
49 | DEFINE_GET_AND_INVOKE_FUNC(SogouPinyin, AddWord, 0) | |
50 | ||
51 | #define CHECK_VALID_IM (im && \ | |
42 | 52 | strcmp(im->langCode, "zh_CN") == 0 && \ |
43 | 53 | (strcmp(im->uniqueName, "pinyin") == 0 || \ |
44 | 54 | strcmp(im->uniqueName, "pinyin-libpinyin") == 0 || \ |
49 | 59 | strcmp(im->uniqueName, "sogou-pinyin") == 0)) |
50 | 60 | |
51 | 61 | #define CLOUDPINYIN_CHECK_PAGE_NUMBER 3 |
52 | ||
53 | #define LOGLEVEL DEBUG | |
54 | 62 | |
55 | 63 | typedef struct _CloudCandWord { |
56 | 64 | boolean filled; |
150 | 158 | } else { |
151 | 159 | FcitxMessagesAddMessageAtLast(message, MSG_INPUT, "%s", str); |
152 | 160 | } |
153 | if (string) | |
154 | free(string); | |
161 | fcitx_utils_free(string); | |
155 | 162 | FcitxInstanceUpdateClientSideUI( |
156 | 163 | cloudpinyin->owner, FcitxInstanceGetCurrentIC(cloudpinyin->owner)); |
157 | 164 | } |
278 | 285 | |
279 | 286 | if (inputString) { |
280 | 287 | CloudPinyinCache* cacheEntry = CloudPinyinCacheLookup(cloudpinyin, inputString); |
281 | FcitxLog(LOGLEVEL, "%s", inputString); | |
288 | FcitxLog(DEBUG, "%s", inputString); | |
282 | 289 | if (cacheEntry == NULL) |
283 | 290 | CloudPinyinAddInputRequest(cloudpinyin, inputString); |
284 | 291 | _CloudPinyinAddCandidateWord(cloudpinyin, inputString); |
346 | 353 | void CloudPinyinProcessEvent(void* arg) |
347 | 354 | { |
348 | 355 | FcitxCloudPinyin* cloudpinyin = (FcitxCloudPinyin*) arg; |
356 | FcitxInstance* instance = cloudpinyin->owner; | |
357 | if (!FD_ISSET(cloudpinyin->pipeRecv, FcitxInstanceGetReadFDSet(instance))) | |
358 | return; | |
359 | ||
349 | 360 | char c; |
350 | 361 | while (read(cloudpinyin->pipeRecv, &c, sizeof(char)) > 0); |
351 | 362 | pthread_mutex_lock(&cloudpinyin->finishQueueLock); |
352 | 363 | CurlQueue* queue; |
353 | 364 | queue = cloudpinyin->finishQueue; |
365 | /* this queue header is empty, so the check condition is "next" not null */ | |
354 | 366 | while (queue->next != NULL) |
355 | 367 | { |
368 | /* remove pivot from queue, thus pivot need to be free'd in HandleRequest */ | |
356 | 369 | CurlQueue* pivot = queue->next; |
357 | 370 | queue->next = queue->next->next; |
358 | 371 | CloudPinyinHandleRequest(cloudpinyin, pivot); |
362 | 375 | |
363 | 376 | void CloudPinyinDestroy(void* arg) |
364 | 377 | { |
365 | ||
378 | FcitxCloudPinyin* cloudpinyin = (FcitxCloudPinyin*) arg; | |
379 | char c = 1; | |
380 | write(cloudpinyin->pipeNotify, &c, sizeof(char)); | |
381 | pthread_join(cloudpinyin->pid, NULL); | |
382 | pthread_mutex_destroy(&cloudpinyin->pendingQueueLock); | |
383 | pthread_mutex_destroy(&cloudpinyin->finishQueueLock); | |
384 | while (cloudpinyin->cache) | |
385 | { | |
386 | CloudPinyinCache* head = cloudpinyin->cache; | |
387 | HASH_DEL(cloudpinyin->cache, cloudpinyin->cache); | |
388 | free(head->pinyin); | |
389 | free(head->str); | |
390 | free(head); | |
391 | } | |
392 | ||
393 | close(cloudpinyin->pipeRecv); | |
394 | close(cloudpinyin->pipeNotify); | |
395 | ||
396 | close(cloudpinyin->fetch->pipeRecv); | |
397 | close(cloudpinyin->fetch->pipeNotify); | |
398 | int i = 0; | |
399 | for (i = 0; i < MAX_HANDLE; i ++) { | |
400 | if (cloudpinyin->freeList[i].curl) { | |
401 | curl_easy_cleanup(cloudpinyin->freeList[i].curl); | |
402 | } | |
403 | } | |
404 | ||
405 | curl_multi_cleanup(cloudpinyin->fetch->curlm); | |
406 | #define _FREE_QUEUE(NAME) \ | |
407 | while(NAME) { \ | |
408 | CurlQueue* queue = NAME; \ | |
409 | NAME = NAME->next; \ | |
410 | fcitx_utils_free(queue->str); \ | |
411 | fcitx_utils_free(queue->pinyin); \ | |
412 | free(queue); \ | |
413 | } | |
414 | _FREE_QUEUE(cloudpinyin->pendingQueue) | |
415 | _FREE_QUEUE(cloudpinyin->finishQueue) | |
416 | _FREE_QUEUE(cloudpinyin->fetch->queue) | |
417 | FcitxConfigFree(&cloudpinyin->config.config); | |
418 | free(cloudpinyin->fetch); | |
419 | free(cloudpinyin); | |
366 | 420 | } |
367 | 421 | |
368 | 422 | void CloudPinyinReloadConfig(void* arg) |
444 | 498 | strToFree = GetCurrentString(cloudpinyin, &inputString); |
445 | 499 | |
446 | 500 | if (inputString) { |
447 | FcitxLog(LOGLEVEL, "fill: %s %s", inputString, queue->pinyin); | |
501 | FcitxLog(DEBUG, "fill: %s %s", inputString, queue->pinyin); | |
448 | 502 | if (strcmp(inputString, queue->pinyin) == 0) |
449 | 503 | { |
450 | 504 | if (CHECK_VALID_IM) |
471 | 525 | } |
472 | 526 | } |
473 | 527 | CloudPinyinReleaseCurlHandle(cloudpinyin, queue->curl); |
474 | if (queue->str) | |
475 | free(queue->str); | |
476 | if (queue->pinyin) | |
477 | free(queue->pinyin); | |
528 | fcitx_utils_free(queue->str); | |
529 | fcitx_utils_free(queue->pinyin); | |
478 | 530 | free(queue); |
479 | 531 | } |
480 | 532 | |
691 | 743 | if (py) { |
692 | 744 | *py = 0; |
693 | 745 | |
694 | snprintf(FcitxInputStateGetOutputString(input), MAX_USER_INPUT, "%s%s", string, candWord->strWord); | |
746 | snprintf(FcitxInputStateGetOutputString(input), | |
747 | MAX_USER_INPUT, "%s%s", string, candWord->strWord); | |
695 | 748 | |
696 | 749 | FcitxIM* im = FcitxInstanceGetCurrentIM(cloudpinyin->owner); |
697 | FcitxModuleFunctionArg args; | |
698 | args.args[0] = FcitxInputStateGetOutputString(input); | |
699 | if (im) | |
700 | { | |
701 | if (strcmp(im->uniqueName, "sunpinyin") == 0) | |
702 | FcitxModuleInvokeFunctionByName(cloudpinyin->owner, "fcitx-sunpinyin", 1, args); | |
703 | else if (strcmp(im->uniqueName, "shuangpin") == 0 || strcmp(im->uniqueName, "pinyin") == 0) | |
704 | FcitxModuleInvokeFunctionByName(cloudpinyin->owner, "fcitx-pinyin", 7, args); | |
705 | else if (strcmp(im->uniqueName, "pinyin-libpinyin") == 0 || | |
706 | strcmp(im->uniqueName, "shuangpin-libpinyin") == 0) | |
707 | { | |
708 | FcitxModuleInvokeFunctionByName(cloudpinyin->owner, "fcitx-libpinyin", 0, args); | |
750 | if (im) { | |
751 | char *output_string = FcitxInputStateGetOutputString(input); | |
752 | FCITX_DEF_MODULE_ARGS(args, output_string); | |
753 | if (strcmp(im->uniqueName, "sunpinyin") == 0) { | |
754 | FcitxSunPinyinInvokeAddWord(cloudpinyin->owner, args); | |
755 | } else if (strcmp(im->uniqueName, "shuangpin") == 0 || | |
756 | strcmp(im->uniqueName, "pinyin") == 0) { | |
757 | FcitxPinyinInvokeAddUserPhrase(cloudpinyin->owner, args); | |
758 | } else if (strcmp(im->uniqueName, "pinyin-libpinyin") == 0 || | |
759 | strcmp(im->uniqueName, "shuangpin-libpinyin") == 0) { | |
760 | FcitxLibPinyinInvokeAddWord(cloudpinyin->owner, args); | |
709 | 761 | } |
710 | 762 | else if (strcmp(im->uniqueName, "sogou-pinyin") == 0) |
711 | 763 | { |
712 | FcitxModuleInvokeFunctionByName(cloudpinyin->owner, "fcitx-sogoupinyin", 0, args); | |
764 | FcitxSogouPinyinInvokeAddWord(cloudpinyin->owner, args); | |
713 | 765 | } |
714 | 766 | } |
715 | 767 | } |
788 | 840 | |
789 | 841 | if (*lastpos != '\0') { |
790 | 842 | char* result = NULL; |
791 | FcitxModuleFunctionArg arg; | |
792 | arg.args[0] = lastpos; | |
793 | 843 | boolean isshuangpin = false; |
794 | 844 | if (strcmp(im->uniqueName, "sunpinyin") == 0) { |
795 | boolean issp = false; | |
796 | arg.args[1] = &issp; | |
797 | result = FcitxModuleInvokeFunctionByName(cloudpinyin->owner, "fcitx-sunpinyin", 0, arg); | |
798 | isshuangpin = issp; | |
845 | FCITX_DEF_MODULE_ARGS(args, lastpos, &isshuangpin); | |
846 | result = FcitxSunPinyinInvokeGetFullPinyin( | |
847 | cloudpinyin->owner, args); | |
799 | 848 | } else if (strcmp(im->uniqueName, "shuangpin") == 0) { |
800 | 849 | isshuangpin = true; |
801 | result = InvokeFunction(cloudpinyin->owner, FCITX_PINYIN, SP2QP, arg); | |
850 | result = FcitxPinyinSP2QP(cloudpinyin->owner, lastpos); | |
802 | 851 | } |
803 | 852 | if (isshuangpin) { |
804 | 853 | if (result) { |
821 | 870 | } |
822 | 871 | } |
823 | 872 | } |
824 | ||
825 | 873 | lastpos = pinyin + 1; |
826 | 874 | } |
827 | 875 | pinyin ++; |
828 | ||
829 | 876 | } while(endflag); |
830 | 877 | free(string); |
831 | 878 | /* no pinyin append, return NULL for off it */ |
845 | 892 | const char* ime_patch_key = "ime_patch_key = \""; |
846 | 893 | size_t len = strlen(str); |
847 | 894 | if (len == SOGOU_KEY_LENGTH + strlen(ime_patch_key) + 1 |
848 | && strncmp(str, ime_patch_key, strlen(ime_patch_key)) == 0 | |
849 | && str[len - 1] == '\"' | |
850 | ) | |
851 | { | |
895 | && strncmp(str, ime_patch_key, strlen(ime_patch_key)) == 0 | |
896 | && str[len - 1] == '\"') { | |
852 | 897 | sscanf(str,"ime_patch_key = \"%s\"", cloudpinyin->key); |
853 | 898 | cloudpinyin->initialized = true; |
854 | 899 | cloudpinyin->key[SOGOU_KEY_LENGTH] = '\0'; |
860 | 905 | void CloudPinyinHookForNewRequest(void* arg) |
861 | 906 | { |
862 | 907 | FcitxCloudPinyin* cloudpinyin = (FcitxCloudPinyin*) arg; |
863 | if (!cloudpinyin->initialized && !cloudpinyin->isrequestkey) | |
864 | { | |
908 | if (!cloudpinyin->initialized && !cloudpinyin->isrequestkey) { | |
865 | 909 | CloudPinyinRequestKey(cloudpinyin); |
866 | 910 | } |
867 | 911 | } |
42 | 42 | curl_multi_setopt(fetch->curlm, CURLMOPT_MAXCONNECTS, MAX_HANDLE); |
43 | 43 | |
44 | 44 | while (true) { |
45 | ||
45 | boolean endflag = false; | |
46 | 46 | char c; |
47 | while (read(fetch->pipeRecv, &c, sizeof(char)) > 0); | |
47 | while (read(fetch->pipeRecv, &c, sizeof(char)) > 0) { | |
48 | if (c == 1) | |
49 | endflag = true; | |
50 | } | |
51 | if (endflag) | |
52 | break; | |
48 | 53 | |
49 | 54 | FetchProcessPendingRequest(fetch); |
50 | 55 | FetchProcessEvent(fetch); |