From a5491d6e630001291928ae037c73564b0d0faae3 Mon Sep 17 00:00:00 2001 From: Hokwon Song Date: Thu, 20 Jun 2013 09:19:47 +0000 Subject: [PATCH] Revert "Seperate DeviceManagerService into System-service so." This reverts commit fecd2da6ec0e3f66f315d6d38c6b0f905af3d734 Change-Id: I5f47782d7a1437ef4a7b6443b87847a75f63709b --- src/system-server/CMakeLists.txt | 20 --- src/system-server/dev/FSys_DeviceManager.cpp | 238 --------------------------- src/system-server/inc/FSys_DeviceManager.h | 64 ------- src/system-server/inc/FSys_IDeviceManager.h | 50 ------ src/system/CMakeLists.txt | 1 - src/system/FSys_DeviceManagerImpl.cpp | 30 ++-- src/system/FSys_DeviceManagerMsgClient.cpp | 122 -------------- src/system/FSys_DeviceManagerMsgClient.h | 63 ------- 8 files changed, 16 insertions(+), 572 deletions(-) delete mode 100644 src/system-server/dev/FSys_DeviceManager.cpp delete mode 100644 src/system-server/inc/FSys_DeviceManager.h delete mode 100644 src/system-server/inc/FSys_IDeviceManager.h delete mode 100644 src/system/FSys_DeviceManagerMsgClient.cpp delete mode 100644 src/system/FSys_DeviceManagerMsgClient.h diff --git a/src/system-server/CMakeLists.txt b/src/system-server/CMakeLists.txt index c9cae01..f87305a 100644 --- a/src/system-server/CMakeLists.txt +++ b/src/system-server/CMakeLists.txt @@ -5,30 +5,12 @@ INCLUDE_DIRECTORIES ( ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/inc ${CMAKE_SOURCE_DIR}/src/system-server/inc - ${CMAKE_SOURCE_DIR}/src/io/inc - ${CMAKE_SOURCE_DIR}/src/server/inc - ${CMAKE_SOURCE_DIR}/src/system/inc ) SET (${this_target}_SOURCE_FILES system/FSys_SystemInfo.cpp - dev/FSys_DeviceManager.cpp ) -INCLUDE(FindPkgConfig) -pkg_check_modules(pkgs REQUIRED - capi-system-media-key - capi-network-bluetooth -) - -FOREACH(flag ${pkgs_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -FOREACH(ldflag ${pkgs_LDFLAGS}) - SET(EXTRA_LDFLAGS "${EXTRA_LDFLAGS} ${flag}") -ENDFOREACH(ldflag) - ## SET EXTRA COMPILER FLAGS SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC -Wall" ) @@ -43,8 +25,6 @@ SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EX ADD_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES}) TARGET_LINK_LIBRARIES(${this_target} osp-appfw) -TARGET_LINK_LIBRARIES(${this_target} capi-network-bluetooth) -TARGET_LINK_LIBRARIES(${this_target} capi-system-media-key) SET_TARGET_PROPERTIES(${this_target} PROPERTIES diff --git a/src/system-server/dev/FSys_DeviceManager.cpp b/src/system-server/dev/FSys_DeviceManager.cpp deleted file mode 100644 index 9e31407..0000000 --- a/src/system-server/dev/FSys_DeviceManager.cpp +++ /dev/null @@ -1,238 +0,0 @@ -// -// 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_DeviceManager.cpp - * @brief This is the implementation file for _DeviceManager class. - */ - -#include -#include -#include - -#include -#include -#include "FSys_DeviceManager.h" - -using namespace Tizen::App; -using namespace Tizen::Io; -using namespace Tizen::System; -using namespace Tizen::Base; -using namespace Tizen::Base::Collection; - -namespace { - const static wchar_t* DEVICE_MANAGER_SERVICE_ID = L"osp.devicemanager.service"; - const static wchar_t* DEVICE_MANAGER_BLUETOOTH = L"osp.devicemanager.bluetooth"; - - const static wchar_t* BLUETOOTH_A2DP_CONNECTED = L"Connected"; - const static wchar_t* BLUETOOTH_A2DP_DISCONNECTED = L"Disconnected"; - const static wchar_t* BLUETOOTH_A2DP_PLAY = L"Play"; - const static wchar_t* BLUETOOTH_A2DP_STOP = L"Stop"; - const static wchar_t* BLUETOOTH_A2DP_PAUSE = L"Pause"; - const static wchar_t* BLUETOOTH_A2DP_RESUME = L"Resume"; - const static wchar_t* BLUETOOTH_A2DP_FORWARD = L"Forward"; - const static wchar_t* BLUETOOTH_A2DP_FASTFORWARD = L"FastForward"; - const static wchar_t* BLUETOOTH_A2DP_BACKWARD = L"Backward"; - const static wchar_t* BLUETOOTH_A2DP_REWIND = L"Rewind"; -} - -Tizen::System::_DeviceManager* Tizen::System::_DeviceManager::__pDeviceManager = null; - -void bluetooth_connection_state_changed(int result, bool connected, const char* remote_address, bt_audio_profile_type_e type, void* user_data) -{ - SysLog(NID_SYS, "Bluetooth headset[%s] connection[%d] event", remote_address, connected); - String bt_event; - _DeviceManager* pDeviceManager = _DeviceManager::GetInstance(); - SysTryReturn(NID_SYS, pDeviceManager, ,E_SYSTEM, "DeviceManager is not created"); - - IDeviceEventListener* pDeviceEventListener = pDeviceManager->GetEventListener(); - - if(pDeviceManager->GetBluetoothStatus() != connected && pDeviceEventListener) - { - if(connected == true) - { - bt_event = BLUETOOTH_A2DP_CONNECTED; - } - else - { - bt_event = BLUETOOTH_A2DP_DISCONNECTED; - } - - pDeviceEventListener->OnDeviceStateChanged(DEVICE_TYPE_BLUETOOTH_HEADSET, bt_event); - } - pDeviceManager->SetBluetoothStatus(connected); -} - -void app_media_key_handler(media_key_e key, media_key_event_e status, void* pUserData) -{ - String event; - SysLog(NID_SYS, "Bluetooth headset event is occured %d, %d", (int)key, (int)status); - _DeviceManager* pDeviceManager = _DeviceManager::GetInstance(); - SysTryReturn(NID_SYS, pDeviceManager, ,E_SYSTEM, "DeviceManager is not created"); - - if(status == MEDIA_KEY_STATUS_RELEASED) - { - switch(key) - { - case MEDIA_KEY_PLAY: - event = BLUETOOTH_A2DP_PLAY; - break; - case MEDIA_KEY_STOP: - event = BLUETOOTH_A2DP_STOP; - break; - case MEDIA_KEY_PAUSE: - event = BLUETOOTH_A2DP_PAUSE; - break; - case MEDIA_KEY_PREVIOUS: - event = BLUETOOTH_A2DP_BACKWARD; - break; - case MEDIA_KEY_NEXT: - event = BLUETOOTH_A2DP_FORWARD; - break; - case MEDIA_KEY_FASTFORWARD: - event = BLUETOOTH_A2DP_FASTFORWARD; - break; - case MEDIA_KEY_REWIND: - event = BLUETOOTH_A2DP_REWIND; - break; - case MEDIA_KEY_UNKNOWN: - default: - SysLog(NID_SYS, "Unsupported key[%d] is occured.", key); - return; - } - - IDeviceEventListener* pDeviceEventListener = pDeviceManager->GetEventListener(); - if (pDeviceEventListener) - { - pDeviceEventListener->OnDeviceStateChanged(DEVICE_TYPE_BLUETOOTH_HEADSET, event); - } - } -} - -_DeviceManager::_DeviceManager() - : isBluetoothHeadSetConnected(false) - , isInitBluetooth(false) - , __pDeviceManagerListener(null) -{ -} - -_DeviceManager::~_DeviceManager() -{ - if(isInitBluetooth == true) - { - int btResult = 0; - SysLog(NID_SYS, "Bluetooth headset event is released."); - media_key_release(); - btResult = bt_audio_unset_connection_state_changed_cb(); - SysTryReturnVoidResult(NID_SYS, btResult == BT_ERROR_NONE, E_SYSTEM, "It is failed to unregister bluetooth headset connection event"); - - btResult = bt_audio_deinitialize(); - SysTryReturnVoidResult(NID_SYS, btResult == BT_ERROR_NONE, E_SYSTEM, "It is failed to close bluetooth"); - - btResult = bt_deinitialize(); - SysTryReturnVoidResult(NID_SYS, btResult == BT_ERROR_NONE, E_SYSTEM, "It is failed to init bluetooth module"); - isInitBluetooth = false; - } -} - -_DeviceManager* -_DeviceManager::GetInstance(void) -{ - if(__pDeviceManager == null) - { - __pDeviceManager = new (std::nothrow) _DeviceManager(); - } - return __pDeviceManager; -} - -result -_DeviceManager::InitializeDevice(void) -{ - result r = E_SUCCESS; - - if(isInitBluetooth == false) - { - SysLog(NID_SYS, "Bluetooth headset event is reserved."); - - int btResult = 0; - btResult = bt_initialize(); - - SysTryReturnResult(NID_SYS, btResult == BT_ERROR_NONE, E_SYSTEM, "It is failed to init bluetooth module"); - - btResult = bt_audio_initialize(); - SysTryReturnResult(NID_SYS, btResult == BT_ERROR_NONE, E_SYSTEM, "It is failed to init bluetooth audio module"); - - btResult = bt_audio_set_connection_state_changed_cb(bluetooth_connection_state_changed, null); - SysTryReturnResult(NID_SYS, btResult == BT_ERROR_NONE, E_SYSTEM, "It is failed to register bluetooth audio event"); - - isInitBluetooth = true; - } - media_key_reserve(app_media_key_handler, null); - - return r; -} - - -result -_DeviceManager::DeinitializeDevice(void) -{ - result r = E_SUCCESS; - media_key_release(); - return r; -} - - -result -_DeviceManager::RegisterListner(IDeviceEventListener &listener) -{ - __pDeviceManagerListener = &listener; - return E_SUCCESS; -} - -result -_DeviceManager::UnregisterListner(IDeviceEventListener &listener) -{ - __pDeviceManagerListener = null; - return E_SUCCESS; -} - -IDeviceEventListener* -_DeviceManager::GetEventListener() -{ - return __pDeviceManagerListener; -} - -String -_DeviceManager::GetId(void) -{ - return DEVICE_MANAGER_SERVICE_ID; -} - -bool -_DeviceManager::GetBluetoothStatus(void) -{ - return isBluetoothHeadSetConnected; -} -void -_DeviceManager::SetBluetoothStatus(bool status) -{ - isBluetoothHeadSetConnected = status; -} - -extern "C" _OSP_EXPORT_ _IDeviceManager* DeviceManager_CreateInstance() -{ - return _DeviceManager::GetInstance(); -} diff --git a/src/system-server/inc/FSys_DeviceManager.h b/src/system-server/inc/FSys_DeviceManager.h deleted file mode 100644 index 1b96fde..0000000 --- a/src/system-server/inc/FSys_DeviceManager.h +++ /dev/null @@ -1,64 +0,0 @@ -// -// 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_DeviceManager.h - * @brief This is the header file of the _DeviceManager class. - * - * This header file contains the declarations of the _DeviceManager class. - */ -#include -#include -#include -#include "FSys_IDeviceManager.h" - -#ifndef _FSYS_INTERNAL_DEVICE_MANAGER_H_ -#define _FSYS_INTERNAL_DEVICE_MANAGER_H_ - -namespace Tizen { namespace System { - -/** - * @class _DeviceManager - * @brief This class contains implementaion of device control. - * @since 2.1 - */ -class _OSP_EXPORT_ _DeviceManager - : public _IDeviceManager -{ -private: - _DeviceManager(void); - virtual ~_DeviceManager(void); -public: - virtual result InitializeDevice(void); - virtual result DeinitializeDevice(void); - virtual result RegisterListner(IDeviceEventListener &listener); - virtual result UnregisterListner(IDeviceEventListener &listener); - IDeviceEventListener* GetEventListener(); - - virtual Tizen::Base::String GetId(void); - void SetBluetoothStatus(bool status); - virtual bool GetBluetoothStatus(void); - static _DeviceManager* GetInstance(void); - -private: - static _DeviceManager* __pDeviceManager; - bool isBluetoothHeadSetConnected; - bool isInitBluetooth; - IDeviceEventListener* __pDeviceManagerListener; -}; //_DeviceManager - -}} //Tizen::System -#endif /* _FSYS_INTERNAL_DEVICE_MANAGER_H_ */ diff --git a/src/system-server/inc/FSys_IDeviceManager.h b/src/system-server/inc/FSys_IDeviceManager.h deleted file mode 100644 index 139d502..0000000 --- a/src/system-server/inc/FSys_IDeviceManager.h +++ /dev/null @@ -1,50 +0,0 @@ -// -// 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_IDeviceManager.h - * @brief This is the header file of the _IDeviceManager class. - * - * This header file contains the declarations of the _IDeviceManager class. - */ -#include -#include - -#ifndef _FSYS_INTERNAL_IDEVICE_MANAGER_H_ -#define _FSYS_INTERNAL_IDEVICE_MANAGER_H_ - -namespace Tizen { namespace System { - -/** - * @class _IDeviceManager - * @brief This class contains implementaion of device control. - * @since 2.1 - */ -class _OSP_EXPORT_ _IDeviceManager -{ -protected: - _IDeviceManager(void) {}; - virtual ~_IDeviceManager(void) {}; -public: - virtual result InitializeDevice(void) = 0; - virtual result DeinitializeDevice(void) = 0; - virtual bool GetBluetoothStatus(void) = 0; - virtual result RegisterListner(IDeviceEventListener &listener) = 0; - virtual result UnregisterListner(IDeviceEventListener &listener) = 0; -}; //_IDeviceManager - -}} //Tizen::System -#endif /* _FSYS_INTERNAL_IDEVICE_MANAGER_H_ */ diff --git a/src/system/CMakeLists.txt b/src/system/CMakeLists.txt index 0b14814..da0b937 100755 --- a/src/system/CMakeLists.txt +++ b/src/system/CMakeLists.txt @@ -42,7 +42,6 @@ SET (${this_target}_SOURCE_FILES FSys_DeviceEventListenerContainer.cpp FSys_SettingClient.cpp FSys_SystemClient.cpp - FSys_DeviceManagerMsgClient.cpp ) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") diff --git a/src/system/FSys_DeviceManagerImpl.cpp b/src/system/FSys_DeviceManagerImpl.cpp index cf68558..ff7ca7d 100644 --- a/src/system/FSys_DeviceManagerImpl.cpp +++ b/src/system/FSys_DeviceManagerImpl.cpp @@ -42,7 +42,6 @@ #include "FSys_CommunicationDispatcherClient.h" #include "FSys_DeviceManagerImpl.h" -#include "FSys_DeviceManagerMsgClient.h" #define VCONFKEY_APPSERVICE_MMC_STATUS "memory/appservice/mmc" @@ -57,7 +56,7 @@ using namespace Tizen::Io; namespace Tizen { namespace System { -static const wchar_t* _DEVICE_MANAGER_SERVICE_ID = L"osp.sys.ipcserver.devicemanager"; +static const wchar_t* _DEVICE_MANAGER_SERVICE_ID = L"osp.devicemanager.service"; static const wchar_t* _DEVICE_MANAGER_COMMAND_OPEN = L"osp.devicemanager.command.open"; static const wchar_t* _DEVICE_MANAGER_COMMAND_CLOSE = L"osp.devicemanager.command.close"; static const wchar_t* _DEVICE_MANAGER_COMMAND_STATUS = L"osp.devicemanager.command.status"; @@ -153,11 +152,13 @@ _DeviceManagerImpl::_DeviceManagerImpl() int ret = 0; static String DEVICE_MANAGER_SERVICE_ID(_DEVICE_MANAGER_SERVICE_ID); - _DeviceManagerMsgClient* pDeviceManagerMsgClient = _DeviceManagerMsgClient::GetInstance(); - SysTryCatch(NID_SYS, pDeviceManagerMsgClient != null, r = E_SYSTEM, r, "It is failed to get DeviceManagerMsgClient."); - r = pDeviceManagerMsgClient->RegisterListener(_DEVICE_MANAGER_SERVICE_ID,*this); - SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to register on DeviceManagerMsgClient."); - __pIpcClient = pDeviceManagerMsgClient->GetIpcClient(); + _CommunicationDispatcherClient* pCommunicationDispatcherClient = _CommunicationDispatcherClient::GetInstance(); + SysTryCatch(NID_SYS, pCommunicationDispatcherClient != null, r = E_SYSTEM, r, "It is failed to get CommunicationDispatcherClient."); + + r = pCommunicationDispatcherClient->RegisterCommunicationListener(DEVICE_MANAGER_SERVICE_ID, *this); + SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to register on CommunicationDispatcherClient."); + + __pIpcClient = pCommunicationDispatcherClient->GetIpcClient(); ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_USB_CONNECTED, OnDeviceStateChanged, null); SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to register USB event"); @@ -209,7 +210,7 @@ _DeviceManagerImpl::~_DeviceManagerImpl() { result r = E_SUCCESS; int ret = 0; - _DeviceManagerMsgClient* pDeviceManagerMsgClient = null; + _CommunicationDispatcherClient* pCommunicationDispatcherClient = null; String key(_DEVICE_MANAGER_SERVICE_ID); ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_USB_CONNECTED); @@ -237,13 +238,15 @@ _DeviceManagerImpl::~_DeviceManagerImpl() ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_HDMI, DeviceEventVConfCallBack); SysTryCatch(NID_SYS, ret == RUNTIME_INFO_ERROR_NONE, r = E_SYSTEM, r, "It is failed to unregister HDMI event"); - pDeviceManagerMsgClient = _DeviceManagerMsgClient::GetInstance(); - SysTryCatch(NID_SYS, pDeviceManagerMsgClient != null, r = E_SYSTEM, r, "It is failed to get DeviceManagerMsgClient."); - r = pDeviceManagerMsgClient->UnregisterListener(_DEVICE_MANAGER_SERVICE_ID); - SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to register on DeviceManagerMsgClient."); + pCommunicationDispatcherClient = _CommunicationDispatcherClient::GetInstance(); + SysTryCatch(NID_SYS, pCommunicationDispatcherClient != null, r = E_SYSTEM, r, "It is failed to get CommunicationDispatcherClient."); + + r = pCommunicationDispatcherClient->UnregisterCommunicationListener(key); + SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to register on CommunicationDispatcherClient."); __pIpcClient = null; + CATCH: SetLastResult(r); } @@ -460,8 +463,7 @@ _DeviceManagerImpl::RequireBluetoothEvent(void) r = __pIpcClient->SendRequest(pRequest.get()); SysTryReturnResult(NID_SYS, r == E_SUCCESS,E_SYSTEM, "It is failed to add bluetooth id"); - SysLog(NID_SYS, "It sent %ls", _DEVICE_MANAGER_COMMAND_OPEN); - + responseMessages.RemoveAll(true); } return r; diff --git a/src/system/FSys_DeviceManagerMsgClient.cpp b/src/system/FSys_DeviceManagerMsgClient.cpp deleted file mode 100644 index 3608023..0000000 --- a/src/system/FSys_DeviceManagerMsgClient.cpp +++ /dev/null @@ -1,122 +0,0 @@ -// -// 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_DeviceManagerMsgClient.cpp - * @brief This is the implementation file for _DeviceManagerMsgClient class. - */ - -#include -#include -#include -#include -#include -#include "FSys_DeviceManagerMsgClient.h" - -using namespace Tizen::App; -using namespace Tizen::Base; -using namespace Tizen::Base::Collection; -using namespace Tizen::Io; - -namespace Tizen { namespace System -{ -static const wchar_t* _DEVICE_MANAGER_MESSAGE_IPC_ID = L"osp.sys.ipcserver.devicemanager"; - -_DeviceManagerMsgClient* _DeviceManagerMsgClient::__pDeviceManagerMsgClient = null; - -_DeviceManagerMsgClient::_DeviceManagerMsgClient() - : __pIpcClient(null), - __pDeviceManagerMsgListener(null) -{ - result r = E_SUCCESS; - - __pIpcClient.reset(new (std::nothrow) _IpcClient()); - SysTryReturn(NID_SYS, __pIpcClient != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] It is failed to create IPC client"); - - r = __pIpcClient->Construct(_DEVICE_MANAGER_MESSAGE_IPC_ID, this); - - SysTryReturn(NID_SYS, r == E_SUCCESS, , r, "Propagated. [%s]", GetErrorMessage(r)); - SetLastResult(r); -} - -_DeviceManagerMsgClient::~_DeviceManagerMsgClient() -{ -} - -_DeviceManagerMsgClient* -_DeviceManagerMsgClient::GetInstance() -{ - if(__pDeviceManagerMsgClient == null) - { - __pDeviceManagerMsgClient = new (std::nothrow) _DeviceManagerMsgClient(); - SysTryReturn(NID_SYS, __pDeviceManagerMsgClient, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] It is not enough memory."); - } - return __pDeviceManagerMsgClient; -} - -_IpcClient* -_DeviceManagerMsgClient::GetIpcClient() -{ - return __pIpcClient.get(); -} - -result -_DeviceManagerMsgClient::RegisterListener(const String key, _ICommunicationDispatcherListener& listener) -{ - SysLog(NID_SYS, "Enter."); - SysTryReturnResult(NID_SYS, !__pDeviceManagerMsgListener, E_OBJ_ALREADY_EXIST, "DeviceManager listener was set already."); - __pDeviceManagerMsgListener = &listener; - SysLog(NID_SYS, "Exit."); - return E_SUCCESS; -} - -result -_DeviceManagerMsgClient::UnregisterListener(const String key) -{ - SysTryReturnResult(NID_SYS, __pDeviceManagerMsgListener, E_OBJ_NOT_FOUND, "DeviceManager listener is not set."); - __pDeviceManagerMsgListener = null; - return E_SUCCESS; -} - -void -_DeviceManagerMsgClient::OnIpcResponseReceived(_IpcClient& client, const IPC::Message& message) -{ - SysLog(NID_SYS, "Enter."); - IPC_BEGIN_MESSAGE_MAP(_DeviceManagerMsgClient, message) - IPC_MESSAGE_HANDLER_EX(IoService_Data, &client, OnDataReceived) - IPC_END_MESSAGE_MAP_EX() - SysLog(NID_SYS, "Exit."); -} - -void -_DeviceManagerMsgClient::OnDataReceived(const ArrayList& data) -{ - result r = E_SUCCESS; - String* pServiceId = (String*) data.GetAt(0); - - SysTryReturnVoidResult(NID_SYS, pServiceId != null, E_SYSTEM, "There is no service id."); - SysLog(NID_SYS, "Service id = %ls", pServiceId->GetPointer()); - - SysTryReturnVoidResult(NID_SYS, __pDeviceManagerMsgListener, E_SYSTEM, "Service[%ls] is available, but listener does not exist. [%s]", pServiceId->GetPointer(), GetErrorMessage(r)); - - __pDeviceManagerMsgListener->OnDataReceived(data); - - SysLog(NID_SYS, "Message is delivered to \"%ls\"[%x]", pServiceId->GetPointer(), __pDeviceManagerMsgListener); - ArrayList* temp = const_cast< ArrayList *> (&data); - temp->RemoveAll(true); -} - -}} diff --git a/src/system/FSys_DeviceManagerMsgClient.h b/src/system/FSys_DeviceManagerMsgClient.h deleted file mode 100644 index 7c2367f..0000000 --- a/src/system/FSys_DeviceManagerMsgClient.h +++ /dev/null @@ -1,63 +0,0 @@ -// -// 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_DeviceManagerMsgClient.h - * @brief This is the header file for the _DeviceManagerMsgClient class. - */ - -#ifndef _FSYS_INTERNAL_DEVICE_MANAGER_MESSAGE_CLIENT_IMPL_H_ -#define _FSYS_INTERNAL_DEVICE_MANAGER_MESSAGE_CLIENT_IMPL_H_ - -#include -#include -#include -#include -#include - -#include -#include -#include - -namespace Tizen { namespace System -{ - -class _DeviceManagerMsgClient - : public Tizen::Io::_IIpcClientEventListener -{ -private: - _DeviceManagerMsgClient(); - ~_DeviceManagerMsgClient(); - -public: - result RegisterListener(const Tizen::Base::String key, _ICommunicationDispatcherListener& listener); - result UnregisterListener(const Tizen::Base::String key); - void OnIpcResponseReceived(Tizen::Io::_IpcClient& client, const IPC::Message& message); - void OnDataReceived(const Tizen::Base::Collection::ArrayList& data); - - Tizen::Io::_IpcClient* GetIpcClient(void); - static _DeviceManagerMsgClient* GetInstance(void); - -private: - std::unique_ptr< Tizen::Io::_IpcClient > __pIpcClient; - _ICommunicationDispatcherListener* __pDeviceManagerMsgListener; -private: - static _DeviceManagerMsgClient* __pDeviceManagerMsgClient; -}; - -}} // Tizen::System - -#endif //_FSYS_INTERNAL_DEVICE_MANAGER_MESSAGE_CLIENT_IMPL_H_ -- 2.7.4