From: InHong Han Date: Wed, 13 Sep 2017 09:00:02 +0000 (+0900) Subject: Fixed the problem that does not have access to ime_info DB in encrytion mode X-Git-Tag: accepted/tizen/unified/20171018.062657~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4c6d7c3fe7fac4234d5dc35d2b9b1cf6dd1d5020;p=platform%2Fcore%2Fuifw%2Fisf.git Fixed the problem that does not have access to ime_info DB in encrytion mode Change-Id: I8e04e53554f3ed64e5bced4a3852fc64eebbfc87 (cherry picked from commit e3940693421978eee9881c401de2983c70586a95) --- diff --git a/ism/extras/efl_panel/isf_panel_efl.cpp b/ism/extras/efl_panel/isf_panel_efl.cpp index 82cb0d5..feb9428 100644 --- a/ism/extras/efl_panel/isf_panel_efl.cpp +++ b/ism/extras/efl_panel/isf_panel_efl.cpp @@ -1811,6 +1811,188 @@ static bool set_helper_ise (const String &uuid, bool launch_ise) return true; } +#ifdef HAVE_PKGMGR_INFO +int get_ime_app_list_cb (const pkgmgrinfo_appinfo_h handle, void *user_data) +{ + int ret = 0; + char *appid = NULL, *pkgid = NULL, *pkgtype = NULL, *exec = NULL, *label = NULL, *path = NULL; + pkgmgrinfo_pkginfo_h pkginfo_handle = NULL; + ImeInfoDB ime_db; + int *result = static_cast(user_data); + + if (result) /* in this case, need to check category */ { + bool exist = true; + ret = pkgmgrinfo_appinfo_is_category_exist (handle, "http://tizen.org/category/ime", &exist); + if (ret != PMINFO_R_OK || !exist) { + return 0; + } + } + + /* appid */ + ret = pkgmgrinfo_appinfo_get_appid (handle, &appid); + if (ret == PMINFO_R_OK) + ime_db.appid = String (appid ? appid : ""); + else { + LOGE ("pkgmgrinfo_appinfo_get_appid failed! error code=%d", ret); + return 0; + } + + ime_db.iconpath = ""; + + /* pkgid */ + ret = pkgmgrinfo_appinfo_get_pkgid (handle, &pkgid); + if (ret == PMINFO_R_OK) + ime_db.pkgid = String (pkgid ? pkgid : ""); + else { + LOGE ("pkgmgrinfo_appinfo_get_pkgid failed! error code=%d", ret); + return 0; + } + + /* exec path */ + ret = pkgmgrinfo_appinfo_get_exec (handle, &exec); + if (ret == PMINFO_R_OK) + ime_db.exec = String (exec ? exec : ""); + else { + LOGE ("pkgmgrinfo_appinfo_get_exec failed! error code=%d", ret); + return 0; + } + + /* label */ + ret = pkgmgrinfo_appinfo_get_label (handle, &label); + if (ret == PMINFO_R_OK) + ime_db.label = String (label ? label : ""); + + /* get pkgmgrinfo_pkginfo_h */ + /* Try to get in global packages */ + ret = pkgmgrinfo_pkginfo_get_pkginfo (pkgid, &pkginfo_handle); + if (ret != PMINFO_R_OK) { + /* Try to get in user packages */ + ret = pkgmgrinfo_pkginfo_get_usr_pkginfo (pkgid, getpid (), &pkginfo_handle); + } + + if (ret == PMINFO_R_OK && pkginfo_handle) { + /* pkgtype */ + ret = pkgmgrinfo_pkginfo_get_type (pkginfo_handle, &pkgtype); + + if (ret == PMINFO_R_OK) + ime_db.pkgtype = String (pkgtype ? pkgtype : ""); + else { + ISF_SAVE_LOG ("pkgtype is not available!"); + pkgmgrinfo_pkginfo_destroy_pkginfo (pkginfo_handle); + return 0; + } + + /* pkgrootpath */ + pkgmgrinfo_pkginfo_get_root_path (pkginfo_handle, &path); + } + + ime_db.languages = "en"; + ime_db.display_lang = ""; + + if (ime_db.pkgtype.compare ("rpm") == 0 && //1 Inhouse IMEngine ISE(IME) + ime_db.exec.find ("scim-launcher") != String::npos) // Some IMEngine's pkgid doesn't have "ise-engine" prefix. + { + ime_db.mode = TOOLBAR_KEYBOARD_MODE; + ime_db.options = 0; + ime_db.module_path = String (SCIM_MODULE_PATH) + String (SCIM_PATH_DELIM_STRING) + String (SCIM_BINARY_VERSION) + + String (SCIM_PATH_DELIM_STRING) + String ("IMEngine"); + ime_db.module_name = ime_db.pkgid; + ime_db.is_enabled = 1; + ime_db.is_preinstalled = 1; + ime_db.has_option = 0; // It doesn't matter. No option for IMEngine... + } + else { + ime_db.mode = TOOLBAR_HELPER_MODE; + if (ime_db.pkgtype.compare ("rpm") == 0) //1 Inhouse Helper ISE(IME) + { +#ifdef _TV + ime_db.options = SCIM_HELPER_STAND_ALONE | SCIM_HELPER_NEED_SCREEN_INFO | SCIM_HELPER_AUTO_RESTART | ISM_HELPER_PROCESS_KEYBOARD_KEYEVENT; +#else + ime_db.options = SCIM_HELPER_STAND_ALONE | SCIM_HELPER_NEED_SCREEN_INFO | SCIM_HELPER_AUTO_RESTART; +#endif + ime_db.module_name = ime_db.pkgid; + + String module_path = String (path) + String ("/lib"); + String fullpath = module_path + String (SCIM_PATH_DELIM_STRING) + ime_db.module_name + String (".so"); + struct stat st; + if (stat (fullpath.c_str (), &st) < 0) { + /* Not found in lib directory of package's root path */ + ime_db.module_path = String (SCIM_MODULE_PATH) + String (SCIM_PATH_DELIM_STRING) + String (SCIM_BINARY_VERSION) + + String (SCIM_PATH_DELIM_STRING) + String ("Helper"); + } + else { + ime_db.module_path = module_path; + } + + ime_db.is_enabled = 1; + ime_db.is_preinstalled = 1; + ime_db.has_option = 1; // Let's assume the inhouse IME always has an option menu. + } + else if (ime_db.pkgtype.compare ("wgt") == 0) //1 Download Web IME + { + ime_db.options = SCIM_HELPER_STAND_ALONE | SCIM_HELPER_NEED_SCREEN_INFO | SCIM_HELPER_AUTO_RESTART + | SCIM_HELPER_NEED_SPOT_LOCATION_INFO | ISM_HELPER_PROCESS_KEYBOARD_KEYEVENT | ISM_HELPER_WITHOUT_IMENGINE; + ime_db.module_path = String (SCIM_MODULE_PATH) + String (SCIM_PATH_DELIM_STRING) + String (SCIM_BINARY_VERSION) + + String (SCIM_PATH_DELIM_STRING) + String ("Helper"); + ime_db.module_name = String ("ise-web-helper-agent"); + if (ime_db.exec.compare (0, 5, "/usr/") == 0) { + ime_db.is_enabled = 1; + ime_db.is_preinstalled = 1; + } + else { +#ifdef _MOBILE + ime_db.is_enabled = 0; +#else + ime_db.is_enabled = 1; +#endif + ime_db.is_preinstalled = 0; + } + ime_db.has_option = -1; // At this point, we can't know IME has an option (setting) or not; -1 means unknown. + } + else if (ime_db.pkgtype.compare ("tpk") == 0) //1 Download Native IME + { + ime_db.options = SCIM_HELPER_STAND_ALONE | SCIM_HELPER_NEED_SCREEN_INFO | SCIM_HELPER_AUTO_RESTART + | ISM_HELPER_PROCESS_KEYBOARD_KEYEVENT | ISM_HELPER_WITHOUT_IMENGINE; + if (path) + ime_db.module_path = String (path) + String ("/lib"); + else + ime_db.module_path = String (tzplatform_getenv(TZ_SYS_RW_APP)) + ime_db.pkgid + String ("/lib"); + ime_db.module_name = String ("lib") + ime_db.exec.substr (ime_db.exec.find_last_of (SCIM_PATH_DELIM) + 1); + if (ime_db.exec.compare (0, 5, "/usr/") == 0) { + ime_db.is_enabled = 1; + ime_db.is_preinstalled = 1; + } + else { +#ifdef _MOBILE + ime_db.is_enabled = 0; +#else + ime_db.is_enabled = 1; +#endif + ime_db.is_preinstalled = 0; + } + ime_db.has_option = -1; // At this point, we can't know IME has an option (setting) or not; -1 means unknown. + } + else { + LOGE ("Unsupported pkgtype(%s)", ime_db.pkgtype.c_str ()); + if (pkginfo_handle) { + pkgmgrinfo_pkginfo_destroy_pkginfo (pkginfo_handle); + pkginfo_handle = NULL; + } + return 0; + } + } + + _ime_info.push_back(ime_db); + + if (pkginfo_handle) { + pkgmgrinfo_pkginfo_destroy_pkginfo (pkginfo_handle); + pkginfo_handle = NULL; + } + + return 0; +} +#endif + /** * @brief Set active ISE. * @@ -1829,6 +2011,25 @@ static bool set_active_ise (const String &uuid, bool launch_ise) bool ise_changed = false, valid = false; + if (_ime_info.size () == 0) { +#ifdef HAVE_PKGMGR_INFO + pkgmgrinfo_appinfo_filter_h handle; + int ret = pkgmgrinfo_appinfo_filter_create (&handle); + if (ret == PMINFO_R_OK) { + ret = pkgmgrinfo_appinfo_filter_add_string (handle, PMINFO_APPINFO_PROP_APP_CATEGORY, "http://tizen.org/category/ime"); + if (ret == PMINFO_R_OK) + ret = pkgmgrinfo_appinfo_filter_foreach_appinfo (handle, get_ime_app_list_cb, NULL); + else { + LOGE ("pkgmgrinfo_appinfo_filter_add_string failed(%d)", ret); + } + pkgmgrinfo_appinfo_filter_destroy (handle); + } + else { + LOGE ("pkgmgrinfo_appinfo_filter_create failed(%d)", ret); + } +#endif + } + for (unsigned int i = 0; i < _ime_info.size (); i++) { if (!uuid.compare (_ime_info[i].appid)) { if (TOOLBAR_KEYBOARD_MODE == _ime_info[i].mode)