2 * \file transport_adapter_listener_impl.h
3 * \brief TransportAdapterListenerImpl class header file.
5 * Copyright (c) 2013, Ford Motor Company
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
11 * Redistributions of source code must retain the above copyright notice, this
12 * list of conditions and the following disclaimer.
14 * Redistributions in binary form must reproduce the above copyright notice,
15 * this list of conditions and the following
16 * disclaimer in the documentation and/or other materials provided with the
19 * Neither the name of the Ford Motor Company nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
36 #ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_ADAPTER_TRANSPORT_ADAPTER_LISTENER_IMPL_H_
37 #define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_ADAPTER_TRANSPORT_ADAPTER_LISTENER_IMPL_H_
39 #include "transport_manager/common.h"
40 #include "transport_manager/transport_adapter/transport_adapter_listener.h"
41 #include "transport_manager/transport_adapter/transport_adapter.h"
43 using transport_manager::transport_adapter::TransportAdapter;
45 namespace transport_manager {
47 class TransportManagerImpl;
50 * @brief Implementation of TransportAdapterListener class.
52 class TransportAdapterListenerImpl
53 : public transport_adapter::TransportAdapterListener {
56 * @enum Available types of events.
61 ON_DEVICE_LIST_UPDATED,
62 ON_APPLICATION_LIST_UPDATED,
71 ON_COMMUNICATION_ERROR,
72 ON_UNEXPECTED_DISCONNECT
78 * @param manager Pointer to the transport manager implementation class.
79 * @param adapter Pointer to the transport adapter associated with listener.
81 TransportAdapterListenerImpl(TransportManagerImpl* manager,
82 TransportAdapter* adapter);
87 virtual ~TransportAdapterListenerImpl();
90 * @brief Search specified device adapter in the container of shared pointers
91 *to device adapters to be sure it is available,
92 * launch event ON_SEARCH_DONE in transport manager.
94 * @param adapter Pointer to the device adapter.
96 virtual void OnSearchDeviceDone(const TransportAdapter* adapter);
99 * @brief Search specified device adapter in the container of shared pointers
100 *to device adapters to be sure it is available, create search device error,
101 * launch event ON_SEARCH_FAIL in transport manager.
103 * @param adapter Pointer to the device adapter.
104 * @param error Error class with information about possible reason of search
107 virtual void OnSearchDeviceFailed(const TransportAdapter* adapter,
108 const SearchDeviceError& error);
111 * @brief Passes notification to TransportManagerImpl
113 * @param adapter Transport adapter that sent notification
115 virtual void OnDeviceListUpdated(const TransportAdapter* adapter);
119 * @brief Reaction on event, when new applications are started on device
120 * and SDL found this application
122 * @param adapter Current transport adapter
123 * @param device_handle Unique ID of device with new application list
126 virtual void OnApplicationListUpdated(const TransportAdapter* adapter,
127 const DeviceUID& device_handle);
130 * @brief Search specified device adapter in the container of shared pointers
131 *to device adapters to be sure it is available,
132 * launch event ON_CONNECT_DONE in transport manager.
134 * @param device_adater Pointer to the device adapter.
135 * @param device_handle Device unique identifier.
136 * @param app_id Handle of application.
138 virtual void OnConnectDone(const TransportAdapter* adapter,
139 const DeviceUID& device_handle,
140 const ApplicationHandle& app_id);
143 * @brief Search specified device adapter in the container of shared pointers
144 *to device adapters to be sure it is available,
145 * launch event ON_CONNECT_FAIL in transport manager.
147 * @param adapter Pointer to the device adapter.
148 * @param device Device unique identifier.
149 * @param app_id Handle of application.
150 * @param error Error class with information about possible reason of connect
153 virtual void OnConnectFailed(const TransportAdapter* adapter,
154 const DeviceUID& device,
155 const ApplicationHandle& app_id,
156 const ConnectError& error);
161 * @param adapter Pointer to the device adapter.
162 * @param device_handle Device unique identifier.
163 * @param app_handle Handle of application.
165 virtual void OnConnectRequested(const TransportAdapter* adapter,
166 const DeviceUID& device_handle,
167 const ApplicationHandle& app_handle);
170 * @brief Search specified device adapter in the container of shared pointers
171 *to device adapters to be sure it is available,
172 * launch event ON_UNEXPECTED_DISCONNECT in transport manager.
174 * @param adapter Pointer to the device adapter.
175 * @param device Device unique identifier.
176 * @param app_id Handle of application.
177 * @param error Error class with information about possible reason of
178 *unexpected Disconnect.
180 virtual void OnUnexpectedDisconnect(const TransportAdapter* adapter,
181 const DeviceUID& device,
182 const ApplicationHandle& app_id,
183 const CommunicationError& error);
186 * @brief Search specified device adapter in the container of shared pointers
187 *to device adapters to be sure it is available,
188 * launch event ON_DISCONNECT_DONE in transport manager.
190 * @param adapter Pointer to the device adapter.
191 * @param devcie_id Device unique identifier.
192 * @param app_id Handle of application.
194 virtual void OnDisconnectDone(const TransportAdapter* adapter,
195 const DeviceUID& device_id,
196 const ApplicationHandle& app_id);
199 * @brief Search specified device adapter in the container of shared pointers
200 *to device adapters to be sure it is available, create Disconnect error,
201 * launch event ON_DISCONNECT_FAIL in transport manager.
203 * @param adapter Pointer to the device adapter.
204 * @param device Device unique identifier.
205 * @param app_id Handle of application.
206 * @param error Error class with information about possible reason of
209 virtual void OnDisconnectFailed(const TransportAdapter* adapter,
210 const DeviceUID& device,
211 const ApplicationHandle& app_id,
212 const DisconnectError& error);
217 * @param adapter Pointer to the device adapter.
218 * @param devic Device unique identifier.
220 virtual void OnDisconnectDeviceDone(const TransportAdapter* adapter,
221 const DeviceUID& device);
226 * @param adapter Pointer to the device adapter.
227 * @param device Device unique identifier.
228 * @param error Error class with information about possible reason of
229 *Disconnect from device failure.
231 virtual void OnDisconnectDeviceFailed(const TransportAdapter* adapter,
232 const DeviceUID& device,
233 const DisconnectDeviceError& error);
236 * @brief Search specified device adapter in the container of shared pointers
237 *to device adapters to be sure it is available, create error,
238 * launch event ON_RECEIVED_DONE in transport manager.
240 * @param adapter Pointer to the device adapter.
241 * @param devcie Device unique identifier.
242 * @param app_id Handle of application.
243 * @param data_container Smart pointer to the raw message.
245 virtual void OnDataReceiveDone(const TransportAdapter* adapter,
246 const DeviceUID& device,
247 const ApplicationHandle& app_id,
248 const RawMessageSptr data_container);
251 * @brief Search specified device adapter in the container of shared pointers
252 *to device adapters to be sure it is available, create data receive error,
253 * launch event ON_RECEIVED_DONE in transport manager.
255 * @param adapter Pointer to the device adapter.
256 * @param device Device unique identifier.
257 * @param app_id Handle of application.
258 * @param error Error class with information about possible reason of data
261 virtual void OnDataReceiveFailed(const TransportAdapter* adapter,
262 const DeviceUID& device,
263 const ApplicationHandle& app_id,
264 const DataReceiveError& error);
267 * @brief Search specified device adapter in the container of shared pointers
268 *to device adapters to be sure it is available, create error,
269 * launch event ON_SEND_DONE in transport manager.
271 * @param adapter Pointer to the device adapter.
272 * @param device Device unique identifier.
273 * @param app_id Handle of application.
274 * @param data_container Smart pointer to the raw message.
276 virtual void OnDataSendDone(const TransportAdapter* adapter,
277 const DeviceUID& device,
278 const ApplicationHandle& app_id,
279 const RawMessageSptr data_container);
282 * @brief Search specified device adapter in the container of shared pointers
283 * to device adapters to be sure it is available, create data send error,
284 * launch event ON_SEND_FAIL in transport manager.
286 virtual void OnDataSendFailed(const TransportAdapter* adapter,
287 const DeviceUID& device,
288 const ApplicationHandle& app_id,
289 const RawMessageSptr data_container,
290 const DataSendError& error);
293 * @brief Search specified device adapter in the container of shared pointers
294 *to device adapters to be sure it is available, create error,
295 * launch event ON_COMMUNICATION_ERROR in transport manager.
297 * @param adapter Pointer to the device adapter.
298 * @param device Device unique identifier.
299 * @param app_id Handle of application.
301 virtual void OnCommunicationError(const TransportAdapter* adapter,
302 const DeviceUID& device,
303 const ApplicationHandle& app_id);
306 TransportManagerImpl* transport_manager_impl_;
307 TransportAdapter* transport_adapter_;
309 } // namespace transport_manager
311 #endif // SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_transport_adapter_transport_adapter_LISTENER_IMPL_H