Merge commit 'upstream/1.2.855.102'
Nobuhiro Iwamatsu
12 years ago
2440 | 2440 | << "Can't get passwd entry for uid " << uid << "."; |
2441 | 2441 | CHECK_LT(0, strlen(pw.pw_dir)) |
2442 | 2442 | << "Home directory for uid " << uid << " is not set."; |
2443 | #if defined(OS_CHROMEOS) | |
2444 | dir = Util::JoinPath(pw.pw_dir, "user/.mozc"); | |
2445 | #else | |
2446 | 2443 | dir = Util::JoinPath(pw.pw_dir, ".mozc"); |
2447 | #endif // OS_CHROMEOS | |
2448 | 2444 | #endif |
2449 | 2445 | |
2450 | 2446 | Util::CreateDirectory(dir); |
3116 | 3112 | // http://b/2430094 |
3117 | 3113 | // This is why we use VerifyVersionInfo here instead of GetVersion(Ex). |
3118 | 3114 | |
3119 | if (IsWindowsX64() && !Util::IsVistaOrLater()) { | |
3120 | // NT 5.x OSes are excluded from Mozc 64-bit support. | |
3121 | return false; // not supported | |
3122 | } | |
3123 | 3115 | // You can find a table of version number for each version of Windows in |
3124 | 3116 | // the following page. |
3125 | 3117 | // http://msdn.microsoft.com/en-us/library/ms724833.aspx |
3126 | 3118 | { |
3127 | 3119 | // Windows 7 <= |OSVERSION|: supported |
3128 | OSVERSIONINFOEX osvi = { 0 }; | |
3120 | OSVERSIONINFOEX osvi = {}; | |
3129 | 3121 | osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); |
3130 | 3122 | osvi.dwMajorVersion = 6; |
3131 | 3123 | osvi.dwMinorVersion = 1; |
3139 | 3131 | } |
3140 | 3132 | { |
3141 | 3133 | // Windows Vista SP1 <= |OSVERSION| < Windows 7: supported |
3142 | OSVERSIONINFOEX osvi = { 0 }; | |
3134 | OSVERSIONINFOEX osvi = {}; | |
3143 | 3135 | osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); |
3144 | 3136 | osvi.dwMajorVersion = 6; |
3145 | 3137 | osvi.dwMinorVersion = 0; |
3155 | 3147 | } |
3156 | 3148 | } |
3157 | 3149 | { |
3158 | // Windows Server 2003 <= |OSVERSION| < Windows Vista SP1: not supported | |
3159 | OSVERSIONINFOEX osvi = { 0 }; | |
3150 | // Windows Vista RTM <= |OSVERSION| < Windows Vista SP1: not supported | |
3151 | OSVERSIONINFOEX osvi = {}; | |
3152 | osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); | |
3153 | osvi.dwMajorVersion = 6; | |
3154 | osvi.dwMinorVersion = 0; | |
3155 | osvi.wServicePackMajor = 0; | |
3156 | DWORDLONG conditional = 0; | |
3157 | VER_SET_CONDITION(conditional, VER_MAJORVERSION, VER_GREATER_EQUAL); | |
3158 | VER_SET_CONDITION(conditional, VER_MINORVERSION, VER_GREATER_EQUAL); | |
3159 | VER_SET_CONDITION(conditional, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); | |
3160 | const DWORD typemask = VER_MAJORVERSION | VER_MINORVERSION | | |
3161 | VER_SERVICEPACKMAJOR; | |
3162 | if (::VerifyVersionInfo(&osvi, typemask, conditional) != 0) { | |
3163 | return false; // not supported | |
3164 | } | |
3165 | } | |
3166 | { | |
3167 | // Windows XP x64/Server 2003 <= |OSVERSION| < Windows Vista RTM: supported | |
3168 | // --- | |
3169 | // Note: We do not oficially support these platforms but allows users to | |
3170 | // install Mozc into them. See b/5182031 for the background information. | |
3171 | OSVERSIONINFOEX osvi = {}; | |
3160 | 3172 | osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); |
3161 | 3173 | osvi.dwMajorVersion = 5; |
3162 | 3174 | osvi.dwMinorVersion = 2; |
3165 | 3177 | VER_SET_CONDITION(conditional, VER_MINORVERSION, VER_GREATER_EQUAL); |
3166 | 3178 | const DWORD typemask = VER_MAJORVERSION | VER_MINORVERSION; |
3167 | 3179 | if (::VerifyVersionInfo(&osvi, typemask, conditional) != 0) { |
3168 | return false; // not supported | |
3180 | return true; // supported | |
3169 | 3181 | } |
3170 | 3182 | } |
3171 | 3183 | { |
3172 | // Windows XP SP2 <= |OSVERSION| < Windows Server 2003: supported | |
3173 | OSVERSIONINFOEX osvi = { 0 }; | |
3184 | // Windows XP SP2 <= |OSVERSION| < Windows XP x64/Server 2003: supported | |
3185 | OSVERSIONINFOEX osvi = {}; | |
3174 | 3186 | osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); |
3175 | 3187 | osvi.dwMajorVersion = 5; |
3176 | 3188 | osvi.dwMinorVersion = 1; |
2017 | 2017 | "\xE3\x87\xB6\xE3\x87\xB7\xE3\x87\xB8\xE3\x87\xB9\xE3\x87\xBA" |
2018 | 2018 | "\xE3\x87\xBB\xE3\x87\xBC\xE3\x87\xBD\xE3\x87\xBE\xE3\x87\xBF", |
2019 | 2019 | Util::KATAKANA)); |
2020 | // "ð" U+1B000: KATAKANA LETTER ARCHAIC E | |
2020 | // "𛀀" U+1B000: KATAKANA LETTER ARCHAIC E | |
2021 | 2021 | EXPECT_TRUE(Util::IsScriptType("\xF0\x9B\x80\x80", Util::KATAKANA)); |
2022 | // "ð" U+1B001: HIRAGANA LETTER ARCHAIC YE | |
2022 | // "𛀁" U+1B001: HIRAGANA LETTER ARCHAIC YE | |
2023 | 2023 | EXPECT_TRUE(Util::IsScriptType("\xF0\x9B\x80\x81", Util::HIRAGANA)); |
2024 | 2024 | |
2025 | 2025 | EXPECT_TRUE(Util::IsScriptType("012", Util::NUMBER)); |
2104 | 2104 | "\xE3\x87\xB1\xE3\x87\xB2\xE3\x87\xB3\xE3\x87\xB4\xE3\x87\xB5" |
2105 | 2105 | "\xE3\x87\xB6\xE3\x87\xB7\xE3\x87\xB8\xE3\x87\xB9\xE3\x87\xBA" |
2106 | 2106 | "\xE3\x87\xBB\xE3\x87\xBC\xE3\x87\xBD\xE3\x87\xBE\xE3\x87\xBF")); |
2107 | // "ð" U+1B000 KATAKANA LETTER ARCHAIC E | |
2107 | // "𛀀" U+1B000 KATAKANA LETTER ARCHAIC E | |
2108 | 2108 | EXPECT_EQ(Util::KATAKANA, Util::GetScriptType("\xF0\x9B\x80\x80")); |
2109 | // "ð" U+1B001 HIRAGANA LETTER ARCHAIC YE | |
2109 | // "𛀁" U+1B001 HIRAGANA LETTER ARCHAIC YE | |
2110 | 2110 | EXPECT_EQ(Util::HIRAGANA, Util::GetScriptType("\xF0\x9B\x80\x81")); |
2111 | 2111 | |
2112 | 2112 | // "!グーグル" |
2220 | 2220 | EXPECT_EQ(Util::KANJI, Util::GetScriptType("\xE9\xBE\xBB")); |
2221 | 2221 | // U+9FFF is not assigned yet but reserved for CJK Unified Ideographs. |
2222 | 2222 | EXPECT_EQ(Util::KANJI, Util::GetScriptType("\xE9\xBE\xFF")); |
2223 | // "ð ®咤" U+20B9F U+54A4 | |
2223 | // "𠮟咤" U+20B9F U+54A4 | |
2224 | 2224 | EXPECT_EQ(Util::KANJI, Util::GetScriptType("\xF0\xA0\xAE\x9F\xE5\x92\xA4")); |
2225 | // "ð ®·野" U+20BB7 U+91CE | |
2225 | // "𠮷野" U+20BB7 U+91CE | |
2226 | 2226 | EXPECT_EQ(Util::KANJI, Util::GetScriptType("\xF0\xA0\xAE\xB7\xE9\x87\x8E")); |
2227 | // "ð¯¢" U+2F884 | |
2227 | // "巽" U+2F884 | |
2228 | 2228 | EXPECT_EQ(Util::KANJI, Util::GetScriptType("\xF0\xAF\xA2\x84")); |
2229 | 2229 | } |
2230 | 2230 |
536 | 536 | |
537 | 537 | PSECURITY_ATTRIBUTES security_attributes_ptr = NULL; |
538 | 538 | SECURITY_ATTRIBUTES security_attributes = {}; |
539 | if (!WinSandbox::MakeSecurityAttributes(&security_attributes)) { | |
539 | if (WinSandbox::MakeSecurityAttributes(&security_attributes)) { | |
540 | 540 | security_attributes_ptr = &security_attributes; |
541 | 541 | // Override the impersonation thread token's DACL to avoid http://b/1728895 |
542 | 542 | // On Windows Server, the objects created by a member of |
362 | 362 | help='Specifies the DEPS file.') |
363 | 363 | parser.add_option('--gyp_generator', dest='gyp_generator', |
364 | 364 | help='Specifies the generator for GYP.') |
365 | parser.add_option('--onepass', '-1', dest='onepass', action='store_true', | |
366 | default=False, help='Builds mozc in one pass. ' | |
367 | 'Not recommended, intended to use only for Debug build.') | |
365 | parser.add_option('--deprecated_onepass', '-1', dest='onepass', | |
366 | action='store_true', | |
367 | default=False, | |
368 | help='Not supported. Builds mozc in one pass.') | |
368 | 369 | parser.add_option('--branding', dest='branding', default='Mozc') |
369 | 370 | parser.add_option('--gypdir', dest='gypdir', default='third_party/gyp') |
370 | 371 | parser.add_option('--noqt', action='store_true', dest='noqt', default=False) |
57 | 57 | # We don't capture stdout and stderr from Popen. The output will just |
58 | 58 | # be emitted to a terminal or console. |
59 | 59 | print sys.argv |
60 | process = subprocess.Popen(sys.argv) | |
60 | sys.exit(subprocess.call(sys.argv)) | |
61 | 61 | |
62 | 62 | if __name__ == '__main__': |
63 | 63 | main() |
56 | 56 | #include "base/util.h" |
57 | 57 | |
58 | 58 | namespace mozc { |
59 | ||
60 | 59 | namespace { |
60 | ||
61 | #ifdef GOOGLE_JAPANESE_INPUT_BUILD | |
61 | 62 | #ifdef OS_WINDOWS |
63 | ||
62 | 64 | const wchar_t kOmahaGUID[] = L"{DDCCD2A9-025E-4142-BCEB-F467B88CF830}"; |
63 | 65 | const wchar_t kOmahaUsageKey[] = |
64 | 66 | L"Software\\Google\\Update\\ClientState\\" |
217 | 219 | #endif // MACOSX |
218 | 220 | |
219 | 221 | |
220 | #ifdef OS_LINUX | |
221 | class LinuxStatsConfigUtilImpl : public StatsConfigUtilInterface { | |
222 | // TODO(toshiyuki): implement this | |
222 | #endif // GOOGLE_JAPANESE_INPUT_BUILD | |
223 | ||
224 | class NullStatsConfigUtilImpl : public StatsConfigUtilInterface { | |
223 | 225 | public: |
224 | LinuxStatsConfigUtilImpl(); | |
225 | virtual ~LinuxStatsConfigUtilImpl(); | |
226 | bool IsEnabled(); | |
227 | bool SetEnabled(bool val); | |
226 | NullStatsConfigUtilImpl() {} | |
227 | virtual ~NullStatsConfigUtilImpl() {} | |
228 | bool IsEnabled() { | |
229 | return false; | |
230 | } | |
231 | bool SetEnabled(bool val) { | |
232 | return true; | |
233 | } | |
228 | 234 | }; |
229 | 235 | |
230 | LinuxStatsConfigUtilImpl::LinuxStatsConfigUtilImpl() {} | |
231 | ||
232 | LinuxStatsConfigUtilImpl::~LinuxStatsConfigUtilImpl() {} | |
233 | ||
234 | bool LinuxStatsConfigUtilImpl::IsEnabled() { | |
235 | return false; | |
236 | } | |
237 | ||
238 | bool LinuxStatsConfigUtilImpl::SetEnabled(bool val) { | |
239 | return true; | |
240 | } | |
241 | #endif // OS_LINUX | |
242 | ||
243 | 236 | StatsConfigUtilInterface *g_stats_config_util_handler = NULL; |
244 | 237 | |
245 | 238 | // GetStatsConfigUtil and SetHandler are not thread safe. |
246 | 239 | |
247 | #ifdef OS_WINDOWS | |
240 | #if !defined(GOOGLE_JAPANESE_INPUT_BUILD) | |
241 | // For non-official build, use null implementation. | |
242 | typedef NullStatsConfigUtilImpl DefaultConfigUtilImpl; | |
243 | #elif defined(OS_WINDOWS) | |
248 | 244 | typedef WinStatsConfigUtilImpl DefaultConfigUtilImpl; |
249 | 245 | #elif defined(OS_MACOSX) |
250 | 246 | typedef MacStatsConfigUtilImpl DefaultConfigUtilImpl; |
251 | 247 | #else |
252 | typedef LinuxStatsConfigUtilImpl DefaultConfigUtilImpl; | |
248 | // Fall back mode. Use null implementation. | |
249 | typedef NullStatsConfigUtilImpl DefaultConfigUtilImpl; | |
253 | 250 | #endif |
254 | 251 | |
255 | 252 | StatsConfigUtilInterface &GetStatsConfigUtil() { |
39 | 39 | #endif |
40 | 40 | |
41 | 41 | |
42 | #ifdef GOOGLE_JAPANESE_INPUT_BUILD | |
42 | 43 | #ifdef OS_WINDOWS |
43 | 44 | |
44 | 45 | namespace { |
503 | 504 | EXPECT_EQ(1, value); |
504 | 505 | EXPECT_FALSE(test.HasUsagestatsValue(kHKLM_ClientStateMedium)); |
505 | 506 | |
506 | // Check if SetEnabled(true) merges kHKLM_ClientStateMedium. | |
507 | test.ClearUsagestatsValue(); | |
508 | test.SetUsagestatsValue(kHKLM_ClientStateMedium, 1); | |
509 | EXPECT_TRUE(StatsConfigUtil::SetEnabled(true)); | |
510 | EXPECT_FALSE(test.HasUsagestatsValue(kHKCU_ClientState)); | |
511 | EXPECT_TRUE(test.HasUsagestatsValue(kHKLM_ClientState)); | |
512 | test.GetUsagestatsValue(kHKLM_ClientState, &value); | |
513 | EXPECT_EQ(1, value); | |
514 | EXPECT_FALSE(test.HasUsagestatsValue(kHKLM_ClientStateMedium)); | |
515 | ||
516 | test.ClearUsagestatsValue(); | |
517 | test.SetUsagestatsValue(kHKLM_ClientStateMedium, 0); | |
518 | EXPECT_TRUE(StatsConfigUtil::SetEnabled(true)); | |
519 | EXPECT_FALSE(test.HasUsagestatsValue(kHKCU_ClientState)); | |
520 | EXPECT_TRUE(test.HasUsagestatsValue(kHKLM_ClientState)); | |
521 | test.GetUsagestatsValue(kHKLM_ClientState, &value); | |
522 | EXPECT_EQ(1, value); | |
523 | EXPECT_FALSE(test.HasUsagestatsValue(kHKLM_ClientStateMedium)); | |
524 | ||
525 | 507 | // Check if SetEnabled(false) works as expected. |
526 | 508 | test.ClearUsagestatsValue(); |
527 | EXPECT_TRUE(StatsConfigUtil::SetEnabled(false)); | |
528 | EXPECT_FALSE(test.HasUsagestatsValue(kHKCU_ClientState)); | |
529 | EXPECT_TRUE(test.HasUsagestatsValue(kHKLM_ClientState)); | |
530 | test.GetUsagestatsValue(kHKLM_ClientState, &value); | |
531 | EXPECT_EQ(0, value); | |
532 | EXPECT_FALSE(test.HasUsagestatsValue(kHKLM_ClientStateMedium)); | |
533 | ||
534 | // Check if SetEnabled(false) works as expected. | |
535 | test.ClearUsagestatsValue(); | |
536 | test.SetUsagestatsValue(kHKLM_ClientStateMedium, 1); | |
537 | EXPECT_TRUE(StatsConfigUtil::SetEnabled(false)); | |
538 | EXPECT_FALSE(test.HasUsagestatsValue(kHKCU_ClientState)); | |
539 | EXPECT_TRUE(test.HasUsagestatsValue(kHKLM_ClientState)); | |
540 | test.GetUsagestatsValue(kHKLM_ClientState, &value); | |
541 | EXPECT_EQ(0, value); | |
542 | EXPECT_FALSE(test.HasUsagestatsValue(kHKLM_ClientStateMedium)); | |
543 | ||
544 | test.ClearUsagestatsValue(); | |
545 | test.SetUsagestatsValue(kHKLM_ClientStateMedium, 0); | |
546 | 509 | EXPECT_TRUE(StatsConfigUtil::SetEnabled(false)); |
547 | 510 | EXPECT_FALSE(test.HasUsagestatsValue(kHKCU_ClientState)); |
548 | 511 | EXPECT_TRUE(test.HasUsagestatsValue(kHKLM_ClientState)); |
719 | 682 | } |
720 | 683 | #endif // !CHANNEL_DEV |
721 | 684 | |
722 | TEST_F(StatsConfigUtilTestWin, IsEnabledForRunLevelLow) { | |
723 | RegistryEmulator<__COUNTER__> test; | |
724 | ||
725 | test.SetRunLevel(kRunLevelHigh); | |
726 | // Enabling usagestats with proper style. | |
727 | test.SetUsagestatsValue(kHKLM_ClientState, 1); | |
728 | // Disable usagestats with wrong style. | |
729 | test.SetUsagestatsValue(kHKCU_ClientState, 0); | |
730 | ||
731 | test.SetRunLevel(kRunLevelLow); | |
732 | ||
733 | #if defined(CHANNEL_DEV) | |
734 | // In dev channel, IsEnabled always returns true regardless of the registry | |
735 | // settings. | |
736 | EXPECT_TRUE(StatsConfigUtil::IsEnabled()); | |
737 | #else | |
738 | // In beta and stable channels, disabling entry with wrong style should be | |
739 | // honored even if it is enabled in |kHKLM_ClientState| | |
740 | EXPECT_FALSE(StatsConfigUtil::IsEnabled()); | |
741 | #endif | |
742 | ||
743 | // If the runlevel is low, we cannot remove the entry under HKCU. | |
744 | // The previous states should remain as it were. | |
745 | EXPECT_FALSE(test.HasUsagestatsValue(kHKLM_ClientStateMedium)); | |
746 | EXPECT_TRUE(test.HasUsagestatsValue(kHKCU_ClientState)); | |
747 | DWORD value = 0; | |
748 | test.GetUsagestatsValue(kHKCU_ClientState, &value); | |
749 | EXPECT_EQ(0, value); | |
750 | } | |
751 | 685 | } // namespace mozc |
752 | 686 | #endif // OS_WINDOWS |
753 | 687 | |
760 | 694 | EXPECT_FALSE(mozc::StatsConfigUtil::IsEnabled()); |
761 | 695 | } |
762 | 696 | #endif // OS_LINUX |
697 | ||
698 | #else // !GOOGLE_JAPANESE_INPUT_BUILD | |
699 | TEST(StatsConfigUtilTestNonOfficialBuild, DefaultValueTest) { | |
700 | EXPECT_FALSE(mozc::StatsConfigUtil::IsEnabled()); | |
701 | } | |
702 | #endif |
15 | 15 | <layout>kr(kr104)</layout> |
16 | 16 | <name>mozc-hangul</name> |
17 | 17 | <longname>Mozc Hangul</longname> |
18 | <hotkeys>Shift+space,Hangul</hotkeys> | |
19 | 18 | </engine> |
20 | 19 | </engines> |
21 | 20 | </component> |
46 | 46 | #include "rewriter/variants_rewriter.h" |
47 | 47 | #include "rewriter/version_rewriter.h" |
48 | 48 | #include "rewriter/zipcode_rewriter.h" |
49 | #if defined(OS_MACOSX) || defined(OS_WINDOWS) | |
50 | // TODO(horo): Usage is available only in Mac and Windows now. | |
49 | #if defined(OS_MACOSX) || defined(OS_WINDOWS) || defined(OS_CHROMEOS) | |
50 | // TODO(horo): Usage is available only in Mac and Windows and ChromeOS now. | |
51 | 51 | #include "rewriter/usage_rewriter.h" |
52 | 52 | #endif |
53 | 53 | DEFINE_bool(use_history_rewriter, true, "Use history rewriter or not."); |
81 | 81 | AddRewriter(new DateRewriter); |
82 | 82 | AddRewriter(new FortuneRewriter); |
83 | 83 | AddRewriter(new VersionRewriter); |
84 | #if defined(OS_MACOSX) || defined(OS_WINDOWS) | |
84 | #if defined(OS_MACOSX) || defined(OS_WINDOWS) || defined(OS_CHROMEOS) | |
85 | 85 | // TODO(horo): Because infolist renderer window is implimented |
86 | // only in Mac and Windows, usage is available only | |
87 | // in Mac and Winnows. | |
86 | // only in Mac and Windows and ChromeOS, | |
87 | // usage is available only in these OS. | |
88 | 88 | AddRewriter(new UsageRewriter); |
89 | #endif // defined(OS_MACOSX) || defined(OS_WINDOWS) | |
89 | #endif // defined(OS_MACOSX) || defined(OS_WINDOWS) || defined(OS_CHROMEOS) | |
90 | 90 | } |
91 | 91 | |
92 | 92 | RewriterInterface *g_rewriter = NULL; |
79 | 79 | 'calculator/calculator.gyp:calculator', |
80 | 80 | 'rewriter_base.gyp:gen_rewriter_files', |
81 | 81 | ], |
82 | # TODO(horo): usage is available only in Mac and Win now. | |
82 | # TODO(horo): usage is available only in Mac and Win and ChromeOS now. | |
83 | 83 | 'conditions': [ |
84 | ['OS=="mac" or OS=="win"', { | |
84 | ['OS=="mac" or OS=="win" or chromeos==1', { | |
85 | 85 | 'sources': [ |
86 | 86 | '<(gen_out_dir)/usage_rewriter_data.h', |
87 | 87 | 'usage_rewriter.cc', |
168 | 168 | '<@(input_files)', |
169 | 169 | ], |
170 | 170 | }, |
171 | { | |
172 | 'action_name': 'gen_usage_rewriter_data', | |
173 | 'variables': { | |
174 | 'usage_data_file': [ | |
175 | '<(DEPTH)/third_party/japanese_usage_dictionary/usage_dict.txt', | |
176 | ], | |
177 | 'cforms_file': [ | |
178 | '../data/rules/cforms.def', | |
179 | ], | |
180 | }, | |
181 | 'inputs': [ | |
182 | '<@(usage_data_file)', | |
183 | '<@(cforms_file)', | |
184 | ], | |
185 | 'conditions': [['two_pass_build==0', { | |
186 | 'inputs': [ | |
187 | '<(mozc_build_tools_dir)/gen_usage_rewriter_dictionary_main', | |
188 | ], | |
189 | }]], | |
190 | 'outputs': [ | |
191 | '<(gen_out_dir)/usage_rewriter_data.h', | |
192 | ], | |
193 | 'action': [ | |
194 | '<(mozc_build_tools_dir)/gen_usage_rewriter_dictionary_main', | |
195 | '--usage_data_file=<@(usage_data_file)', | |
196 | '--cforms_file=<@(cforms_file)', | |
197 | '--logtostderr', | |
198 | '--output=<(gen_out_dir)/usage_rewriter_data.h', | |
199 | ], | |
200 | }, | |
201 | ], | |
202 | 'conditions': [['two_pass_build==0', { | |
203 | 'dependencies': [ | |
204 | 'install_gen_collocation_data_main', | |
205 | 'install_gen_emoticon_rewriter_dictionary_main', | |
206 | 'install_gen_single_kanji_rewriter_dictionary_main', | |
207 | 'install_gen_symbol_rewriter_dictionary_main', | |
208 | 'install_gen_usage_rewriter_dictionary_main', | |
209 | ], | |
210 | }]], | |
171 | ], | |
172 | 'conditions': [ | |
173 | ['OS=="mac" or OS=="win" or chromeos==1', { | |
174 | 'actions': [ | |
175 | { | |
176 | 'action_name': 'gen_usage_rewriter_data', | |
177 | 'variables': { | |
178 | 'usage_data_file': [ | |
179 | '<(DEPTH)/third_party/japanese_usage_dictionary/usage_dict.txt', | |
180 | ], | |
181 | 'cforms_file': [ | |
182 | '../data/rules/cforms.def', | |
183 | ], | |
184 | }, | |
185 | 'inputs': [ | |
186 | '<@(usage_data_file)', | |
187 | '<@(cforms_file)', | |
188 | ], | |
189 | 'outputs': [ | |
190 | '<(gen_out_dir)/usage_rewriter_data.h', | |
191 | ], | |
192 | 'action': [ | |
193 | '<(mozc_build_tools_dir)/gen_usage_rewriter_dictionary_main', | |
194 | '--usage_data_file=<@(usage_data_file)', | |
195 | '--cforms_file=<@(cforms_file)', | |
196 | '--logtostderr', | |
197 | '--output=<(gen_out_dir)/usage_rewriter_data.h', | |
198 | ], | |
199 | }, | |
200 | ], | |
201 | }], | |
202 | ], | |
211 | 203 | }, |
212 | 204 | { |
213 | 205 | 'target_name': 'gen_collocation_data_main', |
82 | 82 | 'longname': ['%s (Japanese keyboard layout)', '%s (US keyboard layout)', |
83 | 83 | '%s (US Dvorak keyboard layout)'], |
84 | 84 | 'layout': ['jp', 'us', 'us(dvorak)'], |
85 | # hotkeys property is Chrome/Chromium OS specific. Upstream ibus-daemon | |
86 | # doesn't support this. | |
87 | 'hotkeys': ['Henkan,Zenkaku_Hankaku', '', ''], | |
88 | 85 | }, |
89 | 86 | } |
90 | 87 | |
164 | 161 | for key in engine_common: |
165 | 162 | OutputCppVariable(product_name, 'Engine', key, engine_common[key]) |
166 | 163 | for key in engines: |
167 | if key == 'hotkeys': | |
168 | # Skip hotkeys because it is not used from C++ code. | |
169 | continue | |
170 | 164 | print 'const char* kEngine%sArray[] = {' % key.capitalize() |
171 | 165 | for i in range(len(engines[key])): |
172 | 166 | print '"%s",' % EmbedProductName(product_name, engines[key][i]) |
139 | 139 | |
140 | 140 | int main(gint argc, gchar **argv) { |
141 | 141 | InitGoogle(argv[0], &argc, &argv, true); |
142 | #ifdef OS_CHROMEOS | |
143 | // On Chrome OS, mozc does not store the config data to a local file. | |
144 | mozc::config::ConfigHandler::SetConfigFileName("memory://config.1.db"); | |
145 | mozc::session::JapaneseSessionFactory session_factory; | |
146 | mozc::session::SessionFactoryManager::SetSessionFactory(&session_factory); | |
147 | #endif // OS_CHROMEOS | |
142 | 148 | ibus_init(); |
143 | 149 | InitIBusComponent(FLAGS_ibus); |
144 | 150 | #ifdef OS_CHROMEOS |
145 | // On Chrome OS, mozc does not store the config data to a local file. | |
146 | mozc::config::ConfigHandler::SetConfigFileName("memory://config.1.db"); | |
147 | 151 | mozc::ibus::MozcEngine::InitConfig(g_config); |
148 | mozc::session::JapaneseSessionFactory session_factory; | |
149 | mozc::session::SessionFactoryManager::SetSessionFactory(&session_factory); | |
150 | 152 | #else |
151 | 153 | #ifndef NO_LOGGING |
152 | 154 | EnableVerboseLog(); |
948 | 948 | |
949 | 949 | for (int i = 0; i < candidates.candidate_size(); ++i) { |
950 | 950 | const commands::Candidates::Candidate &candidate = candidates.candidate(i); |
951 | ||
952 | #ifdef OS_CHROMEOS | |
953 | const bool has_description = candidate.has_annotation() && | |
954 | candidate.annotation().has_description(); | |
955 | IBusText *text = NULL; | |
956 | if (has_description) { | |
957 | // |kDelimiter| divides a candidate and an annotation. | |
958 | static const char kDelimiter[] = " "; | |
959 | ||
960 | // Append an annotation to a candidate word. Both are separated | |
961 | // by |kDelimiter|. | |
962 | text = ibus_text_new_from_string( | |
963 | (candidate.value() + kDelimiter + | |
964 | candidate.annotation().description()).c_str()); | |
965 | ||
966 | // The candidate window on Chrome OS will know | |
967 | // the start index of an annotation by specific number (e.g. 0x888888). | |
968 | // TODO(nhiroki): We should modify the way when iBus supports annotations. | |
969 | const guint kAnnotationForegroundColor = 0x888888; | |
970 | ||
971 | // Insert an attribute. It incidates annotation's | |
972 | // start and end index. | |
973 | const guint start = Util::CharsLen(candidate.value() + kDelimiter); | |
974 | const guint end = start + | |
975 | Util::CharsLen(candidate.annotation().description()); | |
976 | ibus_text_append_attribute(text, | |
977 | IBUS_ATTR_TYPE_FOREGROUND, | |
978 | kAnnotationForegroundColor, | |
979 | start, | |
980 | end); | |
981 | } else { | |
982 | text = ibus_text_new_from_string(candidate.value().c_str()); | |
983 | } | |
984 | #else | |
985 | 951 | IBusText *text = ibus_text_new_from_string(candidate.value().c_str()); |
986 | #endif | |
987 | ||
988 | 952 | ibus_lookup_table_append_candidate(table, text); |
989 | 953 | // |text| is released by ibus_engine_update_lookup_table along with |table|. |
990 | 954 | |
1002 | 966 | // |label| is released by ibus_engine_update_lookup_table along with |
1003 | 967 | // |table|. |
1004 | 968 | } |
969 | ||
970 | #if defined(OS_CHROMEOS) and IBUS_CHECK_VERSION(1, 3, 99) | |
971 | // The function ibus_serializable_set_attachment() had been changed | |
972 | // to use GVariant in ibus-1.3.99. | |
973 | // https://github.com/ibus/ibus/commit/ac9dfac13cef34288440a2ecdf067cd827fb2f8f | |
974 | // But these codes are valid only for ChromeOS since: | |
975 | // 1) IBus's default panel (main.py) does not support the attachment. | |
976 | // 2) Ubuntu 10.10 uses ibus-1.3.99, but the version of ibus it uses is | |
977 | // very old. | |
978 | // If we only use IBUS_CHECK_VERSION, ibus-mozc does not compile on | |
979 | // Ubuntu 10.10. | |
980 | // Also we do not use only OS_CHROMEOS, because we will compile ibus-mozc for | |
981 | // ChromeOS on Ubuntu for debugging even if following feature is missed. | |
982 | if (output.has_candidates()) { | |
983 | string buf; | |
984 | output.candidates().SerializeToString(&buf); | |
985 | ||
986 | GByteArray *bytearray = g_byte_array_sized_new(buf.length()); | |
987 | g_byte_array_append(bytearray, | |
988 | reinterpret_cast<const guint8*>(buf.c_str()), buf.length()); | |
989 | GVariant* variant = g_variant_new_from_data(G_VARIANT_TYPE("ay"), | |
990 | bytearray->data, bytearray->len, TRUE, | |
991 | reinterpret_cast<GDestroyNotify>(g_byte_array_unref), bytearray); | |
992 | ibus_serializable_set_attachment( | |
993 | IBUS_SERIALIZABLE(table), "mozc.candidates", variant); | |
994 | } | |
995 | #endif | |
996 | ||
1005 | 997 | ibus_engine_update_lookup_table(engine, table, TRUE); |
1006 | 998 | // |table| is released by ibus_engine_update_lookup_table. |
1007 | 999 |
47 | 47 | mozc::client::ServerLauncherInterface *server_launcher, |
48 | 48 | mozc::IPCClientFactoryInterface *client_factory) |
49 | 49 | : translator_(new ScimKeyTranslator), |
50 | server_launcher_(server_launcher), | |
51 | client_factory_(client_factory), | |
52 | 50 | preedit_method_(mozc::config::Config::ROMAN) { |
53 | 51 | VLOG(1) << "MozcConnection is created"; |
54 | 52 | mozc::client::ClientInterface *client = |
55 | 53 | mozc::client::ClientFactory::NewClient(); |
56 | client->SetServerLauncher(server_launcher_); | |
57 | client->SetIPCClientFactory(client_factory_.get()); | |
54 | client->SetServerLauncher(server_launcher); | |
55 | client->SetIPCClientFactory(client_factory); | |
58 | 56 | client_.reset(client); |
59 | 57 | |
60 | 58 | mozc::config::Config config; |
123 | 123 | |
124 | 124 | const scoped_ptr<ScimKeyTranslator> translator_; |
125 | 125 | scoped_ptr<mozc::client::ClientInterface> client_; |
126 | mozc::client::ServerLauncherInterface *server_launcher_; | |
127 | scoped_ptr<mozc::IPCClientFactoryInterface> client_factory_; | |
128 | 126 | mozc::config::Config::PreeditMethod preedit_method_; |
129 | 127 | |
130 | 128 | DISALLOW_COPY_AND_ASSIGN(MozcConnection); |