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 (); } }
void IMContextImpl::set_enabled (bool status) { enabled = status; if (imengine != NULL) { imengine->focus_out (); imengine->reset (); } BackEndPointer scim_backend = scim_console->get_scim_backend (); const String scim_language = scim_console->get_scim_language (); if (enabled) { IMEngineFactoryPointer factory = scim_backend->get_default_factory (scim_language, "UTF-8"); if (factory != NULL) { imengine = factory->create_instance ("UTF-8", imengine_id); ++imengine_id; } } else { imengine = NULL; } if (imengine == NULL) { imengine = fallback_imengine; factory_info = PanelFactoryInfo (String (""), String (_ ("English/Keyboard")), String ("C"), String (SCIM_KEYBOARD_ICON_FILE)); } else { IMEngineFactoryPointer factory = scim_backend->get_factory (imengine->get_factory_uuid ()); factory_info = PanelFactoryInfo (factory->get_uuid (), utf8_wcstombs (factory->get_name ()), factory->get_language (), factory->get_icon_file ()); imengine->signal_connect_show_preedit_string (slot (slot_show_preedit)); imengine->signal_connect_show_aux_string (slot (slot_show_aux)); imengine->signal_connect_show_lookup_table (slot (slot_show_lookup_table)); imengine->signal_connect_hide_preedit_string (slot (slot_hide_preedit)); imengine->signal_connect_hide_aux_string (slot (slot_hide_aux)); imengine->signal_connect_hide_lookup_table (slot (slot_hide_lookup_table)); imengine->signal_connect_update_preedit_caret (slot (slot_update_preedit_cursor_position)); imengine->signal_connect_update_preedit_string (slot (slot_update_preedit_string)); imengine->signal_connect_update_aux_string (slot (slot_update_aux_string)); imengine->signal_connect_update_lookup_table (slot (slot_update_lookup_table)); imengine->signal_connect_commit_string (slot (slot_commit)); imengine->signal_connect_forward_key_event (slot (slot_forward_key_event)); imengine->signal_connect_register_properties (slot (slot_register_properties)); imengine->signal_connect_update_property (slot (slot_update_property)); imengine->signal_connect_beep (slot (slot_beep)); imengine->signal_connect_start_helper (slot (slot_start_helper)); imengine->signal_connect_stop_helper (slot (slot_stop_helper)); imengine->signal_connect_send_helper_event (slot (slot_send_helper_event)); imengine->signal_connect_get_surrounding_text (slot (slot_get_surrounding_text)); imengine->signal_connect_delete_surrounding_text (slot (slot_delete_surrounding_text)); } imengine->focus_in (); }
/** * @brief Load all ISEs to initialize. * * @param type The loading ISE type. * @param config The config pointer for loading keyboard ISE. * @param uuids The ISE uuid list. * @param names The ISE name list. * @param module_names The ISE module name list. * @param langs The ISE language list. * @param icons The ISE icon list. * @param modes The ISE type list. * @param options The ISE option list. * @param ise_list The already loaded ISE list. */ void isf_get_factory_list (LOAD_ISE_TYPE type, const ConfigPointer &config, std::vector<String> &uuids, std::vector<String> &names, std::vector<String> &module_names, std::vector<String> &langs, std::vector<String> &icons, std::vector<TOOLBAR_MODE_T> &modes, std::vector<uint32> &options, const std::vector<String> &ise_list) { uuids.clear (); names.clear (); module_names.clear (); langs.clear (); icons.clear (); modes.clear (); options.clear (); _groups.clear (); if (type != HELPER_ONLY) { /* Add "English/Keyboard" factory first. */ IMEngineFactoryPointer factory = new ComposeKeyFactory (); uuids.push_back (factory->get_uuid ()); names.push_back (utf8_wcstombs (factory->get_name ())); module_names.push_back (ENGLISH_KEYBOARD_MODULE); langs.push_back (isf_get_normalized_language (factory->get_language ())); icons.push_back (factory->get_icon_file ()); modes.push_back (TOOLBAR_KEYBOARD_MODE); options.push_back (0); factory.reset (); } String user_file_name = String (USER_ENGINE_FILE_NAME); FILE *engine_list_file = fopen (user_file_name.c_str (), "r"); if (engine_list_file == NULL) { std::cerr << user_file_name << " doesn't exist.\n"; return; } char buf[MAXLINE]; while (fgets (buf, MAXLINE, engine_list_file) != NULL) { ISEINFO info; isf_get_ise_info_from_string (buf, info); if (info.mode == TOOLBAR_HELPER_MODE || type != HELPER_ONLY) { names.push_back (info.name); uuids.push_back (info.uuid); module_names.push_back (info.module); langs.push_back (info.language); icons.push_back (info.icon); modes.push_back (info.mode); options.push_back (info.option); } } fclose (engine_list_file); }
void IMContextImpl::change_imengine (IMEngineFactoryPointer new_factory) { if (imengine != NULL) { imengine->focus_out (); imengine->reset (); } BackEndPointer scim_backend = scim_console->get_scim_backend (); scim_backend->set_default_factory (scim_console->get_scim_language (), new_factory->get_uuid ()); imengine = new_factory->create_instance ("UTF-8", imengine_id); ++imengine_id; factory_info = PanelFactoryInfo (new_factory->get_uuid (), utf8_wcstombs (new_factory->get_name ()), new_factory->get_language (), new_factory->get_icon_file ()); if (imengine != NULL) { imengine->signal_connect_show_preedit_string (slot (slot_show_preedit)); imengine->signal_connect_show_aux_string (slot (slot_show_aux)); imengine->signal_connect_show_lookup_table (slot (slot_show_lookup_table)); imengine->signal_connect_hide_preedit_string (slot (slot_hide_preedit)); imengine->signal_connect_hide_aux_string (slot (slot_hide_aux)); imengine->signal_connect_hide_lookup_table (slot (slot_hide_lookup_table)); imengine->signal_connect_update_preedit_caret (slot (slot_update_preedit_cursor_position)); imengine->signal_connect_update_preedit_string (slot (slot_update_preedit_string)); imengine->signal_connect_update_aux_string (slot (slot_update_aux_string)); imengine->signal_connect_update_lookup_table (slot (slot_update_lookup_table)); imengine->signal_connect_commit_string (slot (slot_commit)); imengine->signal_connect_forward_key_event (slot (slot_forward_key_event)); imengine->signal_connect_register_properties (slot (slot_register_properties)); imengine->signal_connect_update_property (slot (slot_update_property)); imengine->signal_connect_beep (slot (slot_beep)); imengine->signal_connect_start_helper (slot (slot_start_helper)); imengine->signal_connect_stop_helper (slot (slot_stop_helper)); imengine->signal_connect_send_helper_event (slot (slot_send_helper_event)); imengine->signal_connect_get_surrounding_text (slot (slot_get_surrounding_text)); imengine->signal_connect_delete_surrounding_text (slot (slot_delete_surrounding_text)); } preedit_string.clear (); preedit_attributes.clear (); preedit_cursor_position = 0; preedit_shown = false; enabled = true; imengine->focus_in (); }
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; }