From b5a0e50ca564aa5bea06eb7704bc78bd73edcbdb Mon Sep 17 00:00:00 2001 From: Joohyun Kim Date: Thu, 4 Apr 2013 13:59:37 +0900 Subject: [PATCH] Fix System Cache issue Change-Id: I174d691f226f2fab80e073aae4cd9584f46959ae Signed-off-by: Joohyun Kim --- src/system/FSys_SystemClient.cpp | 93 ++++++++++++++++++++++++++++++++++++-- src/system/FSys_SystemClient.h | 2 + src/system/FSys_SystemInfoImpl.cpp | 42 +++++++++-------- 3 files changed, 114 insertions(+), 23 deletions(-) diff --git a/src/system/FSys_SystemClient.cpp b/src/system/FSys_SystemClient.cpp index 4b1bb56..b4e0521 100644 --- a/src/system/FSys_SystemClient.cpp +++ b/src/system/FSys_SystemClient.cpp @@ -40,7 +40,9 @@ namespace Tizen { namespace System { static const wchar_t* _SYSTEM_SERVICE_ID = L"osp.system.service"; -static const wchar_t* _SYSTEM_COMMAND_SUPPORTED = L"osp.system.command.system.get.bool"; +static const wchar_t* _SYSTEM_COMMAND_GET_BOOL = L"osp.system.command.system.get.bool"; +static const wchar_t* _SYSTEM_COMMAND_GET_INT = L"osp.system.command.system.get.int"; +static const wchar_t* _SYSTEM_COMMAND_GET_STRING = L"osp.system.command.system.get.string"; static const wchar_t* _SYSTEM_OK = L"osp.system.result.ok"; static const wchar_t* _SYSTEM_INVALID_ARG = L"osp.system.result.invalid_arg"; @@ -87,12 +89,12 @@ _SystemClient::ConvertResultCode(String code) } result -_SystemClient::GetValue(const Tizen::Base::String& key, bool& value) +_SystemClient::GetValue(const String& key, bool& value) { result r = E_SUCCESS; String requestKey(key); String serviceId(_SYSTEM_SERVICE_ID); - String commandId(_SYSTEM_COMMAND_SUPPORTED); + String commandId(_SYSTEM_COMMAND_GET_BOOL); _CommunicationDispatcherClient* pCommunicationDispatcherClient = _CommunicationDispatcherClient::GetInstance(); @@ -134,6 +136,91 @@ _SystemClient::GetValue(const Tizen::Base::String& key, bool& value) return r; } +result +_SystemClient::GetValue(const String& key, int& value) +{ + result r = E_SUCCESS; + String requestKey(key); + String serviceId(_SYSTEM_SERVICE_ID); + String commandId(_SYSTEM_COMMAND_GET_INT); + + _CommunicationDispatcherClient* pCommunicationDispatcherClient = _CommunicationDispatcherClient::GetInstance(); + + __pIpcClient = pCommunicationDispatcherClient->GetIpcClient(); + + ArrayList requestMessages; + ArrayList responseMessages; + + requestMessages.Construct(); + responseMessages.Construct(); + + requestMessages.Add(serviceId); + requestMessages.Add(commandId); + requestMessages.Add(requestKey); + + unique_ptr pMsg(new (std::nothrow) IoService_Request(requestMessages, &responseMessages)); + + r = __pIpcClient->SendRequest(*pMsg); + SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send request by IPC [%s]", GetErrorMessage(r)); + + String* pResult = (String*)responseMessages.GetAt(2); + SysTryReturnResult(NID_SYS, pResult != null, E_SYSTEM, "There is no result code."); + + r = ConvertResultCode(*pResult); + SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, "Error is occured."); + + String* pValue = (String*)responseMessages.GetAt(3); + SysTryReturnResult(NID_SYS, pValue != null, E_SYSTEM, "There is no result value."); + + r = Integer::Parse(*pValue, value); + SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, "Result value[%ls] convert is failed.", pValue->GetPointer()); + + responseMessages.RemoveAll(true); + return r; +} + +result +_SystemClient::GetValue(const String& key, String& value) +{ + result r = E_SUCCESS; + String requestKey(key); + String serviceId(_SYSTEM_SERVICE_ID); + String commandId(_SYSTEM_COMMAND_GET_STRING); + + _CommunicationDispatcherClient* pCommunicationDispatcherClient = _CommunicationDispatcherClient::GetInstance(); + + __pIpcClient = pCommunicationDispatcherClient->GetIpcClient(); + + ArrayList requestMessages; + ArrayList responseMessages; + + requestMessages.Construct(); + responseMessages.Construct(); + + requestMessages.Add(serviceId); + requestMessages.Add(commandId); + requestMessages.Add(requestKey); + + unique_ptr pMsg(new (std::nothrow) IoService_Request(requestMessages, &responseMessages)); + + r = __pIpcClient->SendRequest(*pMsg); + SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send request by IPC [%s]", GetErrorMessage(r)); + + String* pResult = (String*)responseMessages.GetAt(2); + SysTryReturnResult(NID_SYS, pResult != null, E_SYSTEM, "There is no result code."); + + r = ConvertResultCode(*pResult); + SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, "Error is occured."); + + String* pValue = (String*)responseMessages.GetAt(3); + SysTryReturnResult(NID_SYS, pValue != null, E_SYSTEM, "There is no result value."); + + value = *pValue; + + responseMessages.RemoveAll(true); + return r; +} + void _SystemClient::OnDataReceived(const Tizen::Base::Collection::ArrayList& data) { diff --git a/src/system/FSys_SystemClient.h b/src/system/FSys_SystemClient.h index b06a6b2..6def329 100644 --- a/src/system/FSys_SystemClient.h +++ b/src/system/FSys_SystemClient.h @@ -44,6 +44,8 @@ private: public: result GetValue(const Tizen::Base::String& key, bool& value); + result GetValue(const Tizen::Base::String& key, int& value); + result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value); static _SystemClient* GetInstance(void); private: diff --git a/src/system/FSys_SystemInfoImpl.cpp b/src/system/FSys_SystemInfoImpl.cpp index b92aa5e..dde4c2e 100644 --- a/src/system/FSys_SystemInfoImpl.cpp +++ b/src/system/FSys_SystemInfoImpl.cpp @@ -33,6 +33,7 @@ #include "FSys_Types.h" #include "FSys_SystemClient.h" +#include "FSys_CommunicationDispatcherClient.h" using namespace std; @@ -43,7 +44,7 @@ using namespace Tizen::Io; namespace Tizen { namespace System { -static const wchar_t* _REGISTRY_PATH = L"/tmp/osp/system_info_cache.ini"; +static const wchar_t* _REGISTRY_PATH = L"/opt/usr/etc/system_info_cache.ini"; static const wchar_t* _SYSTEM_INFO_SESSION = L"SystemInformation"; //Bluetooth @@ -132,7 +133,6 @@ static const wchar_t* _NETWORK_TYPE = L"NetworkType"; static const wchar_t* _NETWORK_EMERGENCY = L"Emergency"; static const wchar_t* _NETWORK_NO_SERVICE = L"NoService"; - //WIFI static const wchar_t* _WIFI = L"http://tizen.org/feature/network.wifi"; static const wchar_t* _WIFI_SUPPORTED = L"WiFiSupported"; @@ -436,8 +436,11 @@ _SystemInfoImpl::GetSysInfo(const String& key, String& value) else { r = GetFromRegistry(tizenKey, value); - SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_OBJ_NOT_FOUND, "It is failed to get the key[%ls]", tizenKey.GetPointer()); - r = E_SUCCESS; + if(r != E_SUCCESS) + { + _SystemClient* pSystemClient = _SystemClient::GetInstance(); + r = pSystemClient->GetValue(key, value); + } } if( r == E_SUCCESS) { @@ -446,7 +449,6 @@ _SystemInfoImpl::GetSysInfo(const String& key, String& value) return r; } - result _SystemInfoImpl::GetSysInfo(const String& key, int& value) { @@ -463,6 +465,7 @@ _SystemInfoImpl::GetSysInfo(const String& key, int& value) if(pValue != null) { value = pValue->value; + return E_SUCCESS; } if (key == _CAMERA_COUNT) @@ -483,7 +486,11 @@ _SystemInfoImpl::GetSysInfo(const String& key, int& value) else { r = GetFromRegistry(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) + { + _SystemClient* pSystemClient = _SystemClient::GetInstance(); + r = pSystemClient->GetValue(key, value); + } } if(r == E_SUCCESS) @@ -494,21 +501,18 @@ _SystemInfoImpl::GetSysInfo(const String& key, int& value) return r; } - result _SystemInfoImpl::GetSysInfo(const String& key, long long& value) { return E_OBJ_NOT_FOUND; } - result _SystemInfoImpl::GetSysInfo(const String& key, double& value) { return E_OBJ_NOT_FOUND; } - result _SystemInfoImpl::GetSysInfo(const String& key, bool& value) { @@ -525,10 +529,15 @@ _SystemInfoImpl::GetSysInfo(const String& key, bool& value) if(pValue != null) { value = pValue->value; + return E_SUCCESS; } - r = GetFromRegistry(tizenKey, value); + if(r != E_SUCCESS) + { + _SystemClient* pSystemClient = _SystemClient::GetInstance(); + r = pSystemClient->GetValue(key, 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) @@ -539,14 +548,12 @@ _SystemInfoImpl::GetSysInfo(const String& key, bool& value) return r; } - result _SystemInfoImpl::GetSysInfo(const String& key, UuId& value) { return E_OBJ_NOT_FOUND; } - Collection::IList* _SystemInfoImpl::GetSysInfoValuesN(const String& key, SystemInfoValueType type) { @@ -606,11 +613,10 @@ _SystemInfoImpl::GetImei(String& imei) ArrayList requestMessage; ArrayList responseMessage; - unique_ptr<_IpcClient> pIpcClient (new (std::nothrow) _IpcClient()); - SysTryReturn(NID_SYS, pIpcClient != null, E_OUT_OF_MEMORY, r, "It is failed to create IPC instance."); + _CommunicationDispatcherClient* pCommunicationDispatcherClient = _CommunicationDispatcherClient::GetInstance(); - r = pIpcClient->Construct(_COMMUNICATION_DISPATCHER_IPC_ID); - SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "It is failed to create IpcClient. [%s]", GetErrorMessage(r)); + _IpcClient* pIpcClient = pCommunicationDispatcherClient->GetIpcClient(); + SysTryReturn(NID_SYS, pIpcClient != null, E_OUT_OF_MEMORY, r, "It is failed to create IPC instance."); requestMessage.Construct(); responseMessage.Construct(); @@ -685,10 +691,6 @@ _SystemInfoImpl::GetFromRegistry(const String& key, int& value) result _SystemInfoImpl::GetFromRegistry(const String& key, bool& value) { -/* - _SystemClient* pSystemClient = _SystemClient::GetInstance(); - pSystemClient->GetValue(key, value); -*/ result r = E_SUCCESS; _RegistryImpl _reg; String valStr; -- 2.7.4