diff options
author | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2014-08-05 13:37:49 +0300 |
---|---|---|
committer | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2014-08-14 09:41:52 +0300 |
commit | 1290471fc3e542388e79e27cb2c4ce654f5023f3 (patch) | |
tree | 23a81b2c339c394db4d14ef3cfe3931eaadf9a81 /src/virtualkeyboard/3rdparty | |
parent | 7a7ddb56dee32cc7acf284abed3bfbd1cbb5c99b (diff) |
Make the keyboard layout changeable in password / url input mode
Removed latin-only restriction with specific input method hints.
More specifically, the latin-only keyboard was previously enforced
when password, hidden, sensitive or latin-only flags were set for
the input control.
Now it is possible to use non-latin input methods and keyboard
layouts with these modes too. However, this change implies some
additional changes to the Pinyin and Hunspell input methods.
Changes to PinyinInputMethod:
- Disable the user dictionary when sensitive data flag is set.
This is required so that sensitive data (such as passwords)
is not stored in the user dictionary.
Changes to HunspellInputMethod:
- Disable the auto space functionality when the input mode is not
latin, or the exclusive input mode is set to url or email input.
Task-number: QTRD-3210
Change-Id: I444c4b87c9805b69dc773ef6cac76f1c11dd220a
Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
Reviewed-by: Rainer Keller <rainer.keller@digia.com>
Diffstat (limited to 'src/virtualkeyboard/3rdparty')
4 files changed, 50 insertions, 0 deletions
diff --git a/src/virtualkeyboard/3rdparty/pinyin/include/matrixsearch.h b/src/virtualkeyboard/3rdparty/pinyin/include/matrixsearch.h index f581d30a..61e78aa6 100644 --- a/src/virtualkeyboard/3rdparty/pinyin/include/matrixsearch.h +++ b/src/virtualkeyboard/3rdparty/pinyin/include/matrixsearch.h @@ -380,6 +380,10 @@ class MatrixSearch { bool init_fd(int sys_fd, long start_offset, long length, const char *fn_usr_dict); + void init_user_dictionary(const char *fn_usr_dict); + + bool is_user_dictionary_enabled() const; + void set_max_lens(size_t max_sps_len, size_t max_hzs_len); void close(); diff --git a/src/virtualkeyboard/3rdparty/pinyin/include/pinyinime.h b/src/virtualkeyboard/3rdparty/pinyin/include/pinyinime.h index 0744ec7d..e376c20c 100644 --- a/src/virtualkeyboard/3rdparty/pinyin/include/pinyinime.h +++ b/src/virtualkeyboard/3rdparty/pinyin/include/pinyinime.h @@ -202,6 +202,18 @@ extern "C" { * Enable Yunmus in ShouZiMu mode. */ void im_enable_ym_as_szm(bool enable); + + /** + * Initializes or uninitializes the user dictionary. + * + * @param fn_usr_dict The file name of the user dictionary. + */ + void im_init_user_dictionary(const char *fn_usr_dict); + + /** + * Returns the current status of user dictinary. + */ + bool im_is_user_dictionary_enabled(void); } #ifdef __cplusplus diff --git a/src/virtualkeyboard/3rdparty/pinyin/share/matrixsearch.cpp b/src/virtualkeyboard/3rdparty/pinyin/share/matrixsearch.cpp index 12d092a9..41e11433 100644 --- a/src/virtualkeyboard/3rdparty/pinyin/share/matrixsearch.cpp +++ b/src/virtualkeyboard/3rdparty/pinyin/share/matrixsearch.cpp @@ -169,6 +169,29 @@ bool MatrixSearch::init_fd(int sys_fd, long start_offset, long length, return true; } +void MatrixSearch::init_user_dictionary(const char *fn_usr_dict) { + assert(inited_); + + if (NULL != user_dict_) { + delete user_dict_; + user_dict_ = NULL; + } + + if (NULL != fn_usr_dict) { + user_dict_ = static_cast<AtomDictBase*>(new UserDict()); + if (!user_dict_->load_dict(fn_usr_dict, kUserDictIdStart, kUserDictIdEnd)) { + delete user_dict_; + user_dict_ = NULL; + } + } + + reset_search0(); +} + +bool MatrixSearch::is_user_dictionary_enabled() const { + return NULL != user_dict_; +} + void MatrixSearch::set_max_lens(size_t max_sps_len, size_t max_hzs_len) { if (0 != max_sps_len) max_sps_len_ = max_sps_len; diff --git a/src/virtualkeyboard/3rdparty/pinyin/share/pinyinime.cpp b/src/virtualkeyboard/3rdparty/pinyin/share/pinyinime.cpp index 550da7bf..4d206a76 100644 --- a/src/virtualkeyboard/3rdparty/pinyin/share/pinyinime.cpp +++ b/src/virtualkeyboard/3rdparty/pinyin/share/pinyinime.cpp @@ -181,6 +181,17 @@ extern "C" { spl_trie.szm_enable_ym(enable); } + void im_init_user_dictionary(const char *fn_usr_dict) { + if (!matrix_search) + return; + matrix_search->flush_cache(); + matrix_search->init_user_dictionary(fn_usr_dict); + } + + bool im_is_user_dictionary_enabled(void) { + return NULL != matrix_search ? matrix_search->is_user_dictionary_enabled() : false; + } + #ifdef __cplusplus } #endif |