1 /* ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable. */
4 * Smart Common Input Method
6 * Copyright (c) 2004-2005 James Su <suzhe@tsinghua.org.cn>
7 * Copyright (c) 2012-2015 Samsung Electronics Co., Ltd.
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this program; if not, write to the
22 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
23 * Boston, MA 02111-1307 USA
25 * Modifications by Samsung Electronics Co., Ltd.
26 * 1. Call set_arg_info () before run_helper ()
28 * $Id: scim_helper_launcher.cpp,v 1.6 2005/05/16 01:25:46 suzhe Exp $
32 #define Uses_SCIM_HELPER_MODULE
33 #define Uses_SCIM_GLOBAL_CONFIG
34 #define Uses_SCIM_CONFIG_PATH
36 #include "scim_private.h"
42 int main (int argc, char *argv [])
50 //bool daemon = false;
52 char *p = getenv ("DISPLAY");
53 if (p) display = String (p);
55 //In the normal situation, config should be set by CMD,
56 //if not provide, we assume have something wrong in
57 //server side, so using simple config as default
58 config = scim_global_config_read (SCIM_GLOBAL_CONFIG_DEFAULT_CONFIG_MODULE, String ("simple"));
61 if (++i >= argc) break;
63 if (String ("-c") == argv [i] ||
64 String ("--config") == argv [i]) {
66 std::cerr << "No argument for option " << argv [i-1] << "\n";
73 if (String ("-d") == argv [i] ||
74 String ("--daemon") == argv [i]) {
79 if (String ("--display") == argv [i]) {
81 std::cerr << "No argument for option " << argv [i-1] << "\n";
88 if (String ("-h") == argv [i] ||
89 String ("--help") == argv [i]) {
90 std::cout << "Usage: " << argv [0] << " [options] module appid\n\n"
91 << "The options are:\n"
92 << " -c, --config name Use specified config module, default is \"simple\".\n"
93 << " -d, --daemon Run as daemon.\n"
94 << " --display name run setup on a specified DISPLAY.\n"
95 << " -h, --help Show this help message.\n"
96 << "module The name of the Helper module\n"
97 << "appid The appid of the Helper to be launched.\n";
101 if (String ("-v") == argv [i] ||
102 String ("--verbose") == argv [i]) {
104 std::cerr << "No argument for option " << argv [i-1] << "\n";
107 DebugOutput::set_verbose_level (atoi (argv [i]));
111 if (String ("-m") == argv [i] ||
112 String ("--mask") == argv [i]) {
114 std::cerr << "No argument for option " << argv [i-1] << "\n";
117 if (String (argv [i]) != "none") {
118 std::vector<String> debug_mask_list;
119 scim_split_string_list (debug_mask_list, argv [i], ',');
120 DebugOutput::disable_debug (SCIM_DEBUG_AllMask);
121 for (size_t k=0; k<debug_mask_list.size (); k++)
122 DebugOutput::enable_debug_by_name (debug_mask_list [k]);
127 if (String ("-o") == argv [i] ||
128 String ("--output") == argv [i]) {
130 std::cerr << "No argument for option " << argv [i-1] << "\n";
133 DebugOutput::set_output (String (argv [i]));
140 helper = String (argv [i]);
143 appid = String (argv [i]);
148 String exec = argv[0];
150 if (exec != String (SCIM_HELPER_LAUNCHER_PROGRAM)) {
151 /* 3rd party shared object type IME */
152 helper = String ("lib") + exec.substr (exec.find_last_of (SCIM_PATH_DELIM) + 1);
156 SCIM_DEBUG_MAIN(1) << "scim-helper-launcher: " << config << " " << display << " " << helper << " " << appid << "\n";
157 ISF_SAVE_LOG ("Helper ISE (%s %s) is launching...", helper.c_str (), appid.c_str ());
159 if (!helper.length ()) {
160 ISF_SAVE_LOG ("Module name is missing");
162 std::cerr << "Module name is missing.\n";
166 HelperModule helper_module (helper);
168 if (!helper_module.valid () || helper_module.number_of_helpers () == 0) {
169 ISF_SAVE_LOG ("Unable to load helper module(%s)", helper.c_str ());
171 std::cerr << "Unable to load helper module(" << helper << ")\n";
175 ConfigPointer config_pointer = ConfigBase::get (true, config);
177 if (config_pointer.null ()) {
178 config_pointer = new DummyConfig ();
181 // if (daemon) scim_daemon ();
183 helper_module.set_arg_info (argc, argv);
184 helper_module.run_helper (appid, config_pointer, display);
185 helper_module.unload ();
187 if (!config_pointer.null ())
188 config_pointer.reset ();
190 ISF_SAVE_LOG ("Helper ISE (%s) is destroyed!!!", appid.c_str ());
194 vi:ts=4:nowrap:ai:expandtab