1// Copyright 2010-2018, Google Inc. 2// All rights reserved. 3// 4// Redistribution and use in source and binary forms, with or without 5// modification, are permitted provided that the following conditions are 6// met: 7// 8// * Redistributions of source code must retain the above copyright 9// notice, this list of conditions and the following disclaimer. 10// * Redistributions in binary form must reproduce the above 11// copyright notice, this list of conditions and the following disclaimer 12// in the documentation and/or other materials provided with the 13// distribution. 14// * Neither the name of Google Inc. nor the names of its 15// contributors may be used to endorse or promote products derived from 16// this software without specific prior written permission. 17// 18// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 30#import <Carbon/Carbon.h> 31#import <Cocoa/Cocoa.h> 32#import <InputMethodKit/IMKServer.h> 33 34#include <memory> 35 36#import "mac/GoogleJapaneseInputController.h" 37#import "mac/GoogleJapaneseInputServer.h" 38 39#include "base/const.h" 40#include "base/crash_report_handler.h" 41#include "base/flags.h" 42#include "base/init_mozc.h" 43#include "base/logging.h" 44#include "base/run_level.h" 45#include "client/client.h" 46#include "config/stats_config_util.h" 47 48int main(int argc, char *argv[]) { 49 if (!mozc::RunLevel::IsValidClientRunLevel()) { 50 return -1; 51 } 52 53 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 54#ifdef GOOGLE_JAPANESE_INPUT_BUILD 55 if (mozc::config::StatsConfigUtil::IsEnabled()) { 56 mozc::CrashReportHandler::Initialize(false); 57 } 58#endif 59 mozc::InitMozc(argv[0], &argc, &argv, false); 60 61 IMKServer *imkServer = [GoogleJapaneseInputServer getServer]; 62 if (!imkServer) { 63 LOG(FATAL) << mozc::kProductNameInEnglish << " failed to initialize"; 64 return -1; 65 } 66 DLOG(INFO) << mozc::kProductNameInEnglish << " initialized"; 67 68 [GoogleJapaneseInputController initializeConstants]; 69 70 // Start the converter server at this time explicitly to prevent the 71 // slow-down of the response for initial key event. 72 { 73 std::unique_ptr<mozc::client::Client> client(new mozc::client::Client); 74 client->PingServer(); 75 } 76 NSApplicationMain(argc, (const char **)argv); 77 [pool drain]; 78#ifdef GOOGLE_JAPANESE_INPUT_BUILD 79 mozc::CrashReportHandler::Uninitialize(); 80#endif 81 return 0; 82} 83