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>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this program; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
22 * Boston, MA 02111-1307 USA
24 * $Id: scim_helper_launcher.cpp,v 1.6 2005/05/16 01:25:46 suzhe Exp $
28 #define Uses_SCIM_HELPER_MODULE
29 #define Uses_SCIM_GLOBAL_CONFIG
30 #define Uses_SCIM_CONFIG_PATH
32 #include "scim_private.h"
34 #include <privilege-control.h>
38 int main (int argc, char *argv [])
50 char *p = getenv ("DISPLAY");
51 if (p) display = String (p);
53 config = scim_global_config_read (SCIM_GLOBAL_CONFIG_DEFAULT_CONFIG_MODULE, String ("simple"));
56 if (++i >= argc) break;
58 if (String ("-c") == argv [i] ||
59 String ("--config") == argv [i]) {
61 std::cerr << "No argument for option " << argv [i-1] << "\n";
68 if (String ("-d") == argv [i] ||
69 String ("--daemon") == argv [i]) {
74 if (String ("--display") == argv [i]) {
76 std::cerr << "No argument for option " << argv [i-1] << "\n";
83 if (String ("-h") == argv [i] ||
84 String ("--help") == argv [i]) {
85 std::cout << "Usage: " << argv [0] << " [options] module uuid\n\n"
86 << "The options are:\n"
87 << " -c, --config name Use specified config module, default is \"simple\".\n"
88 << " -d, --daemon Run as daemon.\n"
89 << " --display name run setup on a specified DISPLAY.\n"
90 << " -h, --help Show this help message.\n"
91 << "module The name of the Helper module\n"
92 << "uuid The uuid of the Helper to be launched.\n";
96 if (String ("-v") == argv [i] ||
97 String ("--verbose") == argv [i]) {
99 std::cerr << "No argument for option " << argv [i-1] << "\n";
102 DebugOutput::set_verbose_level (atoi (argv [i]));
106 if (String ("-m") == argv [i] ||
107 String ("--mask") == argv [i]) {
109 std::cerr << "No argument for option " << argv [i-1] << "\n";
112 if (String (argv [i]) != "none") {
113 std::vector<String> debug_mask_list;
114 scim_split_string_list (debug_mask_list, argv [i], ',');
115 DebugOutput::disable_debug (SCIM_DEBUG_AllMask);
116 for (size_t j=0; j<debug_mask_list.size (); j++)
117 DebugOutput::enable_debug_by_name (debug_mask_list [j]);
122 if (String ("-o") == argv [i] ||
123 String ("--output") == argv [i]) {
125 std::cerr << "No argument for option " << argv [i-1] << "\n";
128 DebugOutput::set_output (String (argv [i]));
135 helper = String (argv [i]);
138 uuid = String (argv [i]);
142 std::cerr << "Invalid command line option: " << argv [i] << "\n";
146 SCIM_DEBUG_MAIN(1) << "scim-helper-launcher: " << config << " " << display << " " << helper << " " << uuid << "\n";
148 if (!helper.length () || !uuid.length ()) {
149 std::cerr << "Module name or Helper UUID is missing.\n";
153 HelperModule helper_module (helper);
155 if (!helper_module.valid () || helper_module.number_of_helpers () == 0) {
156 std::cerr << "Unable to load Helper module: " << helper << "\n";
160 ConfigModule config_module (config);
162 ConfigPointer config_pointer;
164 if (config_module.valid ()) {
165 config_pointer = config_module.create_config ();
168 if (config_pointer.null ()) {
169 config_pointer = new DummyConfig ();
172 // if (daemon) scim_daemon ();
174 helper_module.run_helper (uuid, config_pointer, display);
176 if (!config_pointer.null ())
177 config_pointer.reset ();
183 vi:ts=4:nowrap:ai:expandtab