2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FNet_SystemNetConnection.h
19 * @brief This is the header file for the %_SystemNetConnection class.
21 * This header file contains the declarations of the %_SystemNetConnection class.
24 #ifndef _FNET_INTERNAL_SYSTEM_NET_CONNECTION_H_
25 #define _FNET_INTERNAL_SYSTEM_NET_CONNECTION_H_
27 #include <unique_ptr.h>
28 #include <FBaseDataType.h>
29 #include <FBaseObject.h>
30 #include <FBaseString.h>
31 #include <FNetNetTypes.h>
33 namespace Tizen { namespace Base { namespace Collection
37 } } } // Tizen::Base::Collection
39 namespace Tizen { namespace Base { namespace Runtime
42 } } } // Tizen::Base::Runtime
44 namespace Tizen { namespace Net
46 class NetConnectionInfo;
47 class _NetConnectionEvent;
48 class _NetConnectionInfoImpl;
49 class _DefaultSystemNetConnection;
50 class _WifiSystemNetConnection;
51 class _WifiDirectSystemNetConnection;
52 class _UsbSystemNetConnection;
55 * @class _SystemNetConnection
56 * @brief This class provides methods for a system network connection.
60 * This class provides methods for a system network connection.
62 class _SystemNetConnection
63 : public Tizen::Base::Object
70 * @param[in] event A reference to _NetConnectionEvent
71 * @return An error code
72 * @exception E_SUCCESS The method was successful.
73 * @exception E_INVALID_STATE This instance has not been constructed as yet or it may be closed.
75 result AddEvent(_NetConnectionEvent& event);
81 * @param[in] event A reference to _NetConnectionEvent
82 * @return An error code
83 * @exception E_SUCCESS The method was successful.
84 * @exception E_INVALID_STATE This instance has not been constructed as yet or it may be closed.
85 * @exception E_OBJ_NOT_FOUND The EventListener was not found.
87 result RemoveEvent(_NetConnectionEvent& event);
90 * Starts the network connection.
94 * @return An error code
95 * @exception E_SUCCESS The method was successful.
96 * @exception E_INVALID_STATE This instance is in an invalid state.
97 * @exception E_SYSTEM An internal error occurred.
100 virtual result Start(_NetConnectionEvent& event);
103 * Stops the network connection.
107 * @return An error code
108 * @exception E_SUCCESS The method was successful.
109 * @exception E_INVALID_STATE This instance is in an invalid state.
110 * @exception E_SYSTEM An internal error occurred.
113 virtual result Stop(_NetConnectionEvent& event, bool waitingEvent = true);
115 virtual void HandleStartResponse(result error, void* pData);
116 virtual void HandleStopResponse(void);
117 virtual void HandleStartEvent(void);
118 virtual void HandleStopEvent(result error);
120 virtual NetConnectionState QueryConnectionState(Tizen::Base::String& devName) const;
122 NetBearerType GetBearerType(void) const;
123 NetConnectionState GetConnectionState(void) const;
124 Tizen::Base::String GetProxyAddress(void) const;
126 void GetConnectionInfo(NetConnectionInfo& netConnectionInfo);
129 static void InitializeNetworkFramework(void);
131 static _SystemNetConnection* GetPsInstance(NetAccountId netAccountId);
132 static _SystemNetConnection* GetDefaultInstance(void);
133 static _SystemNetConnection* GetWifiInstance(void);
134 static _SystemNetConnection* GetWifiDirectInstance(void);
135 static _SystemNetConnection* GetUsbInstance(void);
137 // static result ConvertError(int ret);
141 * This is the default constructor for this class.
143 _SystemNetConnection(void);
146 * This is the destructor for this class.
148 virtual ~_SystemNetConnection(void);
150 result Initialize(const Tizen::Base::String& name);
151 void Deinitialize(void);
154 static void InitializeNetworkFrameworkOnce(void);
157 * This is the copy constructor for this class.
159 * @param[in] rhs An instance of _SystemNetConnection
161 _SystemNetConnection(const _SystemNetConnection& rhs);
164 * This is the assignment operator. Do @b not use directly.
166 * @param[in] rhs An instance of _SystemNetConnection
168 _SystemNetConnection& operator =(const _SystemNetConnection& rhs);
171 NetBearerType _bearerType;
172 NetConnectionState _connectionState;
173 Tizen::Base::String _name;
174 std::unique_ptr<_NetConnectionInfoImpl> _pConnectionInfo;
175 std::unique_ptr<Tizen::Base::Collection::ArrayList> _pEventList; // Don't use collector deleter because this list doesn't take entries ownership.
176 std::unique_ptr<Tizen::Base::Runtime::Mutex> _pLock;
180 static bool __isInitialized;
181 static Tizen::Base::Collection::HashMap* __pPsSystemConnectionMap;
182 static _DefaultSystemNetConnection* __pDefaultConnection;
183 static _WifiSystemNetConnection* __pWifiConnection;
184 static _WifiDirectSystemNetConnection* __pWifiDirectConnection;
185 static _UsbSystemNetConnection* __pUsbConnection;
187 }; // _SystemNetConnection
190 #endif // _FNET_INTERNAL_SYSTEM_NET_CONNECTION_H_