Fixed bug.
[platform/framework/native/net.git] / inc / FNetINetConnectionEventListener.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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
18 /**
19  * @file        FNetINetConnectionEventListener.h
20  * @brief       This is the header file for the %INetConnectionEventListener interface.
21  *
22  * This header file contains the declarations of the %INetConnectionEventListener interface.
23  *
24  */
25 #ifndef _FNET_INET_CONNECTION_EVENT_LISTENER_H_
26 #define _FNET_INET_CONNECTION_EVENT_LISTENER_H_
27
28 #include <FBaseRtIEventListener.h>
29
30 namespace Tizen { namespace Net
31 {
32 class NetConnection;
33
34 /**
35  * @interface   INetConnectionEventListener
36  * @brief               This interface implements the listeners for the network connection events.
37  *
38  * @since               2.0
39  *
40  *  The %INetConnectionEventListener interface specifies the methods for creating the notifications about the different kinds of network
41  *      connection events. These events are only sent when %INetConnectionEventListener is added to a NetConnection instance, by invoking the
42  *      NetConnection::AddNetConnectionListener() method. When a network connection event is generated, a method of this class is called.
43  *
44  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/managing_network_connections.htm">Managing Network Connections</a>.
45  *
46  * The following example demonstrates how to use the %INetConnectionEventListener interface.
47  *
48  * @code
49 using namespace Tizen::Net;
50 using namespace Tizen::Base;
51
52 class TestListener
53         : public Object
54         , public virtual INetConnectionEventListener
55 {
56 public:
57         TestListener() {}
58
59         ~TestListener() {}
60
61         void OnNetConnectionStarted(NetConnection& netConnection, result r)
62         {
63                 AppLog("OnStarted\n");
64         }
65
66         void OnNetConnectionStopped(NetConnection& netConnection, result r)
67         {
68                 AppLog("OnStopped\n");
69         }
70
71         void OnNetConnectionSuspended(NetConnection& netConnection)
72         {
73                 AppLog("OnSuspended\n");
74         }
75
76         void OnNetConnectionResumed(NetConnection& netConnection)
77         {
78                 AppLog("OnResumed\n");
79         }
80 };
81  * @endcode
82  */
83 class _OSP_EXPORT_ INetConnectionEventListener
84         : virtual public Tizen::Base::Runtime::IEventListener
85 {
86 public:
87         /**
88          * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
89          *
90          * @since       2.0
91          */
92         virtual ~INetConnectionEventListener(void) {}
93
94 public:
95         /**
96          * Called to notify the application that the network connection has been opened and connected. @n
97          * An application can send or receive the data.
98          *
99          * @since               2.0
100          *
101          * @param[in]   netConnection                           The network connection
102          * @param[in]   r                                                       An error code
103          * @exception   E_SUCCESS                                       The method is successful.
104          * @exception   E_TIMEOUT                                       An attempt to connect to the server has timed out.
105          * @exception   E_DEVICE_BUSY                           The device cannot be approached because of other operations.
106          * @exception   E_DEVICE_UNAVAILABLE            The operation has failed due to a missing SIM card.
107          * @exception   E_NETWORK_UNAVAILABLE           The operation has failed because the device is in the offline mode.
108          * @exception   E_SERVICE_UNAVAILABLE           The operation has failed because the device is out of the coverage area or in the emergency mode.
109          * @exception   E_RESOURCE_UNAVAILABLE          The network resource is unavailable.
110          * @exception   E_AUTHENTICATION                        The authentication has failed.
111          * @exception   E_UNSUPPORTED_OPERATION         This operation is not supported.
112          * @exception   E_SYSTEM                                        A system error has occurred.
113          * @exception   E_NETWORK_FAILED                        Requested but an error is received from the network.
114          * @exception   E_INVALID_SIM_STATE                     The network has marked SIM as invalid for the CS and/or PS domain.
115          * @exception   E_FDN_MODE                                      The FDN is enabled and the number is not listed in the FDN list.
116          * @exception   E_DHCP                                          The DHCP operation has failed on WLAN.
117          * @exception   E_LINK                                          A link failure has occurred on WLAN.
118          */
119         virtual void OnNetConnectionStarted(NetConnection& netConnection, result r) = 0;
120
121         /**
122          * Called to notify the application that the network connection has been closed and disconnected.
123          *
124          * @since               2.0
125          *
126          * @param[in]   netConnection                           The network connection
127          * @param[in]   r                                                       An error code
128          * @exception   E_SUCCESS                                       The method is successful.
129          * @exception   E_NETWORK_UNAVAILABLE           The operation has failed because the device is in the offline mode.
130          * @exception   E_SERVICE_UNAVAILABLE           The operation has failed because the device is out of the coverage area or in the emergency mode.
131          * @exception   E_RESOURCE_UNAVAILABLE          The network resource is unavailable.
132          * @exception   E_UNSUPPORTED_OPERATION         This operation is not supported.
133          * @exception   E_SYSTEM                                        A system error has occurred.
134          * @exception   E_NETWORK_FAILED                        Requested but an error is received from the network.
135          * @exception   E_INVALID_SIM_STATE                     The network has marked SIM as invalid for the CS and/or PS domain.
136          * @exception   E_FDN_MODE                                      The FDN is enabled and the number is not listed in the FDN list.
137          * @exception   E_DHCP                                          The DHCP operation has failed on WLAN.
138          * @exception   E_LINK                                          A link failure has occurred on WLAN.
139          * @remarks             This notification does not imply that the network is stopped permanently and cannot be used.
140          *                              The network can be restarted using NetConnection::Start().
141          *                              The NetConnection::Close() method is used to disconnect the connection
142          *              from the remote server or gateway permanently.
143          */
144         virtual void OnNetConnectionStopped(NetConnection& netConnection, result r) = 0;
145
146         /**
147          * Called to notify the application that the connection status has changed or is in an unstable or suspended state. @n
148          * Thus, an application may neither send nor receive data through Socket or Http until the network connection is resumed.
149          *
150          * @since               2.0
151          *
152          * @param[in]   netConnection           The network connection
153          *
154          */
155         virtual void OnNetConnectionSuspended(NetConnection& netConnection) = 0;
156
157         /**
158          * Called to notify the application that the network has recovered from a suspended state. @n
159          * Thus, an application can send or receive data through Socket or Http from now on.
160          *
161          * @since               2.0
162          *
163          * @param[in]   netConnection           The network connection
164          */
165         virtual void OnNetConnectionResumed(NetConnection& netConnection) = 0;
166
167 protected:
168         //
169         // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
170         //
171         // This method is reserved and may change its name at any time without prior notice.
172         //
173         // @since       2.0
174         //
175          virtual void INetConnectionEventListener_Reserved1(void) {}
176
177         //
178         // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
179         //
180         // This method is reserved and may change its name at any time without prior notice.
181         //
182         // @since       2.0
183         //
184          virtual void INetConnectionEventListener_Reserved2(void) {}
185 }; // INetConnectionEventListener
186
187 } } // Tizen::Net
188 #endif // _FNET_INET_CONNECTION_EVENT_LISTENER_H_