2 * @file scim_helper_module.h
3 * @brief Defines scim::HelperModule and it's related types.
5 * scim::HelperModule is a class used to load Client Helper modules.
9 /* ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable. */
12 * Smart Common Input Method
14 * Copyright (c) 2004-2005 James Su <suzhe@tsinghua.org.cn>
17 * This library is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU Lesser General Public
19 * License as published by the Free Software Foundation; either
20 * version 2 of the License, or (at your option) any later version.
22 * This library is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU Lesser General Public License for more details.
27 * You should have received a copy of the GNU Lesser General Public
28 * License along with this program; if not, write to the
29 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
30 * Boston, MA 02111-1307 USA
32 * $Id: scim_helper_module.h,v 1.6 2005/01/10 08:30:54 suzhe Exp $
35 #ifndef __SCIM_HELPER_MODULE_H
36 #define __SCIM_HELPER_MODULE_H
42 * @ingroup InputServiceFramework
47 * @brief Get the number of Helpers in this module.
49 * A helper module can have multiple Helpers in it.
50 * But each helper will run in its own process space.
52 * There must be a function called "scim_helper_module_number_of_helpers"
53 * in each helper module which complies with this prototype.
54 * This function name can have a prefix like kbd_LTX_,
55 * in which "kbd" is the module's name.
57 typedef unsigned int (*HelperModuleNumberOfHelpersFunc) (void);
60 * @brief Get the information of a Helper.
62 * There must be a function called "scim_helper_module_get_helper_info"
63 * in each helper module which complies with this prototype.
64 * This function name can have a prefix like kbd_LTX_,
65 * in which "kbd" is the module's name.
67 * @param idx The index of this helper, must between 0 to (the number of helpers) - 1.
68 * @param info The HelperInfo object to store the information.
69 * @return true if this Helper is valid and the correct information is stored into info.
71 typedef bool (*HelperModuleGetHelperInfoFunc) (unsigned int idx, HelperInfo &info);
74 * @brief Get the language of a Helper.
76 * There must be a function called "scim_helper_module_get_helper_language"
77 * in each helper module which complies with this prototype.
78 * This function name can have a prefix like kbd_LTX_,
79 * in which "kbd" is the module's name.
81 * @param idx The index of this helper, must between 0 to (the number of helpers) - 1.
82 * @return this Helper's language.
84 typedef String (*HelperModuleGetHelperLangFunc) (unsigned int idx);
87 * @brief Run a specific Helper.
89 * This function will be called within an independent process.
91 * There must be a function called "scim_helper_module_run_helper"
92 * in each helper module which complies with this prototype.
93 * This function name can have a prefix like kbd_LTX_,
94 * in which "kbd" is the module's name.
96 * @param config The Config object should be used to read/write configurations.
97 * @param uuid The UUID of the Helper to be run.
98 * @param display The display in which this helper should run.
100 typedef void (*HelperModuleRunHelperFunc) (const String &uuid, const ConfigPointer &config, const String &display);
104 * @brief The class used to load a Helper module and run its Helpers.
106 * This class should not be used directly. HelperManager should be used instead.
112 HelperModuleNumberOfHelpersFunc m_number_of_helpers;
113 HelperModuleGetHelperInfoFunc m_get_helper_info;
114 HelperModuleGetHelperLangFunc m_get_helper_lang;
115 HelperModuleRunHelperFunc m_run_helper;
117 HelperModule (const HelperModule &);
118 HelperModule & operator= (const HelperModule &);
122 * @brief Constructor.
124 * @param name The name of the Helper module to be loaded.
126 HelperModule (const String &name = String (""));
129 * @brief Load a Helper module.
131 * If a module has already been loaded, then it'll be unloaded first.
133 * @param name The name of the Helper module to be loaded.
134 * @return true if success.
136 bool load (const String &name);
139 * @brief Unload the module.
141 * @return true if success.
146 * @brief Check if a Helper module has been loaded successfully.
148 * @return true if a module has been loaded successfully.
153 * @brief Get the number of helpers supported by this module.
155 * @return the number of helpers supported by this module.
157 unsigned int number_of_helpers () const;
160 * @brief The the information of a specific helper.
162 * @param idx The index of the helper, must between 0 to number_of_helpers () - 1.
163 * @param info The HeperInfo object to store the information.
164 * @return true if this helper is ok and the information is stored into info successfully.
166 bool get_helper_info (unsigned int idx, HelperInfo &info) const;
169 * @brief The language of a specific helper.
171 * @param idx The index of the helper, must between 0 to number_of_helpers () - 1.
172 * @return this helper's language.
174 String get_helper_lang (unsigned int idx) const;
177 * @brief Run a specific helper.
179 * The helper should be run in an independent process, this function will not return
180 * until the helper exits.
182 * @param config The Config object to be used to read configurations.
183 * @param uuid The UUID of the helper, which is returned by get_helper_info ().
184 * @param display The display in which this helper should run.
186 void run_helper (const String &uuid, const ConfigPointer &config, const String &display) const;
190 * @brief Get a name list of currently available Helper modules.
191 * @param mod_list - the result list will be stored here.
192 * @return the number of the modules, equal to mod_list.size ().
194 int scim_get_helper_module_list (std::vector <String> &mod_list);
199 #endif //__SCIM_HELPER_MODULE_H
202 vi:ts=4:nowrap:ai:expandtab