a4b2404723c633f113e7a5f1ee3f06a96e2c28e4
[profile/ivi/smartdevicelink.git] / src / components / transport_manager / include / transport_manager / transport_manager_listener.h
1 /**
2  * \file transport_manager_listener.h
3  * \brief TransportManagerListener class header file.
4  *
5  * Copyright (c) 2013, Ford Motor Company
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  * Redistributions of source code must retain the above copyright notice, this
12  * list of conditions and the following disclaimer.
13  *
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
17  * distribution.
18  *
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.
22  *
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.
34  */
35
36 #ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_MANAGER_LISTENER_H_
37 #define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_MANAGER_LISTENER_H_
38
39 #include "transport_manager/common.h"
40 #include "transport_manager/info.h"
41 #include "transport_manager/error.h"
42
43 namespace transport_manager {
44
45 class TransportManagerListener {
46  public:
47   /**
48    * @brief Destructor.
49    */
50   virtual ~TransportManagerListener() {
51   }
52
53   /**
54    * @brief Reaction to the event, when the list of devices is updated.
55    *
56    * @param Container that holds information about devices.
57    */
58   virtual void OnDeviceListUpdated(const std::vector<DeviceInfo>&) = 0;
59
60   /**
61    * @brief Reaction to the event, when the device is found.
62    *
63    * @param device_info Variable that hold information about device.
64    */
65   virtual void OnDeviceFound(const DeviceInfo &device_info) = 0;
66   virtual void OnDeviceAdded(const DeviceInfo &device_info) = 0;
67   virtual void OnDeviceRemoved(const DeviceInfo &device_info) = 0;
68
69   /**
70    * @brief Reaction to the event, when scanning of devices is finished.
71    */
72   virtual void OnScanDevicesFinished() = 0;
73
74   /**
75    * @brief Reaction to the event, when scanning of devices is failed.
76    *
77    * @param error Error information about possible reason of scanning of devices failure.
78    */
79   virtual void OnScanDevicesFailed(const SearchDeviceError& error) = 0;
80
81   /**
82    * @brief Reaction to the event, when connection is established.
83    *
84    * @param devcie_info Variable that hold information about device.
85    * @param connection_id connection unique identifier.
86    */
87   virtual void OnConnectionEstablished(const DeviceInfo &device_info,
88                                        const ConnectionUID &connection_id) = 0;
89
90   /**
91    * @brief Reaction to the event, when connection to the device is failed.
92    *
93    * @param device_info Variable that hold information about device.
94    * @param error Error information about possible reason of connect failure.
95    */
96   virtual void OnConnectionFailed(const DeviceInfo &device_info,
97                                   const ConnectError& error) = 0;
98
99   /**
100    * @brief Reaction to the event, when connection is closed.
101    *
102    * @param connection_id Connection unique identifier.
103    */
104   virtual void OnConnectionClosed(ConnectionUID connection_id) = 0;
105
106   /**
107    * @brief Called when connection is closed unexpectedly, i.e. disconnect was not requested
108    *
109    * @param connection_id Connection ID.
110    * @param error Error information.
111    */
112   virtual void OnUnexpectedDisconnect(ConnectionUID connection_id,
113                                       const CommunicationError& error) = 0;
114
115   /**
116    * @brief Reaction to the event, when connection close is failed.
117    *
118    * @param connection_id Connection unique identifier.
119    * @param error Error information about possible reason of failure.
120    */
121   virtual void OnConnectionClosedFailure(ConnectionUID connection_id,
122                                          const DisconnectError& error) = 0;
123
124   /**
125    * \brief Inform about losing connection with device.
126    * \param device Handle of device.
127    * \param error Error information about possible reason of loosing connection.
128    */
129   virtual void OnDeviceConnectionLost(const DeviceHandle& device,
130                                       const DisconnectDeviceError& error) = 0;
131
132   /**
133    * \brief Inform about failure during DisconnectDevice procedure of transport manager.
134    * \param device Handle of device.
135    * \param error Error information about possible reason of disconnecting failure.
136    */
137   virtual void OnDisconnectFailed(const DeviceHandle& device,
138                                   const DisconnectDeviceError& error) = 0;
139   /**
140    * @brief Notifies about recieving message from TM.
141    *
142    * @param message Recieved message
143    **/
144   virtual void OnTMMessageReceived(const RawMessageSptr message) = 0;
145
146   /**
147    * @brief Reaction to the event, when receiving of massage for transport manager is failed.
148    *
149    * @param connection_id connection unique identifier.
150    * @param error Error information about possible reason of failure.
151    */
152   virtual void OnTMMessageReceiveFailed(ConnectionUID connection_id,
153                                         const DataReceiveError& error) = 0;
154
155   /**
156    * @brief Reaction to the event, when transport manager sent a massage.
157    */
158   virtual void OnTMMessageSend(const RawMessageSptr message) = 0;
159
160   /**
161    * @brief Reaction to the event, when sending of massage by transport manager is failed.
162    *
163    * @param error Error information about possible reason of failure.
164    * @param message Smart pointer to the raw massage.
165    */
166   virtual void OnTMMessageSendFailed(const DataSendError& error,
167                                      const RawMessageSptr message) = 0;
168 };
169 }  //  namespace transport_manager
170 #endif  //  SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_MANAGER_LISTENER