Revert "Revert "Apply xml interface""
authorhansang lee <hs321.lee@samsung.com>
Thu, 20 Jun 2013 16:45:29 +0000 (16:45 +0000)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Thu, 20 Jun 2013 16:45:29 +0000 (16:45 +0000)
This reverts commit 0e1d3077c551f6eeb49f2ab724173ee0c488302a

Change-Id: I53cbadc6e1bacd8cc01eae3b9a89fbf3fba88679

src/system/FSys_SystemInfoImpl.cpp

index 2b586c2..dc94f8a 100644 (file)
 #include <FBaseBoolean.h>
 #include <FBaseInteger.h>
 #include <FBaseColHashMap.h>
+#include <FBaseUtilStringUtil.h>
 
 #include <FBase_NativeError.h>
+#include <FBase_StringConverter.h>
 #include <FIo_RegistryImpl.h>
 #include <FSys_SystemInfoImpl.h>
 #include <FIo_AppServiceIpcMessages.h>
@@ -43,6 +45,7 @@ using namespace std;
 using namespace Tizen::Base;
 using namespace Tizen::Base::Collection;
 using namespace Tizen::Io;
+using namespace Tizen::Base::Utility;
 
 namespace Tizen { namespace System
 {
@@ -263,6 +266,8 @@ _SystemInfoImpl::GetSysInfo(const String& key, String& value)
        result r = E_OBJ_NOT_FOUND;
        String tizenKey = ConvertToTizen(key);
 
+       SysLog(NID_SYS, "Request Key is %ls.", key.GetPointer());
+
        if (firstRequest == false)
        {
                PrepareCache();
@@ -438,37 +443,42 @@ _SystemInfoImpl::GetSysInfo(const String& key, String& value)
        }
        else if (tizenKey == _DUID)
        {
-               int ret = 0;
-               TapiHandle* handle = null;
-               int time_count = 0;
-               int status = 0;
+               r = GetFromRegistry(tizenKey, value);
 
-               handle = tel_init(null);
-               if(handle != null)
+               if(r != E_SUCCESS)
                {
-                       while(time_count < 30) //Wait 30 second.
-                       {
-                               ret = tel_check_modem_power_status(handle, &status);
-                               SysLog(NID_SYS, "Modem check result is %d, status is %d.", handle, status);
-                               if(ret != TAPI_API_SUCCESS)
-                               {
-                                       SysLogException(NID_SYS, E_SYSTEM, "It is failed to get Modem status.");
-                                       tel_deinit(handle);
-                                       return E_SYSTEM;
-                               }
+                       int ret = 0;
+                       TapiHandle* handle = null;
+                       int time_count = 0;
+                       int status = 0;
 
-                               if(status == 0)
+                       handle = tel_init(null);
+                       if(handle != null)
+                       {
+                               while(time_count < 30) //Wait 30 second.
                                {
-                                       break;
+                                       ret = tel_check_modem_power_status(handle, &status);
+                                       SysLog(NID_SYS, "Modem check result is %d, status is %d.", handle, status);
+                                       if(ret != TAPI_API_SUCCESS)
+                                       {
+                                               SysLogException(NID_SYS, E_SYSTEM, "It is failed to get Modem status.");
+                                               tel_deinit(handle);
+                                               return E_SYSTEM;
+                                       }
+
+                                       if(status == 0)
+                                       {
+                                               break;
+                                       }
+
+                                       usleep(1000000);
+                                       time_count++;
                                }
-
-                               usleep(1000000);
-                               time_count++;
+                               tel_deinit(handle);
                        }
-                       tel_deinit(handle);
+                       _SystemClient* pSystemClient = _SystemClient::GetInstance();
+                       r = pSystemClient->GetValue(tizenKey, value);
                }
-               _SystemClient* pSystemClient = _SystemClient::GetInstance();
-               r = pSystemClient->GetValue(tizenKey, value);
        }
        else
        {
@@ -476,8 +486,21 @@ _SystemInfoImpl::GetSysInfo(const String& key, String& value)
 
                if(r != E_SUCCESS)
                {
-                       _SystemClient* pSystemClient = _SystemClient::GetInstance();
-                       r = pSystemClient->GetValue(tizenKey, value);
+                       char* pStringValue = null;
+                       String tKey;
+                       tizenKey.SubString(7, tKey);
+
+                       ClearLastResult();
+                       unique_ptr< char[] > systemKey(_StringConverter::CopyToCharArrayN(tKey));
+                       r = GetLastResult();
+                       SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::StringToUtf8N It is failed", GetErrorMessage(r));
+                       int ret = system_info_get_platform_string(systemKey.get(), &pStringValue);
+
+                       SysTryReturnResult(NID_SYS, ret == 0, E_OBJ_NOT_FOUND, "It is failed to get system information %ls from configration file.", tizenKey.GetPointer());
+
+                       r = StringUtil::Utf8ToString(pStringValue, value);
+                       free(pStringValue);
+                       r = E_SUCCESS;
                }
        }
        if( r == E_SUCCESS)
@@ -493,6 +516,8 @@ _SystemInfoImpl::GetSysInfo(const String& key, int& value)
        result r = E_SUCCESS;
        String tizenKey = ConvertToTizen(key);
 
+       SysLog(NID_SYS, "Request Key is %ls.", key.GetPointer());
+
        if (firstRequest == false)
        {
                PrepareCache();
@@ -526,8 +551,19 @@ _SystemInfoImpl::GetSysInfo(const String& key, int& value)
                r = GetFromRegistry(tizenKey, value);
                if(r != E_SUCCESS)
                {
-                       _SystemClient* pSystemClient = _SystemClient::GetInstance();
-                       r = pSystemClient->GetValue(tizenKey, value);
+                       int ret = 0;
+                       String tKey;
+
+                       tizenKey.SubString(7, tKey);
+
+                       ClearLastResult();
+                       unique_ptr< char[] > systemKey(_StringConverter::CopyToCharArrayN(tKey));
+                       r = GetLastResult(); 
+                       SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::StringToUtf8N It is failed", GetErrorMessage(r));
+                       ret = system_info_get_platform_int(systemKey.get(), &value);
+
+                       SysTryReturnResult(NID_SYS, ret == 0, E_OBJ_NOT_FOUND, "It is failed to get system information %ls from configration file.", tizenKey.GetPointer());
+                       r = E_SUCCESS;
                }
        }
 
@@ -557,6 +593,8 @@ _SystemInfoImpl::GetSysInfo(const String& key, bool& value)
        result r = E_SUCCESS;
        String tizenKey = ConvertToTizen(key);
 
+       SysLog(NID_SYS, "Request Key is %ls.", key.GetPointer());
+
        if (firstRequest == false)
        {
                PrepareCache();
@@ -570,32 +608,23 @@ _SystemInfoImpl::GetSysInfo(const String& key, bool& value)
                return E_SUCCESS;
        }
 
-       if(key == L"http://tizen.org/feature/input.keys.menu")
-       {
-               bool supported = false;
-               int ret = system_info_get_platform_bool("tizen.org/feature/input.keys.menu", &supported);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
-               value = supported;
-               r = E_SUCCESS;
-       }
-       else if(key == L"http://tizen.org/feature/input.keys.back")
+       r = GetFromRegistry(tizenKey, value);
+       if(r != E_SUCCESS)
        {
+               String tKey;
+               tizenKey.SubString(7, tKey);
+
+               ClearLastResult();
+               unique_ptr< char[] > systemKey(_StringConverter::CopyToCharArrayN(tKey));
+               r = GetLastResult();
+               SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::StringToUtf8N It is failed", GetErrorMessage(r));
+
                bool supported = false;
-               int ret = system_info_get_platform_bool("tizen.org/feature/input.keys.back", &supported);
-               SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "It is failed to get system information from configration file.");
+               int ret = system_info_get_platform_bool(systemKey.get(), &supported);
+               SysTryReturnResult(NID_SYS, ret == 0, E_OBJ_NOT_FOUND, "It is failed to get system information %ls from configration file.", tizenKey.GetPointer());
                value = supported;
                r = E_SUCCESS;
        }
-       else
-       {
-               r = GetFromRegistry(tizenKey, value);
-               if(r != E_SUCCESS)
-               {
-                       _SystemClient* pSystemClient = _SystemClient::GetInstance();
-                       r = pSystemClient->GetValue(tizenKey, value);
-               }
-               SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_OBJ_NOT_FOUND, "It is failed to get the key[%ls]", tizenKey.GetPointer());
-       }
 
        if(r == E_SUCCESS)
        {
@@ -625,7 +654,25 @@ _SystemInfoImpl::GetPlatformVersion(String& platformVersion)
        String tizenKey(_PLATFORM_VERSION);
 
        r = GetFromRegistry(tizenKey, platformVersion);
-       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the key[%ls]", tizenKey.GetPointer());
+
+       if(r != E_SUCCESS)
+       {
+               char* pStringValue = null;
+               String tKey;
+               tizenKey.SubString(7, tKey);
+
+               ClearLastResult();
+               unique_ptr< char[] > systemKey(_StringConverter::CopyToCharArrayN(tKey));
+               r = GetLastResult();
+               SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::StringToUtf8N It is failed", GetErrorMessage(r));
+               int ret = system_info_get_platform_string(systemKey.get(), &pStringValue);
+
+               SysTryReturnResult(NID_SYS, ret == 0, E_OBJ_NOT_FOUND, "It is failed to get system information %ls from configration file.", tizenKey.GetPointer());
+
+               r = StringUtil::Utf8ToString(pStringValue, platformVersion);
+               free(pStringValue);
+               r = E_SUCCESS;
+       }
        return r;
 }
 
@@ -636,7 +683,25 @@ _SystemInfoImpl::GetBuildInfo(String& buildInfo)
        String tizenKey(_BUILD_STRING);
 
        r = GetFromRegistry(tizenKey, buildInfo);
-       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the key[%ls]", tizenKey.GetPointer());
+
+       if(r != E_SUCCESS)
+       {
+               char* pStringValue = null;
+               String tKey;
+               tizenKey.SubString(7, tKey);
+
+               ClearLastResult();
+               unique_ptr< char[] > systemKey(_StringConverter::CopyToCharArrayN(tKey));
+               r = GetLastResult();
+               SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::StringToUtf8N It is failed", GetErrorMessage(r));
+               int ret = system_info_get_platform_string(systemKey.get(), &pStringValue);
+
+               SysTryReturnResult(NID_SYS, ret == 0, E_OBJ_NOT_FOUND, "It is failed to get system information %ls from configration file.", tizenKey.GetPointer());
+
+               r = StringUtil::Utf8ToString(pStringValue, buildInfo);
+               free(pStringValue);
+               r = E_SUCCESS;
+       }
        return r;
 }
 
@@ -647,7 +712,25 @@ _SystemInfoImpl::GetNativeApiVersion(String& nativeApiVersion)
        String tizenKey(_PLATFORM_NATIVE_API_VERSION);
 
        r = GetFromRegistry(tizenKey, nativeApiVersion);
-       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the key[%ls]", tizenKey.GetPointer());
+
+       if(r != E_SUCCESS)
+       {
+               char* pStringValue = null;
+               String tKey;
+               tizenKey.SubString(7, tKey);
+
+               ClearLastResult();
+               unique_ptr< char[] > systemKey(_StringConverter::CopyToCharArrayN(tKey));
+               r = GetLastResult();
+               SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::StringToUtf8N It is failed", GetErrorMessage(r));
+               int ret = system_info_get_platform_string(systemKey.get(), &pStringValue);
+
+               SysTryReturnResult(NID_SYS, ret == 0, E_OBJ_NOT_FOUND, "It is failed to get system information %ls from configration file.", tizenKey.GetPointer());
+
+               r = StringUtil::Utf8ToString(pStringValue, nativeApiVersion);
+               free(pStringValue);
+               r = E_SUCCESS;
+       }
        return r;
 }
 
@@ -658,7 +741,25 @@ _SystemInfoImpl::GetWebApiVersion(String& webApiVersion)
        String tizenKey(_PLATFORM_WEB_API_VERSION);
 
        r = GetFromRegistry(tizenKey, webApiVersion);
-       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the key[%ls]", tizenKey.GetPointer());
+
+       if(r != E_SUCCESS)
+       {
+               char* pStringValue = null;
+               String tKey;
+               tizenKey.SubString(7, tKey);
+
+               ClearLastResult();
+               unique_ptr< char[] > systemKey(_StringConverter::CopyToCharArrayN(tKey));
+               r = GetLastResult();
+               SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::StringToUtf8N It is failed", GetErrorMessage(r));
+               int ret = system_info_get_platform_string(systemKey.get(), &pStringValue);
+
+               SysTryReturnResult(NID_SYS, ret == 0, E_OBJ_NOT_FOUND, "It is failed to get system information %ls from configration file.", tizenKey.GetPointer());
+
+               r = StringUtil::Utf8ToString(pStringValue, webApiVersion);
+               free(pStringValue);
+               r = E_SUCCESS;
+       }
        return r;
 }
 
@@ -762,6 +863,7 @@ _SystemInfoImpl::GetFromRegistry(const String& key, int& value)
        result r = E_SUCCESS;
        _RegistryImpl _reg;
        String valStr;
+
        r = _reg.Construct(_REGISTRY_PATH, REG_OPEN_READ_ONLY, null);
        SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, " RegistryImpl construct is failed");
 
@@ -779,6 +881,7 @@ _SystemInfoImpl::GetFromRegistry(const String& key, bool& value)
        result r = E_SUCCESS;
        _RegistryImpl _reg;
        String valStr;
+
        r = _reg.Construct(_REGISTRY_PATH, REG_OPEN_READ_ONLY, null);
        SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, " RegistryImpl construct is failed");