2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
17 // @file FNetBt_BluetoothHealthEventArg.cpp
18 // @brief This is the implementation file for the _BluetoothHealthEventArg class.
21 #include <FBaseByteBuffer.h>
22 #include <FNetBtBluetoothDevice.h>
23 #include <FBaseSysLog.h>
24 #include "FNetBt_BluetoothHealthEventArg.h"
27 using namespace Tizen::Base;
29 namespace Tizen { namespace Net { namespace Bluetooth
33 // This is a class constructor for _BT_HEALTH_EVENT_CONNECTED event.
35 _BluetoothHealthEventArg::_BluetoothHealthEventArg(int channelId, int dataType, BluetoothHealthDataChannelType channelType,
36 const BluetoothDevice* pDevice, result r)
37 : __evtType(_BT_HEALTH_EVENT_CONNECTED)
38 , __pTargetDevice(null)
39 , __channelId(channelId)
40 , __dataType(dataType)
41 , __channelType(channelType)
47 __pTargetDevice = new (std::nothrow) BluetoothDevice(*pDevice);
48 SysTryReturnVoidResult(NID_NET_BT, __pTargetDevice != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
53 // This is a class constructor for _BT_HEALTH_EVENT_DISCONNECTED event.
55 _BluetoothHealthEventArg::_BluetoothHealthEventArg(int channelId, result r)
56 : __evtType(_BT_HEALTH_EVENT_DISCONNECTED)
57 , __pTargetDevice(null)
58 , __channelId(channelId)
60 , __channelType(BT_HEALTH_DATA_CHANNEL_NONE)
67 // This is a class constructor for _BT_HEALTH_EVENT_DATA_RECEIVED event.
69 _BluetoothHealthEventArg::_BluetoothHealthEventArg(int channelId, const Tizen::Base::ByteBuffer& buffer)
70 : __evtType(_BT_HEALTH_EVENT_DATA_RECEIVED)
71 , __pTargetDevice(null)
72 , __channelId(channelId)
74 , __channelType(BT_HEALTH_DATA_CHANNEL_NONE)
78 __pData = new (std::nothrow) ByteBuffer();
79 SysTryReturnVoidResult(NID_NET_BT, __pData != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
81 __pData->Construct(buffer);
82 __pData->SetPosition(0);
85 _BluetoothHealthEventArg::~_BluetoothHealthEventArg(void)
87 delete __pTargetDevice;
91 _BluetoothHealthEventType
92 _BluetoothHealthEventArg::GetEventType(void) const
97 const BluetoothDevice*
98 _BluetoothHealthEventArg::GetSourceDevice(void) const
100 return __pTargetDevice;
104 _BluetoothHealthEventArg::GetChannelId(void) const
110 _BluetoothHealthEventArg::GetDataType(void) const
115 BluetoothHealthDataChannelType
116 _BluetoothHealthEventArg::GetChannelType(void) const
118 return __channelType;
122 _BluetoothHealthEventArg::GetErrorResult(void) const
127 Tizen::Base::ByteBuffer*
128 _BluetoothHealthEventArg::GetReceivedData(void) const
133 } } } // Tizen::Net::Bluetooth