Fix Compatibility and Add Client
authorJoohyun Kim <joohyune.kim@samsung.com>
Wed, 3 Apr 2013 11:00:43 +0000 (20:00 +0900)
committerJoohyun Kim <joohyune.kim@samsung.com>
Wed, 3 Apr 2013 11:04:16 +0000 (20:04 +0900)
Change-Id: I97fba1809288f0bac7bee662dd5d5212cae155af
Signed-off-by: Joohyun Kim <joohyune.kim@samsung.com>
src/system/CMakeLists.txt
src/system/FSys_SystemClient.cpp [new file with mode: 0644]
src/system/FSys_SystemClient.h [new file with mode: 0644]
src/system/FSys_SystemInfoImpl.cpp

index 6b9d0c6..edf5e85 100755 (executable)
@@ -49,6 +49,7 @@ SET (${this_target}_SOURCE_FILES
        FSys_EnvironmentImpl.cpp
        FSys_DeviceEventListenerContainer.cpp
        FSys_SettingClient.cpp
+       FSys_SystemClient.cpp
 )
 
 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
diff --git a/src/system/FSys_SystemClient.cpp b/src/system/FSys_SystemClient.cpp
new file mode 100644 (file)
index 0000000..4b1bb56
--- /dev/null
@@ -0,0 +1,142 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FSys_SettingClient.cpp
+ * @brief              This is the implementation file for _SettingClient class.
+ */
+
+#include <unique_ptr.h>
+
+#include "FSys_SystemClient.h"
+
+#include <FBaseSysLog.h>
+
+#include <FIo_AppServiceIpcMessages.h>
+#include "FSys_CommunicationDispatcherClient.h"
+
+using namespace std;
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Io;
+
+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_OK = L"osp.system.result.ok";
+static const wchar_t* _SYSTEM_INVALID_ARG = L"osp.system.result.invalid_arg";
+static const wchar_t* _SYSTEM_ERROR = L"osp.system.result.error";
+
+_SystemClient* _SystemClient::__pSystemClient = null;
+
+_SystemClient*
+_SystemClient::GetInstance(void)
+{
+       if(__pSystemClient == null)
+       {
+               __pSystemClient = new (std::nothrow) _SystemClient();
+       }
+       return __pSystemClient;
+}
+
+_SystemClient::_SystemClient()
+       :__pIpcClient(null)
+{
+       result r = E_SUCCESS;
+       _CommunicationDispatcherClient* pCommunicationDispatcherClient = _CommunicationDispatcherClient::GetInstance();
+       r = pCommunicationDispatcherClient->RegisterCommunicationListener(_SYSTEM_SERVICE_ID, *this);
+       __pIpcClient = pCommunicationDispatcherClient->GetIpcClient();
+}
+
+_SystemClient::~_SystemClient()
+{
+}
+
+result
+_SystemClient::ConvertResultCode(String code)
+{
+       result r = E_SYSTEM;
+       if(code == _SYSTEM_OK)
+       {
+               r = E_SUCCESS;
+       }
+       else if(code == _SYSTEM_INVALID_ARG)
+       {
+               r = E_INVALID_ARG;
+       }
+       return r;
+}
+
+result
+_SystemClient::GetValue(const Tizen::Base::String& key, bool& value)
+{
+       result r = E_SUCCESS;
+       String requestKey(key);
+       String serviceId(_SYSTEM_SERVICE_ID);
+       String commandId(_SYSTEM_COMMAND_SUPPORTED);
+
+       _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<IoService_Request> 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.");
+       if(pValue->GetPointer() == L"1")
+       {
+               value = true;
+       }
+       else
+       {
+               value = false;
+       }
+
+       responseMessages.RemoveAll(true);
+       return r;
+}
+
+void
+_SystemClient::OnDataReceived(const Tizen::Base::Collection::ArrayList& data)
+{
+}
+
+} } // Tizen::System
diff --git a/src/system/FSys_SystemClient.h b/src/system/FSys_SystemClient.h
new file mode 100644 (file)
index 0000000..b06a6b2
--- /dev/null
@@ -0,0 +1,59 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FSys_SystemClient.h
+ * @brief              This is the header file for _SystemClient class.
+ */
+
+#ifndef _FSYSTEM_INTERNAL_SYSTEM_CLIENT_H_
+#define _FSYSTEM_INTERNAL_SYSTEM_CLIENT_H_
+
+#include <FIo_IpcClient.h>
+
+#include <FBaseColArrayList.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FBaseInteger.h>
+#include <FSys_ICommunicationDispatcherListener.h>
+
+namespace Tizen { namespace System
+{
+
+class _SystemClient
+       : public Tizen::Base::Object
+       , public Tizen::System::_ICommunicationDispatcherListener
+{
+private:
+       _SystemClient(void);
+       virtual ~_SystemClient(void);
+
+public:
+       result GetValue(const Tizen::Base::String& key, bool& value);
+       static _SystemClient* GetInstance(void);
+
+private:
+       void OnDataReceived(const Tizen::Base::Collection::ArrayList& data);
+       result ConvertResultCode(Tizen::Base::String code);
+private:
+       Tizen::Io::_IpcClient*  __pIpcClient;   
+       static _SystemClient*   __pSystemClient;
+};
+
+} } // Tizen::System
+
+#endif //_FSYSTEM_INTERNAL_SYSTEM_CLIENT_H_
index 6cd8e41..b92aa5e 100644 (file)
@@ -30,7 +30,9 @@
 #include <FSys_SystemInfoImpl.h>
 #include <FIo_AppServiceIpcMessages.h>
 #include <FIo_IpcClient.h>
-#include <FSys_Types.h>
+
+#include "FSys_Types.h"
+#include "FSys_SystemClient.h"
 
 using namespace std;
 
@@ -179,7 +181,7 @@ _SystemInfoImpl::ConvertToTizen(const String& key)
        }
        else if(code == _KEYBOARD_TYPE)
        {
-               code == _INPUT_KEYBOARD_LAYOUT;
+               code = _INPUT_KEYBOARD_LAYOUT;
        }
        else if(code == _SCREEN_BITS_PER_PIXEL)
        {
@@ -268,6 +270,7 @@ _SystemInfoImpl::GetSysInfo(const String& key, String& value)
        if(pValue != null)
        {
                value = *pValue;
+               r = E_SUCCESS;
        }
 
        if (key == _NETWORK_TYPE) //Compatibility
@@ -368,7 +371,7 @@ _SystemInfoImpl::GetSysInfo(const String& key, String& value)
 
                        value.Append(L"CDMA");
                }
-
+               r = E_SUCCESS;
        }
        else if (key == _OPENGL_ES_VERSION)
        {
@@ -389,6 +392,7 @@ _SystemInfoImpl::GetSysInfo(const String& key, String& value)
 
                        value.Append(L"2.0");
                }
+               r = E_SUCCESS;
        }
        else if(key == _BLUETOOTH_SUPPORTED)
        {
@@ -398,6 +402,7 @@ _SystemInfoImpl::GetSysInfo(const String& key, String& value)
                        value = _SUPPORTED;
                else
                        value = _UNSUPPORTED;
+               r = E_SUCCESS;
        }
        else if (key == _GPS_SUPPORTED)
        {
@@ -407,6 +412,7 @@ _SystemInfoImpl::GetSysInfo(const String& key, String& value)
                        value = _SUPPORTED;
                else
                        value = _UNSUPPORTED;
+               r = E_SUCCESS;
        }
        else if (key == _WIFI_SUPPORTED)
        {
@@ -416,6 +422,7 @@ _SystemInfoImpl::GetSysInfo(const String& key, String& value)
                        value = _SUPPORTED;
                else
                        value = _UNSUPPORTED;
+               r = E_SUCCESS;
        }
        else if (key == _WAC_VERSION)
        {
@@ -678,6 +685,10 @@ _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;
@@ -701,6 +712,7 @@ _SystemInfoImpl::GetFromRegistry(const String& key, bool& value)
        }
        return E_SUCCESS;
 }
+
 _SystemInfoImpl*
 _SystemInfoImpl::GetInstance(SystemInfo& systeminfo)
 {