update the header for Doxygen
[platform/framework/native/bluetooth.git] / src / FNetBt_BluetoothSppAcceptorEvent.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_BluetoothSppAcceptorEvent.cpp
18 // @brief   This is the implementation file for the _BluetoothSppAcceptorEvent class.
19 //
20
21 #include <FBaseRtIEventListener.h>
22 #include <FBaseSysLog.h>
23 #include <FBaseByteBuffer.h>
24 #include <FBaseRtIEventArg.h>
25 #include "FNetBt_BluetoothSppAcceptorEvent.h"
26 #include "FNetBt_BluetoothSppAcceptorEventArg.h"
27 #include "FNetBtIBluetoothSppAcceptorEventListener.h"
28
29
30 using namespace Tizen::Base;
31
32 namespace Tizen { namespace Net { namespace Bluetooth
33 {
34
35 _BluetoothSppAcceptorEvent::_BluetoothSppAcceptorEvent(void)
36 {
37 }
38
39 _BluetoothSppAcceptorEvent::~_BluetoothSppAcceptorEvent(void)
40 {
41 }
42
43 result
44 _BluetoothSppAcceptorEvent::Construct(void)
45 {
46         return _Event::Initialize();
47 }
48
49 void
50 _BluetoothSppAcceptorEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
51 {
52         const BluetoothDevice* pDevice = null;
53         ByteBuffer* pData = null;
54
55         IBluetoothSppAcceptorEventListener* pListener = dynamic_cast <IBluetoothSppAcceptorEventListener*>(&listener);
56         SysTryReturnVoidResult(NID_NET_BT, pListener != null, E_INVALID_ARG, "[E_INVALID_ARG] The listener argument is invalid.");
57
58         const _BluetoothSppAcceptorEventArg* pEventArg = dynamic_cast <const _BluetoothSppAcceptorEventArg*>(&arg);
59         SysTryReturnVoidResult(NID_NET_BT, pEventArg != null, E_INVALID_ARG, "[E_INVALID_ARG] The event argument is invalid type.");
60
61         _BluetoothSppAcceptorEventType eventType = pEventArg->GetEventType();
62
63         switch (eventType)
64         {
65         case _BT_SPP_ACCEPTOR_EVENT_CONN_REQUESTED:
66                 pDevice = pEventArg->GetRequester();
67                 if (pDevice != null)
68                 {
69                         SysLog(NID_NET_BT, "Firing Bluetooth SPP Acceptor Event (Type: _BT_SPP_ACCEPTOR_EVENT_CONN_REQUESTED)");
70                         pListener->OnSppConnectionRequested(*pDevice);
71                 }
72                 break;
73
74         case _BT_SPP_ACCEPTOR_EVENT_DISCONNECTED:
75                 SysLog(NID_NET_BT, "Firing Bluetooth SPP Acceptor Event (Type: _BT_SPP_ACCEPTOR_EVENT_DISCONNECTED)");
76                 pListener->OnSppDisconnected(pEventArg->GetErrorResult());
77                 break;
78
79         case _BT_SPP_ACCEPTOR_EVENT_DATA_RECEIVED:
80                 pData = pEventArg->GetReceivedData();
81                 if (pData != null)
82                 {
83                         SysLog(NID_NET_BT, "Firing Bluetooth SPP Acceptor Event (Type: _BT_SPP_ACCEPTOR_EVENT_DATA_RECEIVED)");
84                         pListener->OnSppDataReceived(*pData);
85                 }
86                 break;
87
88         default:
89                 break;
90         }
91 }
92
93 } } } // Tizen::Net::Bluetooth