static void add_keyboard_info_to_list (std::vector<ISEINFO> &info_list, const char *module_name, const ConfigPointer &config) { if (module_name == NULL) return; IMEngineFactoryPointer factory; IMEngineModule ime_module; ime_module.load (module_name, config); if (ime_module.valid ()) { for (size_t j = 0; j < ime_module.number_of_factories (); ++j) { try { factory = ime_module.create_factory (j); } catch (...) { factory.reset (); } if (!factory.null ()) { ISEINFO info; info.name = utf8_wcstombs (factory->get_name ()); info.uuid = factory->get_uuid (); info.module = module_name; info.language = isf_get_normalized_language (factory->get_language ()); info.icon = factory->get_icon_file (); info.mode = TOOLBAR_KEYBOARD_MODE; info.option = 0; info.locales = factory->get_locales (); info_list.push_back (info); factory.reset (); } } ime_module.unload (); } }
IMEngineFactoryPointer scim_imengine_module_create_factory (uint32 engine) { SCIM_DEBUG_IMENGINE (3) << "entering scim_imengine_module_create_factory()\n"; if (engine != 0) return IMEngineFactoryPointer (0); if (_scim_pinyin_factory.null ()) { SunPyFactory *factory = new SunPyFactory (_scim_config); if (factory->valid ()) _scim_pinyin_factory = factory; else delete factory; } return _scim_pinyin_factory; }
const String IMContextImpl::get_help_string () const { String help_string = String (_ ("Smart Common Input Method platform ")) + String (SCIM_VERSION) + String (_ ("\n(C) 2002-2005 James Su <*****@*****.**>\n\n")); IMEngineFactoryPointer factory = scim_console->get_scim_backend ()->get_factory (imengine->get_factory_uuid ()); if (!factory.null ()) { help_string += utf8_wcstombs (factory->get_name ()); help_string += String (_ (":\n\n")); help_string += utf8_wcstombs (factory->get_authors ()); help_string += String (_ ("\n\n")); help_string += utf8_wcstombs (factory->get_help ()); help_string += String (_ ("\n\n")); help_string += utf8_wcstombs (factory->get_credits ()); } return help_string; }
/** * @brief Load one keyboard ISE module. * * @param module_name The keboard ISE module name. * @param config The config pointer for loading keyboard ISE. * * @return true if load module is successful, otherwise return false. */ static bool add_keyboard_ise_module (const String module_name, const ConfigPointer &config) { if (module_name.length () <= 0 || module_name == "socket") return false; IMEngineFactoryPointer factory; IMEngineModule ime_module; String filename = String (USER_ENGINE_FILE_NAME); FILE *engine_list_file = fopen (filename.c_str (), "a"); if (engine_list_file == NULL) { std::cerr << "failed to open " << filename << "\n"; return false; } ime_module.load (module_name, config); if (ime_module.valid ()) { for (size_t j = 0; j < ime_module.number_of_factories (); ++j) { try { factory = ime_module.create_factory (j); } catch (...) { factory.reset (); } if (!factory.null ()) { if (std::find (_uuids.begin (), _uuids.end (), factory->get_uuid ()) == _uuids.end ()) { String uuid = factory->get_uuid (); String name = utf8_wcstombs (factory->get_name ()); String language = isf_get_normalized_language (factory->get_language ()); String icon = factory->get_icon_file (); char mode[12]; char option[12]; _uuids.push_back (uuid); _names.push_back (name); _module_names.push_back (module_name); _langs.push_back (language); _icons.push_back (icon); _modes.push_back (TOOLBAR_KEYBOARD_MODE); _options.push_back (0); snprintf (mode, sizeof (mode), "%d", (int)TOOLBAR_KEYBOARD_MODE); snprintf (option, sizeof (option), "%d", 0); String line = isf_combine_ise_info_string (name, uuid, module_name, language, icon, String (mode), String (option), factory->get_locales ()); if (fputs (line.c_str (), engine_list_file) < 0) { std::cerr << "write to ise cache file failed:" << line << "\n"; break; } } factory.reset (); } } ime_module.unload (); } fclose (engine_list_file); return true; }