From: InHong Han Date: Wed, 24 Aug 2022 11:08:57 +0000 (+0900) Subject: Support to get IME setting using metadata X-Git-Tag: accepted/tizen/7.0/unified/20221110.061510~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F53%2F280153%2F1;p=platform%2Fcore%2Fuifw%2Fisf.git Support to get IME setting using metadata Change-Id: Ibd4af2b941b942fec483057b2a5236069ab7832d --- diff --git a/ism/src/isf_pkg.cpp b/ism/src/isf_pkg.cpp index 0d4cc6f..22664b8 100644 --- a/ism/src/isf_pkg.cpp +++ b/ism/src/isf_pkg.cpp @@ -50,6 +50,7 @@ using namespace scim; static String ime_setting_app; +static bool setting_app_changed; #ifdef HAVE_PKGMGR_INFO /** @@ -313,6 +314,29 @@ int isf_pkg_select_all_ime_info_db(std::vector &ime_info) #ifdef HAVE_PKGMGR_INFO /** + * @brief Finds ime_setting with specific metadata + * + * @return 0 if success, negative value(<0) if fail. Callback is not called if return value is negative + */ +static int _metadata_func (const char *key, const char *value, void *user_data) +{ + if (!user_data) { + LOGW ("user_data is null!"); + return -1; + } + + String ime_pkgid = String(static_cast(user_data)); + LOGD ("key : %s, value : %s, ime pkg id : %s", key, value, ime_pkgid.c_str ()); + + if (strncmp (key, "ime-package-id", strlen (key)) == 0 && strncmp (value, ime_pkgid.c_str (), strlen (value)) == 0) { + setting_app_changed = true; + return -1; + } + + return 0; +} + +/** * @brief Finds appid with specific category * * @return 0 if success, negative value(<0) if fail. Callback is not called if return value is negative @@ -346,6 +370,24 @@ static int _find_ime_setting (const pkgmgrinfo_appinfo_h handle, void *user_data ime_setting_app = String (ime_setting_appid); return -1; } + else { + pkgmgrinfo_appinfo_h appinfo_handle = NULL; + ret = pkgmgrinfo_appinfo_get_appinfo(ime_setting_appid, &appinfo_handle); + if (ret != PMINFO_R_OK) + return 0; + setting_app_changed = false; + ret = pkgmgrinfo_appinfo_foreach_metadata (appinfo_handle, _metadata_func, static_cast(user_data)); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_appinfo_destroy_appinfo(appinfo_handle); + return 0; + } + pkgmgrinfo_appinfo_destroy_appinfo(appinfo_handle); + + if (setting_app_changed) { + ime_setting_app = String (ime_setting_appid); + return -1; + } + } } else { LOGW ("pkgmgrinfo_appinfo_get_appid failed!");