2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://floralicense.org/license/
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.
19 * @file FNetHttp_HttpSessionImpl.h
20 * @brief This is the header file for the %_HttpSessionImpl class.
22 * This header file contains the declarations of the %_HttpSessionImpl class.
25 #ifndef _FNET_HTTP_INTERNAL_HTTP_SESSION_IMPL_H_
26 #define _FNET_HTTP_INTERNAL_HTTP_SESSION_IMPL_H_
30 #include <FOspConfig.h>
31 #include <FNetHttpHttpTypes.h>
33 namespace Tizen { namespace Base
38 namespace Tizen { namespace Net
40 class ManagedNetConnection;
42 class _NetConnectionImpl;
45 namespace Tizen { namespace Net { namespace Http
48 class HttpTransaction;
50 class HttpAuthentication;
51 class HttpCookieStorageManager;
52 class _HttpNetConnectionEventListenerImpl;
53 class _HttpManagedNetConnectionEventListenerImpl;
54 class _HttpHeaderImpl;
55 class _HttpMultipleConnectionInfo;
57 * @class _HttpSessionImpl
58 * @brief This class represents an HTTP session.
63 class _OSP_EXPORT_ _HttpSessionImpl
64 : public Tizen::Base::Object
69 * This is the default constructor for this class.
72 * @remarks After creating an instance of this class, one of the Construct() methods must be called explicitly to initialize the instance.
75 _HttpSessionImpl(HttpSession* pHttpSession);
78 * @see HttpSession::Construct()
80 result Construct(NetHttpSessionMode sessionMode, const Tizen::Base::String* pProxyAddr, const Tizen::Base::String& hostAddr, const HttpHeader* pCommonHeader, NetHttpCookieFlag flag = NET_HTTP_COOKIE_FLAG_ALWAYS_MANUAL);
83 * @see HttpSession::Construct()
85 result Construct(const NetConnection& netConnection, NetHttpSessionMode sessionMode, const Tizen::Base::String* pProxyAddr, const Tizen::Base::String& hostAddr, const HttpHeader* pCommonHeader, NetHttpCookieFlag flag = NET_HTTP_COOKIE_FLAG_ALWAYS_MANUAL);
88 * This is the destructor for this class.
92 virtual ~_HttpSessionImpl(void);
95 * @see HttpSession::OpenTransactionN()
97 HttpTransaction* OpenTransactionN(void);
100 * @see HttpSession::OpenTransactionN()
102 HttpTransaction* OpenTransactionN(const HttpAuthentication& auth);
105 * @see HttpSession::CancelTransaction()
107 result CancelTransaction(HttpTransaction& httpTransaction);
110 * @see HttpSession::CloseTransaction()
112 result CloseTransaction(HttpTransaction& httpTransaction);
115 * @see HttpSession::CloseAllTransactions()
117 result CloseAllTransactions(void);
120 * @see HttpSession::SetAutoRedirectionEnabled()
122 result SetAutoRedirectionEnabled(bool enable);
125 * @see HttpSession::IsAutoRedirectionEnabled()
127 bool IsAutoRedirectionEnabled(void) const;
130 * @see HttpSession::GetActiveTransactionCount()
132 int GetActiveTransactionCount(void) const;
135 * @see HttpSession::GetMaxTransactionCount()
137 int GetMaxTransactionCount(void) const;
140 * @see HttpSession::GetCookieStorageManager()
142 HttpCookieStorageManager* GetCookieStorageManager(void) const;
146 * Gets the Impl instance.
149 * @return The pointer to _HttpSessionImpl
150 * @param[in] pHttpSession An instance of HttpSession
152 static _HttpSessionImpl* GetInstance(HttpSession& httpSession);
155 * Gets the Impl instance.
158 * @return The pointer to _HttpSessionImpl
159 * @param[in] pHttpSession An instance of HttpSession
161 static const _HttpSessionImpl* GetInstance(const HttpSession& httpSession);
164 NetHttpSessionMode GetSessionMode(void) const;
166 Tizen::Base::String GetHostAddress(void) const;
168 Tizen::Base::String* GetProxyAddress(void) const;
170 void SetProxyAddress(Tizen::Base::String* pProxyAddress);
172 Tizen::Base::String GetDeviceName(void) const;
174 void SetDeviceName(const Tizen::Base::String& deviceName);
176 bool IsSessionValid(void) const;
178 void SetSessionState(bool isValid);
180 NetHttpCookieFlag GetHttpCookieFlag(void) const;
182 HttpSession* GetHttpSession(void) const;
184 _HttpMultipleConnectionInfo* GetHttpMultipleConnectionInfo(void) const;
186 Tizen::Base::Collection::ArrayList* GetActiveTransactions(void);
188 bool IsConnectionStarted(void) const;
190 HttpTransaction* OpenTransactionWithCurlN(CURL* pCurl, bool uncheckedMaxTransactions = false);
192 HttpTransaction* ReopenTransactionWithAuthN(HttpTransaction& httpTransaction);
194 result Disconnect(void); // HttpSession is disconnected when network problem is occurred.
196 void IgnoreSslVerification(void);
198 result Dispose(void);
202 static int GenerateSessionId(void);
204 int GetSessionId(void) const;
206 static result InitializeSession(void);
209 _HttpSessionImpl(const _HttpSessionImpl& rhs);
211 _HttpSessionImpl& operator =(const _HttpSessionImpl& rhs);
214 static int __generatedSessionId;
216 static int __countOfSessions; //The number of opened sessions in the application.
218 HttpSession* __pHttpSession;
219 bool __isConstructed;
220 NetHttpSessionMode __sessionMode;
221 Tizen::Base::String* __pProxyAddress;
222 Tizen::Base::String __hostAddress;
223 HttpHeader* __pCommonHeader;
224 NetHttpCookieFlag __cookieFlag;
225 Tizen::Base::Collection::ArrayList __activeTransactions;
226 int __countOfTransaction;
230 bool __isAutoRedirectionEnabled;
231 bool __isAlreadyResumed;
232 class _HttpMultipleConnectionInfo* __pHttpMultipleConnectionInfo;
233 HttpCookieStorageManager* __pCookieStorageMgr;
234 Tizen::Net::NetConnection* __pNetConnection;
235 _HttpNetConnectionEventListenerImpl* __pNetConnectionListener;
236 Tizen::Net::ManagedNetConnection* __pManagedNetConnection;
237 _HttpManagedNetConnectionEventListenerImpl* __pManagedNetConnectionListener;
238 Tizen::Base::String __deviceName;
240 friend class HttpSession;
242 }; // _HttpSessionImpl
244 } } } // Tizen::Net::Http
245 #endif // _FNET_HTTP_INTERNAL_HTTP_SESSION_IMPL_H_