diff options
Diffstat (limited to 'src/FNetBt_BluetoothManagerImpl.cpp')
-rwxr-xr-x | src/FNetBt_BluetoothManagerImpl.cpp | 76 |
1 files changed, 7 insertions, 69 deletions
diff --git a/src/FNetBt_BluetoothManagerImpl.cpp b/src/FNetBt_BluetoothManagerImpl.cpp index 05b42d5..40f8587 100755 --- a/src/FNetBt_BluetoothManagerImpl.cpp +++ b/src/FNetBt_BluetoothManagerImpl.cpp @@ -33,8 +33,6 @@ #include "FNetBt_BluetoothManagerEventArg.h" #include "FNetBt_BluetoothDeviceEvent.h" #include "FNetBt_BluetoothDeviceEventArg.h" -#include "FNetBt_BluetoothConnectionEvent.h" -#include "FNetBt_BluetoothConnectionEventArg.h" using namespace std; using namespace Tizen::Base; @@ -49,9 +47,7 @@ _BluetoothManagerImpl::_BluetoothManagerImpl(void) , __pGapAdapter(null) , __pMgrEvent(null) , __pDevEvent(null) - , __pConEvent(null) , __pDevEvtListener(null) - , __pConEvtListener(null) , __pLocalDevice(null) , __pairedDeviceList() , __pairedDeviceMap() @@ -78,6 +74,8 @@ _BluetoothManagerImpl::~_BluetoothManagerImpl(void) __pGapAdapter->UnregisterManagerEventListener(*this); __pGapAdapter->UnregisterDeviceEventListener(*this); } + + delete __pLocalDevice; } result @@ -86,7 +84,6 @@ _BluetoothManagerImpl::Construct(IBluetoothManagerEventListener& listener) result r = E_SUCCESS; unique_ptr<_BluetoothManagerEvent> pMgrEvent; unique_ptr<_BluetoothDeviceEvent> pDevEvent; - unique_ptr<_BluetoothConnectionEvent> pConEvent; r = __stateMutex.Create(); SysTryReturnResult(NID_NET_BT, r == E_SUCCESS, E_SYSTEM, "Failed to create the state mutex."); @@ -113,11 +110,6 @@ _BluetoothManagerImpl::Construct(IBluetoothManagerEventListener& listener) r = pDevEvent->Construct(); SysTryReturnResult(NID_NET_BT, r == E_SUCCESS, E_SYSTEM, "Failed to construct the event."); - pConEvent.reset(new (std::nothrow) _BluetoothConnectionEvent()); - SysTryReturnResult(NID_NET_BT, pConEvent != null, E_OUT_OF_MEMORY, "The memory is insufficient."); - r = pConEvent->Construct(); - SysTryReturnResult(NID_NET_BT, r == E_SUCCESS, E_SYSTEM, "Failed to construct the event."); - // add the IBluetoothManagerEventListener instance to a new created _BluetoothManagerEvent. r = pMgrEvent->AddListener(listener, true); SysTryReturnResult(NID_NET_BT, r == E_SUCCESS, E_SYSTEM, @@ -167,7 +159,6 @@ _BluetoothManagerImpl::Construct(IBluetoothManagerEventListener& listener) __pMgrEvent = move(pMgrEvent); __pDevEvent = move(pDevEvent); - __pConEvent = move(pConEvent); return E_SUCCESS; } @@ -394,6 +385,9 @@ _BluetoothManagerImpl::SetDiscoverableMode(BluetoothDiscoverableMode mode, int s { result r = E_SUCCESS; + SysTryReturnResult(NID_NET_BT, (mode != BT_DISC_MODE_TIME_LIMITED_DISCOVERABLE || seconds>0) , E_INVALID_ARG, + "The seconds should be greater than 0"); + // Sets the discoverable mode through osp-connectivity-service. r = __pIpcProxy->SetDiscoverableMode((int)mode, seconds); SysTryReturnResult(NID_NET_BT, r != E_PRIVILEGE_DENIED && r != E_USER_NOT_CONSENTED, r, @@ -707,34 +701,6 @@ _BluetoothManagerImpl::SetBluetoothDeviceListener(IBluetoothDeviceEventListener* } result -_BluetoothManagerImpl::SetBluetoothConnectionListener(_IBluetoothConnectionEventListener* pListener) -{ - result r = E_SUCCESS; - - SysTryReturnResult(NID_NET_BT, __pConEvtListener != pListener, E_SUCCESS, "the listener instance is already registered."); - - if (__pConEvtListener != null) - { - // remove the previous IBluetoothDeviceEventListener instance from the _BluetoothDeviceEvent. - r = __pMgrEvent->RemoveListener(*__pConEvtListener); - SysTryReturnResult(NID_NET_BT, r == E_SUCCESS, E_SYSTEM, "Failed to remove the previous _IBluetoothConnectionEventListener."); - SysLog(NID_NET_BT, "Removing the previous _IBluetoothConnectionEventListener is successful."); - __pConEvtListener = null; - } - - if (pListener != null) - { - // add the specified new IBluetoothDeviceEventListener instance to the _BluetoothDeviceEvent. - r = __pMgrEvent->AddListener(*pListener, true); - SysTryReturnResult(NID_NET_BT, r == E_SUCCESS, E_SYSTEM, "Failed to add the new _IBluetoothConnectionEventListener."); - SysLog(NID_NET_BT, "Adding the new _IBluetoothConnectionEventListener is successful."); - __pConEvtListener = pListener; - } - - return r; -} - -result _BluetoothManagerImpl::StartDiscovery(void) { SysLog(NID_NET_BT, "EntryPoint, [CurrentState:%s]", GetStringOfCurrentState()); @@ -1615,21 +1581,7 @@ _BluetoothManagerImpl::OnBluetoothDeviceConnected(const Tizen::Base::ByteBuffer& { SysLog(NID_NET_BT, "EntryPoint, [CurrentState:%s]", GetStringOfCurrentState()); - bool isFired = false; - - _BluetoothConnectionEventArg* pArg = new (std::nothrow) _BluetoothConnectionEventArg(_BT_CONNECTION_EVENT_CONNECTED, address); - if (pArg == null) - { - SysLogException(NID_NET_BT, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); - } - else - { - __pConEvent->FireAsync(*pArg); - isFired = true; - } - - SysLog(NID_NET_BT, "ExitPoint, [CurrentState:%s], [CONNECTED_Event:%s]", - GetStringOfCurrentState(), isFired ? "Fired" : "NotFired"); + // This callback is reserved for later use } void @@ -1637,21 +1589,7 @@ _BluetoothManagerImpl::OnBluetoothDeviceDisconnected(const Tizen::Base::ByteBuff { SysLog(NID_NET_BT, "EntryPoint, [CurrentState:%s]", GetStringOfCurrentState()); - bool isFired = false; - - _BluetoothConnectionEventArg* pArg = new (std::nothrow) _BluetoothConnectionEventArg(_BT_CONNECTION_EVENT_DISCONNECTED, address); - if (pArg == null) - { - SysLogException(NID_NET_BT, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); - } - else - { - __pConEvent->FireAsync(*pArg); - isFired = true; - } - - SysLog(NID_NET_BT, "ExitPoint, [CurrentState:%s], [DISCONNECTED_Event:%s]", - GetStringOfCurrentState(), isFired ? "Fired" : "NotFired"); + // This callback is reserved for later use } result |