From bfd5dc01c6709e9eb05d74416ce04de64a82a436 Mon Sep 17 00:00:00 2001 From: "bs0111.cho" Date: Mon, 3 Jun 2013 14:33:33 +0900 Subject: [PATCH] Remove manifest file dependencies due to the security issue. Change-Id: I7b45456816b748e0b8bb2ce541dc1a39d2f482e6 Signed-off-by: bs0111.cho --- src/FUiIme_InputMethodManagerImpl.cpp | 199 ++++++++++++++++------------------ 1 file changed, 96 insertions(+), 103 deletions(-) mode change 100644 => 100755 src/FUiIme_InputMethodManagerImpl.cpp diff --git a/src/FUiIme_InputMethodManagerImpl.cpp b/src/FUiIme_InputMethodManagerImpl.cpp old mode 100644 new mode 100755 index f1f900f..aa7eab9 --- a/src/FUiIme_InputMethodManagerImpl.cpp +++ b/src/FUiIme_InputMethodManagerImpl.cpp @@ -28,7 +28,8 @@ #include -#include +#include +#include #include #include #include @@ -48,9 +49,6 @@ using namespace Tizen::Base; using namespace Tizen::Base::Collection; using namespace Tizen::Locales; -static const AppId _PRELOADED_IME_APPID = "PRIVTIME01.ise-default"; -static const char* _PRELOADED_IME_UUID = "12aa3425-f88d-45f4-a509-cee8dfe904e3"; - namespace Tizen { namespace Ui { namespace Ime { _InputMethodManagerImpl::_InputMethodManagerImpl(void) @@ -321,12 +319,13 @@ _InputMethodManagerImpl::GetInputMethodInfoListN(void) const { result r = E_SUCCESS; - int ospImeCount = 0; - InputMethodInfo* pInputMethodInfo = null; _InputMethodInfoImpl* pInputMethodInfoImpl = null; + IList* pLanguageList = null; - std::unique_ptr pLanguageList(null); + const AppId* pAppId = null; + const PackageManager* pPackageManager = null; + PackageAppInfo* pPackageAppInfo = null; std::unique_ptr pInputMethodInfoList(new(std::nothrow) ArrayList(SingleObjectDeleter)); SysTryReturn(NID_UI_IME, pInputMethodInfoList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); @@ -334,12 +333,10 @@ _InputMethodManagerImpl::GetInputMethodInfoListN(void) const r = pInputMethodInfoList->Construct(); SysTryReturn(NID_UI_IME, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); - char* pAppRootPath = null; - - // get preloaded IME info + // add the input method info char** dpList = null; - int preloadedImeCount = isf_control_get_ise_list(&dpList); - SysTryReturn(NID_UI_IME, (dpList != null) && (preloadedImeCount > 0), null, E_SYSTEM, "[E_SYSTEM] A failure occurs from the underlying system."); + int iseCount = isf_control_get_ise_list(&dpList); + SysTryReturn(NID_UI_IME, (dpList != null) && (iseCount > 0), null, E_SYSTEM, "[E_SYSTEM] A failure occurs from the underlying system."); int ret = -1; char* pName = null; @@ -347,85 +344,87 @@ _InputMethodManagerImpl::GetInputMethodInfoListN(void) const ISE_TYPE_T type; int option = 0; - int preloadedImeIndex = -1; - - for (int i = 0; i < preloadedImeCount; i++) + for (int i = 0; i < iseCount; i++) { - if (!strcmp(dpList[i], _PRELOADED_IME_UUID)) - { - ret = isf_control_get_ise_info(dpList[i], &pName, &pLanguage, &type, &option); - SysTryCatch(NID_UI_IME, ret == 0, , E_SYSTEM, "[E_SYSTEM] A failure occurs from the underlying system."); - - preloadedImeCount = 1; - preloadedImeIndex = i; - break; - } - } + ret = isf_control_get_ise_info(dpList[i], &pName, &pLanguage, &type, &option); + SysTryCatch(NID_UI_IME, ret == 0, , E_SYSTEM, "[E_SYSTEM] A failure occurs from the underlying system."); - // get osp IME info - r = RequestInputMethodAppIdList(); - SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + if (type == SOFTWARE_KEYBOARD_ISE) + { + pInputMethodInfo = new(std::nothrow) InputMethodInfo(); + SysTryCatch(NID_UI_IME, pInputMethodInfo, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); - // add preloaded IME info - pInputMethodInfo = new(std::nothrow) InputMethodInfo(); - SysTryCatch(NID_UI_IME, pInputMethodInfo, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed."); + pInputMethodInfoImpl = _InputMethodInfoImpl::GetInstance(*pInputMethodInfo); + r = GetLastResult(); + SysTryCatch(NID_UI_IME, pInputMethodInfoImpl, , r, "[%s] Propagating.", GetErrorMessage(r)); - pInputMethodInfoImpl = _InputMethodInfoImpl::GetInstance(*pInputMethodInfo); - r = GetLastResult(); - SysTryCatch(NID_UI_IME, pInputMethodInfoImpl, , r, "[%s] Propagating.", GetErrorMessage(r)); + pInputMethodInfoImpl->SetUuid(dpList[i]); + pInputMethodInfoImpl->SetName(String(pName)); + pInputMethodInfoImpl->SetType(_ScimDataConverter::ConvertType(type)); - pInputMethodInfoImpl->SetAppId(_PRELOADED_IME_APPID); - pInputMethodInfoImpl->SetUuid(dpList[preloadedImeIndex]); - pInputMethodInfoImpl->SetName(String(pName)); - pInputMethodInfoImpl->SetType(_ScimDataConverter::ConvertType(type)); - pLanguageList.reset(GetInputMethodLanguageListN(pLanguage)); - r = GetLastResult(); - SysTryCatch(NID_UI_IME, pLanguageList, , r, "[%s] Propagating.", GetErrorMessage(r)); - r = pInputMethodInfoImpl->SetLanguageList(*(pLanguageList.get())); - SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - - SysSecureLog(NID_UI_IME, "The UUID of the preloaded IME application is %s.", dpList[preloadedImeIndex]); + pLanguageList = GetInputMethodLanguageListN(pLanguage); + r = GetLastResult(); + SysTryCatch(NID_UI_IME, pLanguageList, , r, "[%s] Propagating.", GetErrorMessage(r)); + r = pInputMethodInfoImpl->SetLanguageList(*pLanguageList); + SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + delete pLanguageList; + pLanguageList = null; + + r = pInputMethodInfoList->Add(pInputMethodInfo); + SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + pInputMethodInfo = null; + } - r = pInputMethodInfoList->Add(pInputMethodInfo); - SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - pInputMethodInfo = null; + free(pName); + free(pLanguage); + } free(dpList); - free(pName); - free(pLanguage); - // add osp IME info - ospImeCount = __pInputMethodAppIdList->GetCount(); + // add the appid of the input method + r = RequestInputMethodAppIdList(); + SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - for (int i = 0; i < ospImeCount; i++) + for (int i = 0; i < __pInputMethodAppIdList->GetCount(); i++) { - AppId* pAppId = static_cast(__pInputMethodAppIdList->GetAt(i)); + pAppId = static_cast(__pInputMethodAppIdList->GetAt(i)); r = GetLastResult(); SysTryCatch(NID_UI_IME, pAppId, , r, "[%s] Propagating.", GetErrorMessage(r)); - const wchar_t _RESERVED_APP_ID[] = L"PRIVT"; - const int _RESERVED_APP_ID_LENGTH = 5; - if (!wcsncmp(pAppId->GetPointer(), _RESERVED_APP_ID, _RESERVED_APP_ID_LENGTH)) - { - continue; - } - - String appRootPath; - r = _AppManagerImpl::GetAppRootPath(*pAppId, appRootPath); - SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - - pAppRootPath = _StringConverter::CopyToCharArrayN(appRootPath.GetPointer()); + pPackageManager = PackageManager::GetInstance(); r = GetLastResult(); - SysTryCatch(NID_UI_IME, pAppRootPath, , r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryCatch(NID_UI_IME, pPackageManager, , r, "[%s] Propagating.", GetErrorMessage(r)); - pInputMethodInfo = GetInputMethodInfoN(pAppRootPath); + pPackageAppInfo = pPackageManager->GetPackageAppInfoN(*pAppId); r = GetLastResult(); - SysTryCatch(NID_UI_IME, pInputMethodInfo, , r, "[%s] Propagating.", GetErrorMessage(r)); + SysTryCatch(NID_UI_IME, pPackageAppInfo, , r, "[%s] Propagating.", GetErrorMessage(r)); - r = pInputMethodInfoList->Add(pInputMethodInfo); - SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + for (int j = 0; j < pInputMethodInfoList->GetCount(); j++) + { + pInputMethodInfo = static_cast(pInputMethodInfoList->GetAt(j)); + r = GetLastResult(); + SysTryCatch(NID_UI_IME, pInputMethodInfo, , r, "[%s] Propagating.", GetErrorMessage(r)); + + SysLog(NID_UI_IME, "The registered input method names are %S, %S.", + pInputMethodInfo->GetName().GetPointer(), + pPackageAppInfo->GetAppDisplayName().GetPointer()); + if (pInputMethodInfo->GetName() == pPackageAppInfo->GetAppDisplayName()) + { + pInputMethodInfoImpl = _InputMethodInfoImpl::GetInstance(*pInputMethodInfo); + r = GetLastResult(); + SysTryCatch(NID_UI_IME, pInputMethodInfoImpl, , r, "[%s] Propagating.", GetErrorMessage(r)); + + pInputMethodInfoImpl->SetAppId(*pAppId); + SysSecureLog(NID_UI_IME, "The AppId, UUID, and the name of the input method is %S, %s, %S respectively.", + pInputMethodInfoImpl->GetAppId().GetPointer(), + pInputMethodInfoImpl->GetUuid(), + pInputMethodInfoImpl->GetName().GetPointer()); - delete[] pAppRootPath; + break; + } + } + + delete pPackageAppInfo; } return pInputMethodInfoList.release(); @@ -436,7 +435,8 @@ CATCH: free(pLanguage); delete pInputMethodInfo; - delete[] pAppRootPath; + delete pLanguageList; + delete pPackageAppInfo; return null; } @@ -446,44 +446,37 @@ _InputMethodManagerImpl::SetInputMethod(const AppId& id) { result r = E_SUCCESS; - std::unique_ptr pLog(_StringConverter::CopyToCharArrayN(id.GetPointer())); - SysSecureLog(NID_UI_IME, "The application ID is %s.", pLog.get()); + PackageManager* pPackageManager = PackageManager::GetInstance(); + r = GetLastResult(); + SysTryReturnResult(NID_UI_IME, pPackageManager, r, "Propagating."); + + std::unique_ptr pPackageAppInfo(pPackageManager->GetPackageAppInfoN(id)); + r = GetLastResult(); + SysTryReturnResult(NID_UI_IME, pPackageAppInfo, r, "Propagating."); + + std::unique_ptr pInputMethodInfoList(GetInputMethodInfoListN()); + r = GetLastResult(); + SysTryReturnResult(NID_UI_IME, pInputMethodInfoList, r, "Propagating."); - if (id == _PRELOADED_IME_APPID) + for (int i = 0; i < pInputMethodInfoList->GetCount(); i++) { - char** dpList = null; - int preloadedImeCount = isf_control_get_ise_list(&dpList); - SysTryReturnResult(NID_UI_IME, (dpList != null) && (preloadedImeCount > 0), E_SYSTEM, "A failure occurs from the underlying system."); + InputMethodInfo* pInputMethodInfo = static_cast(pInputMethodInfoList->GetAt(i)); + r = GetLastResult(); + SysTryReturnResult(NID_UI_IME, pInputMethodInfo, r, "Propagating."); - for (int i = 0; i < preloadedImeCount; i++) + if (pInputMethodInfo->GetName() == pPackageAppInfo->GetAppDisplayName()) { - if (!strcmp(dpList[i], _PRELOADED_IME_UUID)) - { - isf_control_set_active_ise_by_uuid(dpList[i]); - break; - } - } + _InputMethodInfoImpl* pInputMethodInfoImpl = _InputMethodInfoImpl::GetInstance(*pInputMethodInfo); + r = GetLastResult(); + SysTryReturnResult(NID_UI_IME, pInputMethodInfoImpl, r, "Propagating."); - free(dpList); + isf_control_set_active_ise_by_uuid(pInputMethodInfoImpl->GetUuid()); + SysSecureLog(NID_UI_IME, "The UUID of the input method to be set is %s.", pInputMethodInfoImpl->GetUuid()); - return r; + break; + } } - String appRootPath; - r = _AppManagerImpl::GetAppRootPath(id, appRootPath); - SysTryReturnResult(NID_UI_IME, r == E_SUCCESS, r, "Propagating."); - - std::unique_ptr pAppRootPath(_StringConverter::CopyToCharArrayN(appRootPath.GetPointer())); - r = GetLastResult(); - SysTryReturnResult(NID_UI_IME, pAppRootPath, r, "Propagating."); - - std::unique_ptr pInputMethodInfo(GetInputMethodInfoN(pAppRootPath.get())); - r = GetLastResult(); - SysTryReturnResult(NID_UI_IME, pInputMethodInfo, r, "Propagating."); - - _InputMethodInfoImpl* pInputMethodInfoImpl = _InputMethodInfoImpl::GetInstance(*(pInputMethodInfo.get())); - isf_control_set_active_ise_by_uuid(pInputMethodInfoImpl->GetUuid()); - return r; } -- 2.7.4