update the header for Doxygen
[platform/framework/native/bluetooth.git] / src / FNetBt_BluetoothHealthEventArg.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17 // @file    FNetBt_BluetoothHealthEventArg.cpp
18 // @brief   This is the implementation file for the _BluetoothHealthEventArg class.
19 //
20
21 #include <FBaseByteBuffer.h>
22 #include <FNetBtBluetoothDevice.h>
23 #include <FBaseSysLog.h>
24 #include "FNetBt_BluetoothHealthEventArg.h"
25
26
27 using namespace Tizen::Base;
28
29 namespace Tizen { namespace Net { namespace Bluetooth
30 {
31
32 //
33 // This is a class constructor for _BT_HEALTH_EVENT_CONNECTED event.
34 //
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)
42         , __result(r)
43         , __pData(null)
44 {
45         if (pDevice != null)
46         {
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.");
49         }
50 }
51
52 //
53 // This is a class constructor for _BT_HEALTH_EVENT_DISCONNECTED event.
54 //
55 _BluetoothHealthEventArg::_BluetoothHealthEventArg(int channelId, result r)
56         : __evtType(_BT_HEALTH_EVENT_DISCONNECTED)
57         , __pTargetDevice(null)
58         , __channelId(channelId)
59         , __dataType(0)
60         , __channelType(BT_HEALTH_DATA_CHANNEL_NONE)
61         , __result(r)
62         , __pData(null)
63 {
64 }
65
66 //
67 // This is a class constructor for _BT_HEALTH_EVENT_DATA_RECEIVED event.
68 //
69 _BluetoothHealthEventArg::_BluetoothHealthEventArg(int channelId, const Tizen::Base::ByteBuffer& buffer)
70         : __evtType(_BT_HEALTH_EVENT_DATA_RECEIVED)
71         , __pTargetDevice(null)
72         , __channelId(channelId)
73         , __dataType(0)
74         , __channelType(BT_HEALTH_DATA_CHANNEL_NONE)
75         , __result(E_SUCCESS)
76         , __pData(null)
77 {
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.");
80
81         __pData->Construct(buffer);
82         __pData->SetPosition(0);
83 }
84
85 _BluetoothHealthEventArg::~_BluetoothHealthEventArg(void)
86 {
87         delete __pTargetDevice;
88         delete __pData;
89 }
90
91 _BluetoothHealthEventType
92 _BluetoothHealthEventArg::GetEventType(void) const
93 {
94         return __evtType;
95 }
96
97 const BluetoothDevice*
98 _BluetoothHealthEventArg::GetSourceDevice(void) const
99 {
100         return __pTargetDevice;
101 }
102
103 int
104 _BluetoothHealthEventArg::GetChannelId(void) const
105 {
106         return __channelId;
107 }
108
109 int
110 _BluetoothHealthEventArg::GetDataType(void) const
111 {
112         return __dataType;
113 }
114
115 BluetoothHealthDataChannelType
116 _BluetoothHealthEventArg::GetChannelType(void) const
117 {
118         return __channelType;
119 }
120
121 result
122 _BluetoothHealthEventArg::GetErrorResult(void) const
123 {
124         return __result;
125 }
126
127 Tizen::Base::ByteBuffer*
128 _BluetoothHealthEventArg::GetReceivedData(void) const
129 {
130         return __pData;
131 }
132
133 } } } // Tizen::Net::Bluetooth