merge with master
[platform/framework/native/ime.git] / src / FUiIme_InputMethodManagerImpl.cpp
index b9d8baa..166cb1c 100644 (file)
@@ -34,7 +34,6 @@
 #include <FBaseString.h>\r
 #include <FBaseSysLog.h>\r
 #include <FLclLocale.h>\r
-#include <FUiImeInputMethodInfo.h>\r
 \r
 #include <FApp_AppManagerImpl.h>\r
 #include <FBase_StringConverter.h>\r
@@ -48,28 +47,20 @@ using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;\r
 using namespace Tizen::Locales;\r
 \r
-const AppId PRELOADED_IME_APPID = "sja4pgHCvq.Tizen";\r
-const char* PRELOADED_IME_UUID = "12aa3425-f88d-45f4-a509-cee8dfe904e3";\r
-const char* PRELOADED_IME_LANGUAGE = "eng-US";\r
+static const AppId PRELOADED_IME_APPID = "sja4pgHCvq.Tizen";\r
+static const char* PRELOADED_IME_UUID = "12aa3425-f88d-45f4-a509-cee8dfe904e3";\r
 \r
 namespace Tizen { namespace Ui { namespace Ime {\r
 \r
-_InputMethodManagerImpl* _InputMethodManagerImpl::__pInputMethodManagerImpl = null;\r
-\r
 _InputMethodManagerImpl::_InputMethodManagerImpl(void)\r
-       :__pInputMethodManager(null)\r
-       ,__pInputMethodAppIdList(null)\r
+       :__pInputMethodAppIdList(null)\r
 {\r
 }\r
 \r
 _InputMethodManagerImpl::~_InputMethodManagerImpl(void)\r
 {\r
-       __pInputMethodManagerImpl = null;\r
-\r
        delete __pInputMethodAppIdList;\r
        __pInputMethodAppIdList = null;\r
-\r
-       __pInputMethodManager = null;\r
 }\r
 \r
 result\r
@@ -77,17 +68,13 @@ _InputMethodManagerImpl::Construct(void)
 {\r
        result r = E_SUCCESS;\r
 \r
-       __pInputMethodAppIdList = new(std::nothrow) ArrayList(SingleObjectDeleter);\r
-       SysTryReturnResult(NID_UI_IME, __pInputMethodAppIdList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");\r
+       std::unique_ptr<ArrayList> pInputMethodAppIdList(new(std::nothrow) ArrayList(SingleObjectDeleter));\r
+       SysTryReturnResult(NID_UI_IME, pInputMethodAppIdList, E_OUT_OF_MEMORY, "Memory allocation failed.");\r
 \r
-       r = __pInputMethodAppIdList->Construct();\r
-       SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));\r
-\r
-       return r;\r
+       r = pInputMethodAppIdList->Construct();\r
+       SysTryReturnResult(NID_UI_IME, r == E_SUCCESS, r, "Propagating.");\r
 \r
-CATCH:\r
-       delete __pInputMethodAppIdList;\r
-       __pInputMethodAppIdList = null;\r
+       __pInputMethodAppIdList = pInputMethodAppIdList.release();\r
 \r
        return r;\r
 }\r
@@ -95,26 +82,7 @@ CATCH:
 _InputMethodManagerImpl*\r
 _InputMethodManagerImpl::GetInstance(InputMethodManager& inputMethodManager)\r
 {\r
-       result r = E_SUCCESS;\r
-\r
-       if (!__pInputMethodManagerImpl)\r
-       {\r
-               __pInputMethodManagerImpl = new(std::nothrow) _InputMethodManagerImpl();\r
-               SysTryReturn(NID_UI_IME, __pInputMethodManagerImpl, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");\r
-\r
-               r = __pInputMethodManagerImpl->Construct();\r
-               SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));\r
-\r
-               __pInputMethodManagerImpl->__pInputMethodManager = &inputMethodManager;\r
-       }\r
-\r
-       return __pInputMethodManagerImpl;\r
-\r
-CATCH:\r
-       delete __pInputMethodManagerImpl;\r
-       __pInputMethodManagerImpl = null;\r
-\r
-       return null;\r
+       return inputMethodManager.__pInputMethodManagerImpl;\r
 }\r
 \r
 InputMethodInfo*\r
@@ -127,29 +95,28 @@ _InputMethodManagerImpl::GetInputMethodInfoN(const char* pAppRootPath)
        // declare variables\r
        xmlDocPtr pXmlDoc = null;\r
        xmlNodePtr pXmlRootElement = null;\r
-       InputMethodInfo* pInputMethodInfo = null;\r
 \r
        // get the manifest file path\r
-       const char* MANIFEST_FILE_PATH = "/info/manifest.xml";\r
+       const char* _MANIFEST_FILE_PATH = "/info/manifest.xml";\r
 \r
-       int length = strlen(pAppRootPath) + strlen(MANIFEST_FILE_PATH) + 1;\r
+       int length = strlen(pAppRootPath) + strlen(_MANIFEST_FILE_PATH) + 1;\r
        char manifestFilePath[length];\r
        memset(manifestFilePath, '\0', length);\r
 \r
        strncpy(manifestFilePath, pAppRootPath, strlen(pAppRootPath));\r
-       strcat(manifestFilePath, MANIFEST_FILE_PATH);\r
+       strcat(manifestFilePath, _MANIFEST_FILE_PATH);\r
 \r
        // get InputMethodInfo\r
+       std::unique_ptr<InputMethodInfo> pInputMethodInfo(new(std::nothrow) InputMethodInfo());\r
+       SysTryReturn(NID_UI_IME, pInputMethodInfo, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");\r
+\r
        pXmlDoc = xmlParseFile(manifestFilePath);\r
        SysTryReturn(NID_UI_IME, pXmlDoc, null, E_SYSTEM, "[E_SYSTEM] A failure occurs from the underlying system.");\r
 \r
        pXmlRootElement = xmlDocGetRootElement(pXmlDoc);\r
        SysTryCatch(NID_UI_IME, pXmlRootElement, , E_SYSTEM, "[E_SYSTEM] A failure occurs from the underlying system.");\r
 \r
-       pInputMethodInfo = new(std::nothrow) InputMethodInfo();\r
-       SysTryCatch(NID_UI_IME, pInputMethodInfo, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");\r
-\r
-       r = ParseInputMethodInfo(pXmlRootElement, pInputMethodInfo);\r
+       r = ParseInputMethodInfo(pXmlRootElement, pInputMethodInfo.get());\r
        SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));\r
 \r
        if (pXmlDoc)\r
@@ -160,7 +127,7 @@ _InputMethodManagerImpl::GetInputMethodInfoN(const char* pAppRootPath)
 \r
        xmlCleanupParser();\r
 \r
-       return pInputMethodInfo;\r
+       return pInputMethodInfo.release();\r
 \r
 CATCH:\r
        if (pXmlDoc)\r
@@ -171,8 +138,6 @@ CATCH:
 \r
        xmlCleanupParser();\r
 \r
-       delete pInputMethodInfo;\r
-\r
        return null;\r
 }\r
 \r
@@ -255,12 +220,19 @@ _InputMethodManagerImpl::PackageManagerAppIdHandler(pkgmgrinfo_appinfo_h handle,
        char* appId = NULL;\r
        pkgmgrinfo_appinfo_get_appid(handle, &appId);\r
 \r
+       _InputMethodManagerImpl* pImpl = null;\r
        ArrayList* pInputMethodAppIdList = null;\r
 \r
        AppId* pAppId = new(std::nothrow) AppId(appId);\r
        SysTryReturn(NID_UI_IME, pAppId, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");\r
 \r
-       pInputMethodAppIdList = static_cast<ArrayList*>(__pInputMethodManagerImpl->GetInputMethodAppIdList());\r
+       InputMethodManager* pInputMethodManager = InputMethodManager::GetInstance();\r
+       r = GetLastResult();\r
+       SysTryCatch(NID_UI_IME, pInputMethodManager, , r, "[%s] Propagating.", GetErrorMessage(r));\r
+\r
+       pImpl = pInputMethodManager->__pInputMethodManagerImpl;\r
+\r
+       pInputMethodAppIdList = static_cast<ArrayList*>(pImpl->GetInputMethodAppIdList());\r
        r = pInputMethodAppIdList->Add(pAppId);\r
        SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));\r
 \r
@@ -275,21 +247,62 @@ CATCH:
 }\r
 \r
 InputMethodInfo*\r
-_InputMethodManagerImpl::GetCurrentInputMethodInfoN(void) const\r
+_InputMethodManagerImpl::GetActiveInputMethodInfoN(void) const\r
 {\r
-       InputMethodInfo* pInputMethodInfo = null;\r
+       result r = E_SUCCESS;\r
 \r
-       int length = -1;\r
        char* pUuid = null;\r
-       length = scim::isf_control_get_active_ise(&pUuid);\r
+       int length = isf_control_get_active_ise(&pUuid);\r
        SysTryReturn(NID_UI_IME, (length != -1) && pUuid, null, E_SYSTEM,\r
-                               "[E_SYSTEM] A failure occurs from the underlying system. The uuid length of the current input method is %d", length);\r
+                               "[E_SYSTEM] A failure occurs from the underlying system. The uuid length of the active input method is %d", length);\r
 \r
-       // need to implement\r
+       InputMethodInfo* pActiveInputMethodInfo = null;\r
+\r
+       std::unique_ptr<IList> pInputMethodInfoList(null);\r
+       std::unique_ptr<IBidirectionalEnumerator> pItor(null);\r
+\r
+       pInputMethodInfoList.reset(GetInputMethodInfoListN());\r
+       r = GetLastResult();\r
+       SysTryCatch(NID_UI_IME, pInputMethodInfoList, , r, "[%s] Propagating.", GetErrorMessage(r));\r
+\r
+       pItor.reset(pInputMethodInfoList->GetBidirectionalEnumeratorN());\r
+       r = GetLastResult();\r
+       SysTryCatch(NID_UI_IME, pItor, , r, "[%s] Propagating.", GetErrorMessage(r));\r
+\r
+       while (pItor->MoveNext() != E_OUT_OF_RANGE)\r
+       {\r
+               InputMethodInfo* pInputMethodInfo = static_cast<InputMethodInfo*>(pItor->GetCurrent());\r
+               r = GetLastResult();\r
+               SysTryCatch(NID_UI_IME, pInputMethodInfo, , r, "[%s] Propagating.", GetErrorMessage(r));\r
+\r
+               _InputMethodInfoImpl* pInputMethodInfoImpl = _InputMethodInfoImpl::GetInstance(*pInputMethodInfo);\r
+               r = GetLastResult();\r
+               SysTryCatch(NID_UI_IME, pInputMethodInfoImpl, , r, "[%s] Propagating.", GetErrorMessage(r));\r
 \r
+               if (strcmp(pInputMethodInfoImpl->GetUuid(), pUuid) == 0)\r
+               {\r
+                       pActiveInputMethodInfo = new(std::nothrow) InputMethodInfo();\r
+                       SysTryCatch(NID_UI_IME, pActiveInputMethodInfo, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");\r
+\r
+                       _InputMethodInfoImpl* pActiveInputMethodInfoImpl = _InputMethodInfoImpl::GetInstance(*pActiveInputMethodInfo);\r
+                       r = GetLastResult();\r
+                       SysTryCatch(NID_UI_IME, pActiveInputMethodInfoImpl, , r, "[%s] Propagating.", GetErrorMessage(r));\r
+\r
+                       *pActiveInputMethodInfoImpl = *pInputMethodInfoImpl;\r
+                       break;\r
+               }\r
+       }\r
+\r
+       free(pUuid);\r
+\r
+       return pActiveInputMethodInfo;\r
+\r
+CATCH:\r
        free(pUuid);\r
 \r
-       return pInputMethodInfo;\r
+       delete pActiveInputMethodInfo;\r
+\r
+       return null;\r
 }\r
 \r
 IList*\r
@@ -305,21 +318,28 @@ _InputMethodManagerImpl::GetInputMethodInfoListN(void) const
 \r
        int ospImeCount = 0;\r
 \r
-       ArrayList* pInputMethodInfoList = null;\r
        InputMethodInfo* pInputMethodInfo = null;\r
        _InputMethodInfoImpl* pInputMethodInfoImpl = null;\r
 \r
+       std::unique_ptr<IList> pLanguageList(null);\r
+\r
+       std::unique_ptr<ArrayList> pInputMethodInfoList(new(std::nothrow) ArrayList(SingleObjectDeleter));\r
+       SysTryReturn(NID_UI_IME, pInputMethodInfoList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");\r
+\r
+       r = pInputMethodInfoList->Construct();\r
+       SysTryReturn(NID_UI_IME, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));\r
+\r
        char* pAppRootPath = null;\r
 \r
        // get preloaded IME info\r
        char** dpList = null;\r
-       int preloadedImeCount = scim::isf_control_get_ise_list(&dpList);\r
+       int preloadedImeCount = isf_control_get_ise_list(&dpList);\r
        SysTryReturn(NID_UI_IME, (dpList != null) && (preloadedImeCount > 0), null, E_SYSTEM, "[E_SYSTEM] A failure occurs from the underlying system.");\r
 \r
        int ret = -1;\r
        char* pName = null;\r
        char* pLanguage = null;\r
-       scim::ISE_TYPE_T type;\r
+       ISE_TYPE_T type;\r
        int option = 0;\r
 \r
        int preloadedImeIndex = -1;\r
@@ -328,7 +348,7 @@ _InputMethodManagerImpl::GetInputMethodInfoListN(void) const
        {\r
                if (!strcmp(dpList[i], PRELOADED_IME_UUID))\r
                {\r
-                       ret = scim::isf_control_get_ise_info(dpList[i], &pName, &pLanguage, type, option);\r
+                       ret = isf_control_get_ise_info(dpList[i], &pName, &pLanguage, &type, &option);\r
                        SysTryCatch(NID_UI_IME, ret == 0, , E_SYSTEM, "[E_SYSTEM] A failure occurs from the underlying system.");\r
 \r
                        preloadedImeCount = 1;\r
@@ -341,15 +361,6 @@ _InputMethodManagerImpl::GetInputMethodInfoListN(void) const
        r = RequestInputMethodAppIdList();\r
        SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));\r
 \r
-       ospImeCount = __pInputMethodAppIdList->GetCount();\r
-\r
-       // make a InputMethodInfo list\r
-       pInputMethodInfoList = new(std::nothrow) ArrayList(SingleObjectDeleter);\r
-       SysTryCatch(NID_UI_IME, pInputMethodInfoList, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");\r
-\r
-       r = pInputMethodInfoList->Construct(preloadedImeCount + ospImeCount);\r
-       SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));\r
-\r
        // add preloaded IME info\r
        pInputMethodInfo = new(std::nothrow) InputMethodInfo();\r
        SysTryCatch(NID_UI_IME, pInputMethodInfo, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");\r
@@ -361,7 +372,11 @@ _InputMethodManagerImpl::GetInputMethodInfoListN(void) const
        pInputMethodInfoImpl->SetAppId(PRELOADED_IME_APPID);\r
        pInputMethodInfoImpl->SetUuid(dpList[preloadedImeIndex]);\r
        pInputMethodInfoImpl->SetName(String(pName));\r
-       pInputMethodInfoImpl->AddLanguage(PRELOADED_IME_LANGUAGE);\r
+       pLanguageList.reset(GetInputMethodLanguageListN(pLanguage));\r
+       r = GetLastResult();\r
+       SysTryCatch(NID_UI_IME, pLanguageList, , r, "[%s] Propagating.", GetErrorMessage(r));\r
+       r = pInputMethodInfoImpl->SetLanguageList(*(pLanguageList.get()));\r
+       SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));\r
 \r
        SysLog(NID_UI_IME, "The UUID of the preloaded IME application is %s.", dpList[preloadedImeIndex]);\r
 \r
@@ -374,6 +389,8 @@ _InputMethodManagerImpl::GetInputMethodInfoListN(void) const
        free(pLanguage);\r
 \r
        // add osp IME info\r
+       ospImeCount = __pInputMethodAppIdList->GetCount();\r
+\r
        for (int i = 0; i < ospImeCount; i++)\r
        {\r
                AppId* pAppId = static_cast<AppId*>(__pInputMethodAppIdList->GetAt(i));\r
@@ -398,14 +415,13 @@ _InputMethodManagerImpl::GetInputMethodInfoListN(void) const
                delete[] pAppRootPath;\r
        }\r
 \r
-       return pInputMethodInfoList;\r
+       return pInputMethodInfoList.release();\r
 \r
 CATCH:\r
        free(dpList);\r
        free(pName);\r
        free(pLanguage);\r
 \r
-       delete pInputMethodInfoList;\r
        delete pInputMethodInfo;\r
        delete[] pAppRootPath;\r
 \r
@@ -413,7 +429,7 @@ CATCH:
 }\r
 \r
 result\r
-_InputMethodManagerImpl::SetInputMethod(AppId id)\r
+_InputMethodManagerImpl::SetInputMethod(const AppId& id)\r
 {\r
        result r = E_SUCCESS;\r
 \r
@@ -423,14 +439,14 @@ _InputMethodManagerImpl::SetInputMethod(AppId id)
        if (id == PRELOADED_IME_APPID)\r
        {\r
                char** dpList = null;\r
-               int preloadedImeCount = scim::isf_control_get_ise_list(&dpList);\r
+               int preloadedImeCount = isf_control_get_ise_list(&dpList);\r
                SysTryReturnResult(NID_UI_IME, (dpList != null) && (preloadedImeCount > 0), E_SYSTEM, "A failure occurs from the underlying system.");\r
 \r
                for (int i = 0; i < preloadedImeCount; i++)\r
                {\r
                        if (!strcmp(dpList[i], PRELOADED_IME_UUID))\r
                        {\r
-                               scim::isf_control_set_active_ise_by_uuid(dpList[i]);\r
+                               isf_control_set_active_ise_by_uuid(dpList[i]);\r
                                break;\r
                        }\r
                }\r
@@ -441,32 +457,37 @@ _InputMethodManagerImpl::SetInputMethod(AppId id)
        }\r
 \r
        String appRootPath;\r
-       char* pAppRootPath = null;\r
-       InputMethodInfo* pInputMethodInfo = null;\r
-       _InputMethodInfoImpl* pInputMethodInfoImpl = null;\r
-\r
        r = _AppManagerImpl::GetAppRootPath(id, appRootPath);\r
        SysTryReturnResult(NID_UI_IME, r == E_SUCCESS, r, "Propagating.");\r
 \r
-       pAppRootPath = _StringConverter::CopyToCharArrayN(appRootPath.GetPointer());\r
+       std::unique_ptr<char[]> pAppRootPath(_StringConverter::CopyToCharArrayN(appRootPath.GetPointer()));\r
        r = GetLastResult();\r
        SysTryReturnResult(NID_UI_IME, pAppRootPath, r, "Propagating.");\r
 \r
-       pInputMethodInfo = GetInputMethodInfoN(pAppRootPath);\r
+       std::unique_ptr<InputMethodInfo> pInputMethodInfo(GetInputMethodInfoN(pAppRootPath.get()));\r
        r = GetLastResult();\r
-       SysTryCatch(NID_UI_IME, pInputMethodInfo, , r, "[%s] Propagating.", GetErrorMessage(r));\r
-\r
-       pInputMethodInfoImpl = _InputMethodInfoImpl::GetInstance(*pInputMethodInfo);\r
-       scim::isf_control_set_active_ise_by_uuid(pInputMethodInfoImpl->GetUuid());\r
+       SysTryReturnResult(NID_UI_IME, pInputMethodInfo, r, "Propagating.");\r
 \r
-       // Fall through\r
-CATCH:\r
-       delete[] pAppRootPath;\r
-       delete pInputMethodInfo;\r
+       _InputMethodInfoImpl* pInputMethodInfoImpl = _InputMethodInfoImpl::GetInstance(*(pInputMethodInfo.get()));\r
+       isf_control_set_active_ise_by_uuid(pInputMethodInfoImpl->GetUuid());\r
 \r
        return r;\r
 }\r
 \r
+bool\r
+_InputMethodManagerImpl::IsActiveInputMethod(const AppId& id) const\r
+{\r
+       result r = E_SUCCESS;\r
+\r
+       std::unique_ptr<InputMethodInfo> pActiveInputMethodInfo(GetActiveInputMethodInfoN());\r
+       r = GetLastResult();\r
+       SysTryReturn(NID_UI_IME, pActiveInputMethodInfo, false, r, "[%s] Propagating.", GetErrorMessage(r));\r
+\r
+       bool active = ((id == pActiveInputMethodInfo->GetAppId())? true: false);\r
+\r
+       return active;\r
+}\r
+\r
 IList*\r
 _InputMethodManagerImpl::GetInputMethodLanguageListN(const char* pLanguageList) const\r
 {\r
@@ -476,47 +497,46 @@ _InputMethodManagerImpl::GetInputMethodLanguageListN(const char* pLanguageList)
 \r
        const char* pItor = pLanguageList;\r
 \r
-       const int ISO_639_1_CODE_LENGTH = 5;\r
-       char arrayLanguage[ISO_639_1_CODE_LENGTH + 1];\r
+       const int _ISO_639_1_CODE_LENGTH = 5;\r
+       char arrayLanguage[_ISO_639_1_CODE_LENGTH + 1];\r
        memset(arrayLanguage, '\0', sizeof(arrayLanguage));\r
 \r
-       const int LANGUAGE_CODE_LENGTH = 2;\r
-       char arrayLanguageCode[LANGUAGE_CODE_LENGTH + 1];\r
+       const int _LANGUAGE_CODE_LENGTH = 2;\r
+       char arrayLanguageCode[_LANGUAGE_CODE_LENGTH + 1];\r
        memset(arrayLanguageCode, '\0', sizeof(arrayLanguageCode));\r
 \r
-       const int COUNTRY_CODE_LENGTH = 2;\r
-       char arrayCountryCode[COUNTRY_CODE_LENGTH + 1];\r
+       const int _COUNTRY_CODE_LENGTH = 2;\r
+       char arrayCountryCode[_COUNTRY_CODE_LENGTH + 1];\r
        memset(arrayCountryCode, '\0', sizeof(arrayCountryCode));\r
 \r
        Locale* pLanguage = null;\r
 \r
-       ArrayList* pInputMethodLanguageList = new(std::nothrow) ArrayList(SingleObjectDeleter);\r
+       std::unique_ptr<ArrayList> pInputMethodLanguageList(new(std::nothrow) ArrayList(SingleObjectDeleter));\r
        SysTryReturn(NID_UI_IME, pInputMethodLanguageList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");\r
 \r
        r = pInputMethodLanguageList->Construct();\r
-       SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));\r
+       SysTryReturn(NID_UI_IME, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));\r
 \r
        while ( pItor != null)\r
        {\r
-               strncpy(arrayLanguage, pItor, ISO_639_1_CODE_LENGTH);\r
+               strncpy(arrayLanguage, pItor, _ISO_639_1_CODE_LENGTH);\r
 \r
-               strncpy(arrayLanguageCode, arrayLanguage, LANGUAGE_CODE_LENGTH);\r
-               strncpy(arrayCountryCode, arrayLanguage + LANGUAGE_CODE_LENGTH + 1, COUNTRY_CODE_LENGTH);\r
+               strncpy(arrayLanguageCode, arrayLanguage, _LANGUAGE_CODE_LENGTH);\r
+               strncpy(arrayCountryCode, arrayLanguage + _LANGUAGE_CODE_LENGTH + 1, _COUNTRY_CODE_LENGTH);\r
 \r
                LanguageCode languageCode = Locale::TwoLetterLanguageCodeStringToLanguageCode(String(arrayLanguageCode));\r
                r = GetLastResult();\r
-               SysTryCatch(NID_UI_IME, languageCode < LANGUAGE_MAX, , r, "[%s] Propagating.", GetErrorMessage(r));\r
+               SysTryReturn(NID_UI_IME, languageCode < LANGUAGE_MAX, null, r, "[%s] Propagating.", GetErrorMessage(r));\r
 \r
                CountryCode countryCode = Locale::StringToCountryCode(String(arrayCountryCode));\r
                r = GetLastResult();\r
-               SysTryCatch(NID_UI_IME, countryCode < COUNTRY_MAX, , r, "[%s] Propagating.", GetErrorMessage(r));\r
+               SysTryReturn(NID_UI_IME, countryCode < COUNTRY_MAX, null, r, "[%s] Propagating.", GetErrorMessage(r));\r
 \r
                pLanguage = new(std::nothrow) Locale(languageCode, countryCode);\r
-               SysTryCatch(NID_UI_IME, pLanguage, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");\r
+               SysTryReturn(NID_UI_IME, pLanguage, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");\r
 \r
                r = pInputMethodLanguageList->Add(pLanguage);\r
                SysTryCatch(NID_UI_IME, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));\r
-               pLanguage = null;\r
 \r
                memset(arrayLanguage, '\0', sizeof(arrayLanguage));\r
                memset(arrayLanguageCode, '\0', sizeof(arrayLanguageCode));\r
@@ -530,11 +550,10 @@ _InputMethodManagerImpl::GetInputMethodLanguageListN(const char* pLanguageList)
                }\r
        }\r
 \r
-       return pInputMethodLanguageList;\r
+       return pInputMethodLanguageList.release();\r
 \r
 CATCH:\r
        delete pLanguage;\r
-       delete pInputMethodLanguageList;\r
 \r
        return null;\r
 }\r