62e6caddac718fef54df62e61a39f9fdeb43f310
[platform/core/system/swap-probe.git] / probe_tizenapi / tizen_http.cpp
1 /*
2  *  DA probe
3  *
4  * Copyright (File::*c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:
7  *
8  * Hyunjong Park      <phjwithyou.park@samsung.com>
9  * Juyoung Kim        <j0.kim@samsung.com>
10  * Vitaliy Cherepanov <v.cherepanov@samsung.com>
11  *
12  * This library is free software; you can redistribute it and/or modify it under
13  * the terms of the GNU Lesser General Public License as published by the
14  * Free Software Foundation; either version 2.1 of the License, or (at your option)
15  * any later version.
16  *
17  * This library is distributed in the hope that it will be useful, but WITHOUT ANY
18  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
19  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
20  * License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * along with this library; if not, write to the Free Software Foundation, Inc., 51
24  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25  *
26  * Contributors:
27  * - S-Core Co., Ltd
28  * - Samsung RnD Institute Russia
29  *
30  */
31
32 #include <FBase.h>
33 #include <FBaseObject.h>
34 #include <FBaseResult.h>
35
36 /*#include <sys/socket.h>
37 #include <sys/types.h>
38 #include <netinet/in.h>
39 #include <netdb.h>
40 #include <arpa/inet.h>*/
41
42 #include <stdio.h>
43 #include <netdb.h>
44
45 #include "binproto.h"
46 #include "daprobe.h"
47 #include "probeinfo.h"
48 #include "dahelper.h"
49 #include "dacollection.h"
50 #include "tizen_probe.h"
51 #include "../probe_socket/da_socket.h"
52 static enum DaOptions _sopt = OPT_NETWORK;
53
54 namespace Tizen {
55 namespace Net {
56
57 enum NetBearerType {
58         NET_BEARER_PS = 1, /**< The bearer type for the PS domain */
59         NET_BEARER_CS, // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
60         NET_BEARER_WIFI, /**< The bearer type for Wi-Fi */
61         NET_BEARER_WIFI_DIRECT, /**< The bearer type for Wi-Fi Direct @n
62          *      This bearer type cannot be tested on the Emulator. */
63         NET_BEARER_USB, /**< The bearer type for USB NDIS mode @n
64          *      Can use this bearer type via USB Tethering mode. @n
65          *      This bearer type cannot be tested on the Emulator. */
66         NET_BEARER_MMS, /**< The bearer type for MMS */
67         NET_BEARER_NONE = 0 // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. Network Bearer Type not set
68 };
69
70 enum NetProtocolType {
71         NET_PROTO_TYPE_IPV4 = 1, /**< The IPV4 type */
72         NET_PROTO_TYPE_PPP, /**< The PPP type */
73         NET_PROTO_TYPE_IPV6, /**< The IPV6 type, currently NOT supported */
74         NET_PROTO_TYPE_NONE = 0 // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. Network Protocol type not set
75 };
76
77 enum NetAddressScheme {
78         NET_ADDRESS_SCHEME_DYNAMIC = 1, /**< The Dynamic IP or DNS Address */
79         NET_ADDRESS_SCHEME_STATIC, /**< The Static IP or DNS Address */
80         NET_ADDRESS_SCHEME_NONE = 0 // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. Network Address Scheme not set
81 };
82
83 enum NetAddressFamily {
84         NET_AF_IPV4 = 1, /**< The default @n An IPv4 address [RFC791] is represented in decimal format with dots as delimiters. */
85         NET_AF_IPV6, /**< An IPv6 address [RFC2373] is generally represented in hexadecimal numbers with colons as delimiters @n It can also be a combination of hexadecimal and decimal numbers with dots and colons as delimiters. */
86         NET_AF_ALPHANUMERIC, /**< A generic alphanumeric address (as defined by alphanum in [RFC2396]) */
87         NET_AF_APN, /**< A GPRS APN as defined in [GENFORM] */
88         NET_AF_NONE = 0 // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application. Network Address Family not set
89 };
90
91 enum NetConnectionState {
92         NET_CONNECTION_STATE_NONE, /**< The initial state */
93         NET_CONNECTION_STATE_STARTING, /**< The network connection is being established */
94         NET_CONNECTION_STATE_STARTED, /**< The network connection has been established */
95         NET_CONNECTION_STATE_STOPPING, /**< The network connection is being disconnected */
96         NET_CONNECTION_STATE_STOPPED, /**< The network connection has been disconnected */
97         NET_CONNECTION_STATE_SUSPENDED, /**< The network connection has been suspended */
98         NET_CONNECTION_STATE_SUSPEND = 5, // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
99         NET_CONNECTION_STATE_RESUMED, /**< The network connection is established, and recovered from SUSPEND state - enable to send/receive packet data */
100         NET_CONNECTION_STATE_AVAILABLE, // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
101         NET_CONNECTION_STATE_UNAVAILABLE, // This enum value is for internal use only. Using this enum value can cause behavioral, security-related, and consistency-related issues in the application.
102 };
103
104 class _IpAddressImpl;
105 class IpAddress {
106 public:
107         virtual ~IpAddress(void);
108         static unsigned short HostToNetworkOrder(unsigned short host);
109         static unsigned long HostToNetworkOrder(unsigned long host);
110         static unsigned short NetworkToHostOrder(unsigned short network);
111         static unsigned long NetworkToHostOrder(unsigned long network);
112         virtual NetAddressFamily GetNetAddressFamily(void) const = 0;
113         virtual result GetAddress(Tizen::Base::ByteBuffer& ipAddr) const = 0;
114         virtual Tizen::Base::String ToString(void) const = 0;
115         virtual IpAddress* CloneN(void) const = 0;
116 protected:
117         IpAddress(void);
118 protected:
119         virtual void IpAddress_Reserved1(void) {
120         }
121         virtual void IpAddress_Reserved2(void) {
122         }
123         virtual void IpAddress_Reserved3(void) {
124         }
125         virtual void IpAddress_Reserved4(void) {
126         }
127         virtual void IpAddress_Reserved5(void) {
128         }
129 private:
130         IpAddress(const IpAddress& rhs);
131         IpAddress& operator =(const IpAddress& rhs);
132 protected:
133         _IpAddressImpl* _pIpAddressImpl;
134         friend class _IpAddressImpl;
135 };
136 // IpAddress
137
138 class _NetConnectionInfoImpl;
139 class NetConnectionInfo {
140 public:
141         NetConnectionInfo(void);
142         virtual ~NetConnectionInfo(void);
143         NetBearerType GetBearerType(void) const;
144         NetProtocolType GetProtocolType(void) const;
145         Tizen::Base::String GetAccessPointName(void) const;
146         NetAddressScheme GetLocalAddressScheme(void) const;
147         const IpAddress* GetLocalAddress(void) const;
148         NetAddressScheme GetDnsAddressScheme(void) const;
149         const IpAddress* GetPrimaryDnsAddress(void) const;
150         const IpAddress* GetSecondaryDnsAddress(void) const;
151         const IpAddress* GetSubnetMaskAddress(void) const;
152         const IpAddress* GetDefaultGatewayAddress(void) const;
153         NetConnectionInfo(const NetConnectionInfo& rhs);
154         NetConnectionInfo& operator =(const NetConnectionInfo& rhs);
155         virtual bool Equals(const Tizen::Base::Object& rhs) const;
156         virtual int GetHashCode(void) const;
157 private:
158         _NetConnectionInfoImpl* __pNetConnectionInfoImpl;
159         friend class _NetConnectionInfoImpl;
160 };
161 // NetConnectionInfo
162 }
163 } //Tizen::Net
164
165 namespace Tizen {
166 namespace Net {
167 namespace Http {
168
169 typedef int NetAccountId;
170
171 enum HttpVersion {
172         HTTP_VERSION_1_0, /**< %Http version 1.0 */
173         HTTP_VERSION_1_1 /**< %Http version 1.1 */
174 };
175
176 enum NetHttpSessionMode {
177         NET_HTTP_SESSION_MODE_NORMAL, /**< The Normal Mode */
178         NET_HTTP_SESSION_MODE_PIPELINING, /**< The Pipelining mode */
179         NET_HTTP_SESSION_MODE_MULTIPLE_HOST /**< The Multiple host mode */
180 };
181
182 enum NetHttpCookieFlag {
183         NET_HTTP_COOKIE_FLAG_NONE, /**< The mode is not defined */
184         NET_HTTP_COOKIE_FLAG_ALWAYS_AUTOMATIC, /**< The cookie will be parsed and saved, and also attached to request automatically */
185         NET_HTTP_COOKIE_FLAG_ALWAYS_MANUAL /**< The cookie will be handled by the user action with Tizen::Net::Http::HttpRequest::SetCookie() and Tizen::Net::Http::HttpCookieStorageManager::GetCookies() */
186 };
187
188 enum NetHttpStatusCode {
189         NET_HTTP_STATUS_UNDEFINED = 0, /**< @if OSPDEPREC The undefined status @endif */
190         NET_HTTP_STATUS_CONTINUE = 100, /**< @if OSPDEPREC The status code: 100 Continue @endif */
191         NET_HTTP_STATUS_SWITCHING_PROTOCOLS = 101, /**< @if OSPDEPREC The status code: 101 Switching Protocols @endif */
192         NET_HTTP_STATUS_OK = 200, /**< @if OSPDEPREC The status code: 200 OK @endif */
193         NET_HTTP_STATUS_CREATED = 201, /**< @if OSPDEPREC The status code: 201 Created @endif */
194         NET_HTTP_STATUS_ACCEPTED = 202, /**< @if OSPDEPREC The status code: 202 Accepted @endif */
195         NET_HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION = 203, /**< @if OSPDEPREC The status code: 203 Non-Authoritative Information @endif */
196         NET_HTTP_STATUS_NO_CONTENT = 204, /**< @if OSPDEPREC The status code: 204 No %Content @endif */
197         NET_HTTP_STATUS_RESET_CONTENT = 205, /**< @if OSPDEPREC The status code: 205 Reset %Content @endif */
198         NET_HTTP_STATUS_PARTIAL_CONTENT = 206, /**< @if OSPDEPREC The status code: 206 Partial %Content @endif */
199
200         NET_HTTP_STATUS_MULTIPLE_CHOICE = 300, /**< @if OSPDEPREC The status code: 300 Multiple Choices @endif */
201         NET_HTTP_STATUS_MOVED_PERMANENTLY = 301, /**< @if OSPDEPREC The status code: 301 Moved Permanently @endif */
202         NET_HTTP_STATUS_MOVED_TEMPORARILY = 302, /**< @if OSPDEPREC The status code: 302 Found @endif */
203         NET_HTTP_STATUS_SEE_OTHER = 303, /**< @if OSPDEPREC The status code: 303 See Other @endif */
204         NET_HTTP_STATUS_NOT_MODIFIED = 304, /**< @if OSPDEPREC The status code: 304 Not Modified @endif */
205         NET_HTTP_STATUS_USE_PROXY = 305, /**< @if OSPDEPREC The status code: 305 Use Proxy @endif */
206
207         NET_HTTP_STATUS_BAD_REQUEST = 400, /**< @if OSPDEPREC The status code: 400 Bad Request @endif */
208         NET_HTTP_STATUS_UNAUTHORIZED = 401, /**< @if OSPDEPREC The status code: 401 Unauthorized @endif */
209         NET_HTTP_STATUS_PAYMENT_REQUIRED = 402, /**< @if OSPDEPREC The status code: 402 Payment Required @endif */
210         NET_HTTP_STATUS_FORBIDDEN = 403, /**< @if OSPDEPREC The status code: 403 Forbidden @endif */
211         NET_HTTP_STATUS_NOT_FOUND = 404, /**<@if OSPDEPREC  The status code: 404 Not Found @endif */
212         NET_HTTP_STATUS_METHOD_NOT_ALLOWED = 405, /**< @if OSPDEPREC The status code: 405 Method Not Allowed @endif */
213         NET_HTTP_STATUS_NOT_ACCEPTABLE = 406, /**< @if OSPDEPREC The status code: 406 Not Acceptable @endif */
214         NET_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED = 407, /**< @if OSPDEPREC The status code: 407 Proxy Authentication Required @endif */
215         NET_HTTP_STATUS_REQUEST_TIME_OUT = 408, /**< @if OSPDEPREC The status code: 408 Request Timeout (not used) @endif */
216         NET_HTTP_STATUS_CONFLICT = 409, /**<@if OSPDEPREC  The status code: 409 Conflict @endif */
217         NET_HTTP_STATUS_GONE = 410, /**< @if OSPDEPREC The status code: 410 Gone @endif */
218         NET_HTTP_STATUS_LENGTH_REQUIRED = 411, /**< @if OSPDEPREC The status code: 411 Length Required @endif */
219         NET_HTTP_STATUS_PRECONDITION_FAILED = 412, /**<@if OSPDEPREC  The status code: 412 Precondition Failed @endif */
220         NET_HTTP_STATUS_REQUEST_ENTITY_TOO_LARGE = 413, /**< @if OSPDEPREC The status code: 413 Request Entity Too Large (not used) @endif */
221         NET_HTTP_STATUS_REQUEST_URI_TOO_LARGE = 414, /**< @if OSPDEPREC The status code: 414 Request-URI Too Long (not used) @endif */
222         NET_HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE = 415, /**< @if OSPDEPREC The status code: 415 Unsupported %Media Type @endif */
223
224         NET_HTTP_STATUS_INTERNAL_SERVER_ERROR = 500, /**< @if OSPDEPREC The status code: 500 Internal Server Error @endif */
225         NET_HTTP_STATUS_NOT_IMPLEMENTED = 501, /**< @if OSPDEPREC The status code: 501 Not Implemented @endif */
226         NET_HTTP_STATUS_BAD_GATEWAY = 502, /**< @if OSPDEPREC The status code: 502 Bad Gateway @endif */
227         NET_HTTP_STATUS_SERVICE_UNAVAILABLE = 503, /**< @if OSPDEPREC The status code: 503 Service Unavailable @endif */
228         NET_HTTP_STATUS_GATEWAY_TIME_OUT = 504, /**< @if OSPDEPREC The status code: 504 Gateway Timeout @endif */
229         NET_HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED = 505 /**< @if OSPDEPREC The status code: 505 HTTP Version Not Supported @endif */
230 };
231
232 enum NetHttpMethod {
233         NET_HTTP_METHOD_GET = 0x40, /**< The HTTP GET Method */
234         NET_HTTP_METHOD_OPTIONS = 0x41, /**< The HTTP OPTIONS Method */
235         NET_HTTP_METHOD_HEAD = 0x42, /**< The HTTP HEAD Method */
236         NET_HTTP_METHOD_DELETE = 0x43, /**< The HTTP DELETE Method */
237         NET_HTTP_METHOD_TRACE = 0x44, /**< The HTTP TRACE Method */
238         NET_HTTP_METHOD_POST = 0x60, /**< The HTTP POST Method */
239         NET_HTTP_METHOD_PUT = 0x61, /**< The HTTP PUT Method */
240         NET_HTTP_METHOD_CONNECT = 0x70, /**< The HTTP CONNECT Method */
241 };
242
243 enum NetHttpCertificateVerificationFlag {
244         HTTP_CV_FLAG_AUTOMATIC, /**< The certificate is verified by the system @n If server certificate is invalid, the IHttpTransactionEventListener::OnTransactionCertVerificationRequiredN() listener is received.  */
245         HTTP_CV_FLAG_MANUAL, /**< The certificate verification is handled by user action when the IHttpTransactionEventListener::OnTransactionCertVerificationRequestedN() listener is received */
246         HTTP_CV_FLAG_IGNORED, /**< The certificate verification is ignored */
247 };
248
249 enum NetHttpAuthScheme {
250         NET_HTTP_AUTH_NONE = 0, /**< The no authentication type */
251         NET_HTTP_AUTH_PROXY_BASIC = 1, /**< The authentication type is Proxy Basic Authentication */
252         NET_HTTP_AUTH_PROXY_MD5 = 2, /**< The authentication type is Proxy Digest Authentication */
253         NET_HTTP_AUTH_WWW_BASIC = 3, /**< The authentication Type is HTTP Basic Authentication */
254         NET_HTTP_AUTH_WWW_MD5 = 4, /**< The authentication type is HTTP Digest Authentication */
255         NET_HTTP_AUTH_PROXY_NTLM = 5, /**< The authentication type is Proxy NTLM Authentication */
256         NET_HTTP_AUTH_WWW_NTLM = 7, /**< The authentication type is NTLM Authentication */
257         NET_HTTP_AUTH_WWW_NEGOTIATE = 8 /**< The authentication type is Negotiate Authentication */
258 };
259
260 class _HttpHeaderImpl;
261 class HttpHeader {
262 public:
263         HttpHeader(void);
264         HttpHeader(const HttpHeader* pHeader);
265         virtual ~HttpHeader(void);
266 public:
267         result AddField(const Tizen::Base::String& fieldName,
268                         const Tizen::Base::String& fieldValue);
269         result RemoveField(const Tizen::Base::String& fieldName);
270         result RemoveField(const Tizen::Base::String& fieldName,
271                         const Tizen::Base::String& fieldValue);
272         void RemoveAll(void);
273         Tizen::Base::String* GetRawHeaderN(void) const;
274         Tizen::Base::Collection::IList* GetFieldNamesN(void) const;
275         Tizen::Base::Collection::IEnumerator* GetFieldValuesN(
276                         const Tizen::Base::String& fieldName) const;
277 private:
278         HttpHeader(const HttpHeader& rhs);
279         HttpHeader& operator =(const HttpHeader& rhs);
280 private:
281         friend class _HttpHeaderImpl;
282         _HttpHeaderImpl* __pHttpHeaderImpl;
283 };
284
285 Tizen::Base::String* HttpHeader::GetRawHeaderN(void) const
286 {
287         typedef Tizen::Base::String* (HttpHeader::*methodType)(void) const;
288         static methodType GetRawHeaderNp;
289         Tizen::Base::String* retVal;
290
291         BEFORE_ORIGINAL_TIZEN_NET( _ZNK5Tizen3Net4Http10HttpHeader13GetRawHeaderNEv,
292                         GetRawHeaderNp);
293
294         retVal = (this->*GetRawHeaderNp)();
295
296         char *out = NULL;
297         int bufferSize = 0;
298         if (retVal == NULL) {
299                 newerrno = 1;
300         } else {
301                 bufferSize = retVal->GetLength();
302                 out = new char[bufferSize + sizeof(char)];
303                 WcharToChar(out, retVal->GetPointer());
304         }
305
306         info.msg_buf = out;
307         info.msg_pack_size = bufferSize > SOCKET_SEND_SIZE ? SOCKET_SEND_SIZE : bufferSize;
308         info.msg_total_size = bufferSize;
309
310         AFTER_ORIGINAL_TIZEN_SOCK("HttpHeader::GetRawHeaderN", VT_NULL, NULL,
311                                   (unsigned int)this, (unsigned int)this,
312                                   HTTP_API_RESPONSE, info, "s", "void");
313
314         if (out)
315                 delete [] out;
316
317         return retVal;
318 }
319
320 // HttpHeader
321
322 class HttpTransaction;
323 class NetConnection;
324 class HttpAuthentication;
325 class HttpCookieStorageManager;
326
327 class _HttpSessionImpl;
328 class HttpSession {
329 public:
330         HttpSession(void);
331         result Construct(NetHttpSessionMode sessionMode,
332                         const Tizen::Base::String* pProxyAddr,
333                         const Tizen::Base::String& hostAddr,
334                         const HttpHeader* pCommonHeader, NetHttpCookieFlag flag =
335                                         NET_HTTP_COOKIE_FLAG_ALWAYS_MANUAL);
336         result Construct(const NetConnection& netConnection,
337                         NetHttpSessionMode sessionMode,
338                         const Tizen::Base::String* pProxyAddr,
339                         const Tizen::Base::String& hostAddr,
340                         const HttpHeader* pCommonHeader, NetHttpCookieFlag flag =
341                                         NET_HTTP_COOKIE_FLAG_ALWAYS_MANUAL);
342         ~HttpSession(void);
343 public:
344         HttpTransaction* OpenTransactionN(void);
345         HttpTransaction* OpenTransactionN(const HttpAuthentication& auth);
346         result CancelTransaction(HttpTransaction& httpTransaction);
347         result CloseTransaction(HttpTransaction& httpTransaction);
348         result CloseAllTransactions(void);
349         result SetAutoRedirectionEnabled(bool enable);
350         bool IsAutoRedirectionEnabled(void) const;
351         int GetActiveTransactionCount(void) const;
352         int GetMaxTransactionCount(void) const;
353         HttpCookieStorageManager* GetCookieStorageManager(void) const;
354 private:
355         HttpSession(const HttpSession& rhs);
356         HttpSession& operator =(const HttpSession& rhs);
357 private:
358         friend class _HttpSessionImpl;
359         _HttpSessionImpl* __pHttpSessionImpl;
360 };
361 // HttpSession
362
363 result HttpSession::Construct(NetHttpSessionMode sessionMode,
364                 const Tizen::Base::String* pProxyAddr,
365                 const Tizen::Base::String& hostAddr, const HttpHeader* pCommonHeader,
366                 NetHttpCookieFlag flag) {
367         typedef result (HttpSession::*methodType)(NetHttpSessionMode sessionMode,
368                         const Tizen::Base::String* pProxyAddr,
369                         const Tizen::Base::String& hostAddr,
370                         const HttpHeader* pCommonHeader, NetHttpCookieFlag flag);
371         static methodType Constructp;
372         result retVal;
373
374         BEFORE_ORIGINAL_TIZEN_NET(
375                         _ZN5Tizen3Net4Http11HttpSession9ConstructENS1_18NetHttpSessionModeEPKNS_4Base6StringERS6_PKNS1_10HttpHeaderENS1_17NetHttpCookieFlagE,
376                         Constructp);
377
378         retVal = (this->*Constructp)(sessionMode, pProxyAddr, hostAddr,
379                         pCommonHeader, flag);
380
381         char temp1[50];
382         if (NULL != pProxyAddr) {
383                 WcharToChar(temp1, pProxyAddr->GetPointer());
384         } else {
385                 strcpy(temp1, "NULL");
386         }
387         char temp2[50];
388         WcharToChar(temp2, hostAddr.GetPointer());
389
390         AFTER_ORIGINAL_TIZEN_SOCK("HttpSession::Construct", VT_ULONG, retVal,
391                                   (unsigned int)this, (unsigned int)this,
392                                   HTTP_API_SESSION_CONSTRUCT,
393                                   info, "dssxd",
394                                   sessionMode, temp1, temp2,
395                                   voidp_to_uint64(&pCommonHeader), flag);
396         return retVal;
397 }
398
399 result HttpSession::Construct(const NetConnection& netConnection,
400                 NetHttpSessionMode sessionMode, const Tizen::Base::String* pProxyAddr,
401                 const Tizen::Base::String& hostAddr, const HttpHeader* pCommonHeader,
402                 NetHttpCookieFlag flag)
403 {
404         typedef result (HttpSession::*methodType)(
405                         const NetConnection& netConnection, NetHttpSessionMode sessionMode,
406                         const Tizen::Base::String* pProxyAddr,
407                         const Tizen::Base::String& hostAddr,
408                         const HttpHeader* pCommonHeader, NetHttpCookieFlag flag);
409         static methodType Constructp;
410         result retVal;
411
412         BEFORE_ORIGINAL_TIZEN_NET(
413                         _ZN5Tizen3Net4Http11HttpSession9ConstructERKNS0_13NetConnectionENS1_18NetHttpSessionModeEPKNS_4Base6StringERS9_PKNS1_10HttpHeaderENS1_17NetHttpCookieFlagE,
414                         Constructp);
415
416         retVal = (this->*Constructp)(netConnection, sessionMode, pProxyAddr,
417                         hostAddr, pCommonHeader, flag);
418
419         char temp1[50];
420         if (NULL != pProxyAddr) {
421                 WcharToChar(temp1, pProxyAddr->GetPointer());
422         } else {
423                 strcpy(temp1, "NULL");
424         }
425         char temp2[50];
426         WcharToChar(temp2, hostAddr.GetPointer());
427
428         AFTER_ORIGINAL_TIZEN_SOCK("HttpSession::Construct", VT_ULONG, retVal,
429                                   (unsigned int)this, (unsigned int)this,
430                                   HTTP_API_SESSION_CONSTRUCT,
431                                   info, "xdssxd",
432                                   voidp_to_uint64(&netConnection), sessionMode,
433                                   temp1, temp2,
434                                   voidp_to_uint64(&pCommonHeader), flag);
435         return retVal;
436 }
437
438 HttpTransaction* HttpSession::OpenTransactionN(void)
439 {
440         typedef HttpTransaction* (HttpSession::*methodType)(void);
441         static methodType OpenTransactionNp;
442
443         HttpTransaction* retVal;
444
445         BEFORE_ORIGINAL_TIZEN_NET(
446                         _ZN5Tizen3Net4Http11HttpSession16OpenTransactionNEv,
447                         OpenTransactionNp);
448
449         retVal = (this->*OpenTransactionNp)();
450         if (retVal == NULL)
451                 newerrno = 1;
452         AFTER_ORIGINAL_TIZEN_SOCK("HttpSession::OpenTransactionN", VT_PTR, retVal,
453                         (unsigned int)this, (unsigned int)this, HTTP_API_TRANSACTION_OPEN,
454                         info, "s", "void");
455         return retVal;
456 }
457
458 HttpTransaction* HttpSession::OpenTransactionN(const HttpAuthentication& auth)
459 {
460         typedef HttpTransaction* (HttpSession::*methodType)(
461                         const HttpAuthentication& auth);
462         static methodType OpenTransactionNp;
463
464         HttpTransaction* retVal;
465
466         BEFORE_ORIGINAL_TIZEN_NET(
467                         _ZN5Tizen3Net4Http11HttpSession16OpenTransactionNERKNS1_18HttpAuthenticationE,
468                         OpenTransactionNp);
469
470         retVal = (this->*OpenTransactionNp)(auth);
471
472         if (retVal == NULL)
473                 newerrno = 1;
474         AFTER_ORIGINAL_TIZEN_SOCK("HttpSession::OpenTransactionN", VT_PTR, retVal,
475                                   (unsigned int)this, (unsigned int)this,
476                                   HTTP_API_TRANSACTION_OPEN,
477                                   info, "x", voidp_to_uint64(&auth));
478         return retVal;
479
480 }
481
482 result HttpSession::CancelTransaction(HttpTransaction& httpTransaction)
483 {
484         typedef result (HttpSession::*methodType)(HttpTransaction& httpTransaction);
485         static methodType CancelTransactionp;
486
487         result retVal;
488
489         BEFORE_ORIGINAL_TIZEN_NET(
490                         _ZN5Tizen3Net4Http11HttpSession17CancelTransactionERNS1_15HttpTransactionE,
491                         CancelTransactionp);
492
493         retVal = (this->*CancelTransactionp)(httpTransaction);
494
495         AFTER_ORIGINAL_TIZEN_SOCK("HttpSession::CancelTransaction", VT_ULONG,
496                                   retVal, (unsigned int)this,
497                                   (unsigned int)this,
498                                   HTTP_API_TRANSACTION_CLOSE, info, "x",
499                                   voidp_to_uint64(&httpTransaction));
500
501         return retVal;
502 }
503
504 result HttpSession::CloseTransaction(HttpTransaction& httpTransaction)
505 {
506         typedef result (HttpSession::*methodType)(HttpTransaction& httpTransaction);
507         static methodType CloseTransactionp;
508
509         result retVal;
510
511         BEFORE_ORIGINAL_TIZEN_NET(
512                         _ZN5Tizen3Net4Http11HttpSession16CloseTransactionERNS1_15HttpTransactionE,
513                         CloseTransactionp);
514
515         retVal = (this->*CloseTransactionp)(httpTransaction);
516
517         AFTER_ORIGINAL_TIZEN_SOCK("HttpSession::CloseTransaction", VT_ULONG, retVal,
518                                   (unsigned int)this, (unsigned int)this,
519                                   HTTP_API_TRANSACTION_CLOSE,
520                                   info, "x", voidp_to_uint64(&httpTransaction));
521
522         return retVal;
523 }
524
525 result HttpSession::CloseAllTransactions(void)
526 {
527         typedef result (HttpSession::*methodType)(void);
528         static methodType CloseTransactionp;
529
530         result retVal;
531
532         BEFORE_ORIGINAL_TIZEN_NET(
533                         _ZN5Tizen3Net4Http11HttpSession20CloseAllTransactionsEv,
534                         CloseTransactionp);
535
536         retVal = (this->*CloseTransactionp)();
537
538         AFTER_ORIGINAL_TIZEN_SOCK("HttpSession::CloseAllTransactions", VT_ULONG,
539                         retVal, (unsigned int)this, (unsigned int)this,
540                         HTTP_API_TRANSACTION_CLOSE, info, "s", "void");
541
542         return retVal;
543 }
544
545 result HttpSession::SetAutoRedirectionEnabled(bool enable)
546 {
547         typedef result (HttpSession::*methodType)(bool enable);
548         static methodType SetAutoRedirectionEnabledp;
549         result retVal;
550
551         BEFORE_ORIGINAL_TIZEN_NET(
552                         _ZN5Tizen3Net4Http11HttpSession25SetAutoRedirectionEnabledEb,
553                         SetAutoRedirectionEnabledp);
554
555         retVal = (this->*SetAutoRedirectionEnabledp)(enable);
556
557         AFTER_ORIGINAL_TIZEN_SOCK("HttpSession::SetAutoRedirectionEnabled",
558                         VT_ULONG, retVal, (unsigned int)this, (unsigned int)this,
559                         HTTP_API_OTHER, info, "d", enable);
560         return retVal;
561 }
562
563 bool HttpSession::IsAutoRedirectionEnabled(void) const
564 {
565         typedef bool (HttpSession::*methodType)(void) const;
566         static methodType IsAutoRedirectionEnabledp;
567         bool retVal;
568
569         BEFORE_ORIGINAL_TIZEN_NET(
570                         _ZNK5Tizen3Net4Http11HttpSession24IsAutoRedirectionEnabledEv,
571                         IsAutoRedirectionEnabledp);
572
573         retVal = (this->*IsAutoRedirectionEnabledp)();
574
575         AFTER_ORIGINAL_TIZEN_SOCK("HttpSession::IsAutoRedirectionEnabled", VT_INT,
576                                   retVal, (unsigned int)this, (unsigned int)this,
577                                   HTTP_API_OTHER, info, "s", "void");
578         return retVal;
579 }
580
581 int HttpSession::GetActiveTransactionCount(void) const
582 {
583         typedef int (HttpSession::*methodType)(void) const;
584         static methodType GetActiveTransactionCountp;
585         int retVal;
586
587         BEFORE_ORIGINAL_TIZEN_NET(
588                         _ZNK5Tizen3Net4Http11HttpSession25GetActiveTransactionCountEv,
589                         GetActiveTransactionCountp);
590
591         retVal = (this->*GetActiveTransactionCountp)();
592
593         AFTER_ORIGINAL_TIZEN_SOCK("HttpSession::GetActiveTransactionCount", VT_INT,
594                                   retVal, (unsigned int)this, (unsigned int)this,
595                                   HTTP_API_OTHER, info, "s", "void");
596         return retVal;
597 }
598
599 int HttpSession::GetMaxTransactionCount(void) const
600 {
601         typedef int (HttpSession::*methodType)(void) const;
602         static methodType GetMaxTransactionCountp;
603         int retVal;
604
605         BEFORE_ORIGINAL_TIZEN_NET(
606                         _ZNK5Tizen3Net4Http11HttpSession22GetMaxTransactionCountEv,
607                         GetMaxTransactionCountp);
608
609         retVal = (this->*GetMaxTransactionCountp)();
610
611         AFTER_ORIGINAL_TIZEN_SOCK("HttpSession::GetMaxTransactionCount", VT_INT,
612                                   retVal, (unsigned int)this, (unsigned int)this,
613                                   HTTP_API_OTHER, info, "s", "void");
614         return retVal;
615 }
616
617 HttpCookieStorageManager* HttpSession::GetCookieStorageManager(void) const
618 {
619         typedef HttpCookieStorageManager* (HttpSession::*methodType)(void) const;
620         static methodType GetMaxTransactionCountp;
621         HttpCookieStorageManager* retVal;
622
623         BEFORE_ORIGINAL_TIZEN_NET(
624                         _ZNK5Tizen3Net4Http11HttpSession23GetCookieStorageManagerEv,
625                         GetMaxTransactionCountp);
626
627         retVal = (this->*GetMaxTransactionCountp)();
628         if (retVal == NULL)
629                 newerrno = 1;
630         AFTER_ORIGINAL_TIZEN_SOCK("HttpSession::GetCookieStorageManager", VT_PTR,
631                         retVal, (unsigned int)this, (unsigned int)this, HTTP_API_ALLOCATION,
632                         info, "s", "void");
633         return retVal;
634 }
635
636 HttpSession::~HttpSession(void)
637 {
638         typedef void (HttpSession::*methodType)(void);
639         static methodType HttpSessionDp = 0;
640
641         probeInfo_t probeInfo;
642         log_t log;
643         int blockresult = 0;
644         bool bfiltering = false;
645         if (!HttpSessionDp) {
646                 if (lib_handle[LIBOSP_NET] == NULL) {
647                         lib_handle[LIBOSP_NET] = dlopen(lib_string[LIBOSP_NET], RTLD_LAZY);
648                         if (lib_handle[LIBOSP_NET] == NULL) {
649                                 char perror_msg[128];
650                                 sprintf(perror_msg, "dlopen failed : %s",
651                                                 lib_string[LIBOSP_NET]);
652                                 perror(perror_msg);
653                                 exit(0);
654                         }
655                 }
656                 void* funcp = dlsym(lib_handle[LIBOSP_NET],
657                                 "_ZN5Tizen3Net4Http11HttpSessionD1Ev");
658                 if (funcp == NULL || dlerror() != NULL) {
659                         perror("dlsym failed : " "_ZN5Tizen3Net4Http11HttpSessionD1Ev");
660                         exit(0);
661                 }
662                 memcpy(&HttpSessionDp, &funcp, sizeof(void*));
663         }
664
665         if ((blockresult =
666                         preBlockBegin(
667                                         ((void*) __builtin_extract_return_addr(
668                                                         __builtin_return_address(0))), bfiltering, _sopt))
669                         != 0) {
670                 setProbePoint(&probeInfo);
671                 preBlockEnd();
672         }
673
674         (this->*HttpSessionDp)();
675
676         if (postBlockBegin(blockresult)) {
677                 log.type = 0;
678                 log.length = 0;
679                 log.data[0] = '\0';
680                 log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", 15,
681                                 probeInfo.eventIndex, "HttpSession::~HttpSession",
682                                 probeInfo.currentTime, probeInfo.pID, probeInfo.tID);
683                 log.length += sprintf(log.data + log.length, "`,`,");
684                 log.length += sprintf(log.data + log.length,
685                                 "`,0`,0`,2`,%u`,0x%x`,0x%x`,2`,%d`,`,",
686                                 (unsigned int) CALLER_ADDRESS, (unsigned int) this,
687                                 (unsigned int) this, HTTP_API_TRANSACTION_CLOSE);
688                 log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
689                 getBacktraceString(&log, 4096 - log.length - 17);
690                 log.length += sprintf(log.data + log.length, "`,callstack_end");
691
692                 printLog(&log, MSG_LOG);
693                 postBlockEnd();
694         }
695 }
696
697 //HttpSession;
698
699 class HttpRequest;
700 class HttpResponse;
701 class IHttpTransactionEventListener;
702 class IHttpProgressEventListener;
703
704 class _HttpTransactionImpl;
705 class HttpTransaction {
706 public:
707         ~HttpTransaction(void);
708 public:
709
710         HttpAuthentication* OpenAuthenticationInfoN(void);
711         HttpRequest* GetRequest(void) const;
712         HttpResponse* GetResponse(void) const;
713         result AddHttpTransactionListener(IHttpTransactionEventListener& listener);
714         result RemoveHttpTransactionListener(
715                         IHttpTransactionEventListener& listener);
716         result SetHttpProgressListener(IHttpProgressEventListener& listener);
717         result SetUserObject(const Tizen::Base::Object* pUserData);
718         Tizen::Base::Object* GetUserObject(void) const;
719         bool EnableTransactionReadyToWrite(void);
720         result Submit(void);
721         result Resume(void);
722         result Pause(void);
723         result SetClientCertificate(int certificateId);
724         result SetTimeout(int timeout);
725         result SetServerCertificateVerification(
726                         NetHttpCertificateVerificationFlag flag = HTTP_CV_FLAG_AUTOMATIC);
727 private:
728         HttpTransaction(void);
729         HttpTransaction(const HttpTransaction& rhs);
730         HttpTransaction& operator =(const HttpTransaction& rhs);
731 private:
732         friend class _HttpTransactionImpl;
733         _HttpTransactionImpl* __pHttpTransactionImpl;
734 };
735
736 HttpAuthentication* HttpTransaction::OpenAuthenticationInfoN(void)
737 {
738         typedef HttpAuthentication* (HttpTransaction::*methodType)(void) const;
739         static methodType GetRequestp;
740         HttpAuthentication* retVal;
741
742         BEFORE_ORIGINAL_TIZEN_NET(
743                         _ZNK5Tizen3Net4Http15HttpTransaction10GetRequestEv, GetRequestp);
744
745         retVal = (this->*GetRequestp)();
746         if (retVal == NULL)
747                 newerrno = 1;
748         AFTER_ORIGINAL_TIZEN_SOCK("HttpTransaction::OpenAuthenticationInfoN",
749                         VT_PTR, retVal, (unsigned int)this, (unsigned int)this,
750                         HTTP_API_ALLOCATION, info, "s", "void");
751         return retVal;
752 }
753
754 HttpRequest* HttpTransaction::GetRequest(void) const
755 {
756         typedef HttpRequest* (HttpTransaction::*methodType)(void) const;
757         static methodType GetRequestp;
758         HttpRequest* retVal;
759
760         BEFORE_ORIGINAL_TIZEN_NET(
761                         _ZNK5Tizen3Net4Http15HttpTransaction10GetRequestEv, GetRequestp);
762
763         retVal = (this->*GetRequestp)();
764         if (retVal == NULL)
765                 newerrno = 1;
766         AFTER_ORIGINAL_TIZEN_SOCK("HttpTransaction::GetRequest", VT_PTR, retVal,
767                                   (unsigned int)this, (unsigned int)this,
768                                   HTTP_API_ALLOCATION, info, "s", "void");
769         return retVal;
770 }
771
772 HttpResponse* HttpTransaction::GetResponse(void) const
773 {
774         typedef HttpResponse* (HttpTransaction::*methodType)(void) const;
775         static methodType GetResponsep;
776         HttpResponse* retVal;
777
778         BEFORE_ORIGINAL_TIZEN_NET(
779                         _ZNK5Tizen3Net4Http15HttpTransaction11GetResponseEv, GetResponsep);
780
781         retVal = (this->*GetResponsep)();
782         if (retVal == NULL)
783                 newerrno = 1;
784         AFTER_ORIGINAL_TIZEN_SOCK("HttpTransaction::GetResponse", VT_PTR, retVal,
785                                   (unsigned int)this, (unsigned int)this,
786                                   HTTP_API_ALLOCATION, info, "s", "void");
787         return retVal;
788 }
789
790 result HttpTransaction::AddHttpTransactionListener(
791                 IHttpTransactionEventListener& listener) {
792         typedef result (HttpTransaction::*methodType)(
793                         IHttpTransactionEventListener& listener);
794         static methodType AddHttpTransactionListenerp;
795         result retVal;
796
797         BEFORE_ORIGINAL_TIZEN_NET(
798                         _ZN5Tizen3Net4Http15HttpTransaction26AddHttpTransactionListenerERNS1_29IHttpTransactionEventListenerE,
799                         AddHttpTransactionListenerp);
800
801         retVal = (this->*AddHttpTransactionListenerp)(listener);
802
803         AFTER_ORIGINAL_TIZEN_SOCK("HttpTransaction::AddHttpTransactionListener",
804                                   VT_ULONG, retVal, (unsigned int)this,
805                                   (unsigned int)this,
806                                   HTTP_API_OTHER, info,
807                                   "x", voidp_to_uint64(&listener));
808         return retVal;
809 }
810
811 result HttpTransaction::RemoveHttpTransactionListener(
812                 IHttpTransactionEventListener& listener) {
813         typedef result (HttpTransaction::*methodType)(
814                         IHttpTransactionEventListener& listener);
815         static methodType RemoveHttpTransactionListenerp;
816         result retVal;
817
818         BEFORE_ORIGINAL_TIZEN_NET(
819                         _ZN5Tizen3Net4Http15HttpTransaction29RemoveHttpTransactionListenerERNS1_29IHttpTransactionEventListenerE,
820                         RemoveHttpTransactionListenerp);
821
822         retVal = (this->*RemoveHttpTransactionListenerp)(listener);
823
824         AFTER_ORIGINAL_TIZEN_SOCK("HttpTransaction::RemoveHttpTransactionListener",
825                                   VT_ULONG, retVal, (unsigned int)this,
826                                   (unsigned int)this,
827                                   HTTP_API_OTHER, info, "x",
828                                   voidp_to_uint64(&listener));
829         return retVal;
830 }
831
832 result HttpTransaction::SetHttpProgressListener(
833                 IHttpProgressEventListener& listener) {
834         typedef result (HttpTransaction::*methodType)(
835                         IHttpProgressEventListener& listener);
836         static methodType SetHttpProgressListenerp;
837         result retVal;
838
839         BEFORE_ORIGINAL_TIZEN_NET(
840                         _ZN5Tizen3Net4Http15HttpTransaction23SetHttpProgressListenerERNS1_26IHttpProgressEventListenerE,
841                         SetHttpProgressListenerp);
842
843         retVal = (this->*SetHttpProgressListenerp)(listener);
844
845         AFTER_ORIGINAL_TIZEN_SOCK("HttpTransaction::SetHttpProgressListener",
846                                   VT_ULONG, retVal, (unsigned int)this,
847                                   (unsigned int)this,
848                                   HTTP_API_OTHER, info, "x",
849                                   voidp_to_uint64(&listener));
850         return retVal;
851 }
852
853 result HttpTransaction::SetUserObject(const Tizen::Base::Object* pUserData)
854 {
855         typedef result (HttpTransaction::*methodType)(
856                         const Tizen::Base::Object* pUserData);
857         static methodType SetUserObjectp;
858         result retVal;
859
860         BEFORE_ORIGINAL_TIZEN_NET(
861                         _ZN5Tizen3Net4Http15HttpTransaction13SetUserObjectEPKNS_4Base6ObjectE,
862                         SetUserObjectp);
863
864         retVal = (this->*SetUserObjectp)(pUserData);
865
866         AFTER_ORIGINAL_TIZEN_SOCK("HttpTransaction::SetUserObject", VT_ULONG,
867                                   retVal, (unsigned int)this,
868                                   (unsigned int)this,
869                                   HTTP_API_OTHER, info, "x",
870                                   voidp_to_uint64(&pUserData));
871         return retVal;
872 }
873
874 Tizen::Base::Object* HttpTransaction::GetUserObject(void) const
875 {
876         typedef Tizen::Base::Object* (HttpTransaction::*methodType)(void) const;
877         static methodType GetUserObjectp;
878         Tizen::Base::Object* retVal;
879
880         BEFORE_ORIGINAL_TIZEN_NET(
881                         _ZNK5Tizen3Net4Http15HttpTransaction13GetUserObjectEv,
882                         GetUserObjectp);
883
884         retVal = (this->*GetUserObjectp)();
885
886         AFTER_ORIGINAL_TIZEN_SOCK("HttpTransaction::GetUserObject", VT_PTR, retVal,
887                         (unsigned int)this, (unsigned int)this, HTTP_API_OTHER, info,
888                         "s", "void");
889         return retVal;
890 }
891
892 bool HttpTransaction::EnableTransactionReadyToWrite(void)
893 {
894         typedef bool (HttpTransaction::*methodType)(void) const;
895         static methodType EnableTransactionReadyToWritep;
896         bool retVal;
897
898         BEFORE_ORIGINAL_TIZEN_NET(
899                         _ZN5Tizen3Net4Http15HttpTransaction29EnableTransactionReadyToWriteEv,
900                         EnableTransactionReadyToWritep);
901
902         retVal = (this->*EnableTransactionReadyToWritep)();
903
904         AFTER_ORIGINAL_TIZEN_SOCK("HttpTransaction::GetUserObject", VT_INT, retVal,
905                         (unsigned int)this, (unsigned int)this, HTTP_API_OTHER, info,
906                         "s", "void");
907         return retVal;
908 }
909 //
910 result HttpTransaction::Submit(void)
911 {
912         typedef result (HttpTransaction::*methodType)(void);
913         static methodType Submitp;
914         result retVal;
915
916         BEFORE_ORIGINAL_TIZEN_NET( _ZN5Tizen3Net4Http15HttpTransaction6SubmitEv,
917                         Submitp);
918
919         retVal = (this->*Submitp)();
920
921         AFTER_ORIGINAL_TIZEN_SOCK("HttpTransaction::Submit", VT_ULONG, retVal,
922                         (unsigned int)this, (unsigned int)this, HTTP_API_SUBMIT, info,
923                         "s", "void");
924         return retVal;
925 }
926
927 result HttpTransaction::Resume(void)
928 {
929         typedef result (HttpTransaction::*methodType)(void);
930         static methodType Resumep;
931         result retVal;
932
933         BEFORE_ORIGINAL_TIZEN_NET( _ZN5Tizen3Net4Http15HttpTransaction6ResumeEv,
934                         Resumep);
935
936         retVal = (this->*Resumep)();
937
938         AFTER_ORIGINAL_TIZEN_SOCK("HttpTransaction::Resume", VT_ULONG, retVal,
939                         (unsigned int)this, (unsigned int)this, HTTP_API_OTHER, info,
940                         "s", "void");
941         return retVal;
942 }
943
944 result HttpTransaction::Pause(void)
945 {
946         typedef result (HttpTransaction::*methodType)(void);
947         static methodType Pausep;
948         result retVal;
949
950         BEFORE_ORIGINAL_TIZEN_NET( _ZN5Tizen3Net4Http15HttpTransaction5PauseEv,
951                         Pausep);
952
953         retVal = (this->*Pausep)();
954
955         AFTER_ORIGINAL_TIZEN_SOCK("HttpTransaction::Pause", VT_ULONG, retVal,
956                         (unsigned int)this, (unsigned int)this, HTTP_API_OTHER, info,
957                         "s", "void");
958         return retVal;
959 }
960
961 result HttpTransaction::SetClientCertificate(int certificateId)
962 {
963         typedef result (HttpTransaction::*methodType)(int certificateId);
964         static methodType SetClientCertificatep;
965         result retVal;
966
967         BEFORE_ORIGINAL_TIZEN_NET(
968                         _ZN5Tizen3Net4Http15HttpTransaction20SetClientCertificateEi,
969                         SetClientCertificatep);
970
971         retVal = (this->*SetClientCertificatep)(certificateId);
972
973         AFTER_ORIGINAL_TIZEN_SOCK("HttpTransaction::SetClientCertificate", VT_ULONG,
974                                   retVal, (unsigned int)this, (unsigned int)this,
975                                   HTTP_API_OTHER, info, "d", certificateId);
976         return retVal;
977 }
978
979 result HttpTransaction::SetTimeout(int timeout)
980 {
981         typedef result (HttpTransaction::*methodType)(int timeout);
982         static methodType SetTimeoutp;
983         result retVal;
984
985         BEFORE_ORIGINAL_TIZEN_NET(
986                         _ZN5Tizen3Net4Http15HttpTransaction10SetTimeoutEi, SetTimeoutp);
987
988         retVal = (this->*SetTimeoutp)(timeout);
989
990         AFTER_ORIGINAL_TIZEN_SOCK("HttpTransaction::SetTimeout", VT_ULONG, retVal,
991                         (unsigned int)this, (unsigned int)this, HTTP_API_OTHER, info,
992                         "d", timeout);
993         return retVal;
994 }
995 result HttpTransaction::SetServerCertificateVerification(
996                 NetHttpCertificateVerificationFlag flag) {
997         typedef result (HttpTransaction::*methodType)(
998                         NetHttpCertificateVerificationFlag flag);
999         static methodType SetServerCertificateVerificationp;
1000         result retVal;
1001
1002         BEFORE_ORIGINAL_TIZEN_NET(
1003                         _ZN5Tizen3Net4Http15HttpTransaction32SetServerCertificateVerificationENS1_34NetHttpCertificateVerificationFlagE,
1004                         SetServerCertificateVerificationp);
1005
1006         retVal = (this->*SetServerCertificateVerificationp)(flag);
1007
1008         AFTER_ORIGINAL_TIZEN_SOCK("HttpTransaction::SetServerCertificateVerification",
1009                                   VT_ULONG, retVal, (unsigned int)this,
1010                                   (unsigned int)this, HTTP_API_OTHER, info, "d",
1011                                   flag);
1012         return retVal;
1013 }
1014
1015 HttpTransaction::~HttpTransaction(void)
1016 {
1017         typedef void (HttpTransaction::*methodType)(void);
1018         static methodType HttpTransactiondp = 0;
1019
1020         probeInfo_t probeInfo;
1021         log_t log;
1022         int blockresult = 0;
1023         bool bfiltering = false;
1024         if (!HttpTransactiondp) {
1025                 if (lib_handle[LIBOSP_NET] == NULL) {
1026                         lib_handle[LIBOSP_NET] = dlopen(lib_string[LIBOSP_NET], RTLD_LAZY);
1027                         if (lib_handle[LIBOSP_NET] == NULL) {
1028                                 char perror_msg[128];
1029                                 sprintf(perror_msg, "dlopen failed : %s",
1030                                                 lib_string[LIBOSP_NET]);
1031                                 perror(perror_msg);
1032                                 exit(0);
1033                         }
1034                 }
1035                 void* funcp = dlsym(lib_handle[LIBOSP_NET],
1036                                 "_ZN5Tizen3Net4Http15HttpTransactionD1Ev");
1037                 if (funcp == NULL || dlerror() != NULL) {
1038                         perror("dlsym failed : " "_ZN5Tizen3Net4Http15HttpTransactionD1Ev");
1039                         exit(0);
1040                 }
1041                 memcpy(&HttpTransactiondp, &funcp, sizeof(void*));
1042         }
1043
1044         if ((blockresult =
1045                         preBlockBegin(
1046                                         ((void*) __builtin_extract_return_addr(
1047                                                         __builtin_return_address(0))), bfiltering, _sopt))
1048                         != 0) {
1049                 setProbePoint(&probeInfo);
1050                 preBlockEnd();
1051         }
1052
1053         (this->*HttpTransactiondp)();
1054
1055         if (postBlockBegin(blockresult)) {
1056                 log.type = 0;
1057                 log.length = 0;
1058                 log.data[0] = '\0';
1059                 log.length = sprintf(log.data, "%d`,%d`,%s`,%lu`,%d`,%d", 15,
1060                                 probeInfo.eventIndex, "HttpTransaction::~HttpTransaction",
1061                                 probeInfo.currentTime, probeInfo.pID, probeInfo.tID);
1062                 log.length += sprintf(log.data + log.length, "`,`,");
1063                 log.length += sprintf(log.data + log.length,
1064                                 "`,0`,0`,2`,%u`,0x%x`,0x%x`,2`,%d`,`,",
1065                                 (unsigned int) CALLER_ADDRESS, (unsigned int) this,
1066                                 (unsigned int) this, HTTP_API_TRANSACTION_CLOSE);
1067                 log.length += sprintf(log.data + log.length, "`,\ncallstack_start`,");
1068                 getBacktraceString(&log, 4096 - log.length - 17);
1069                 log.length += sprintf(log.data + log.length, "`,callstack_end");
1070
1071                 printLog(&log, MSG_LOG);
1072                 postBlockEnd();
1073         }
1074 }
1075
1076 // HttpTransaction
1077
1078 class HttpCredentials;
1079
1080 class _HttpAuthenticationImpl;
1081 class HttpAuthentication {
1082 public:
1083         ~HttpAuthentication(void);
1084         Tizen::Base::String* GetRealmN(void) const;
1085         NetHttpAuthScheme GetAuthScheme(void) const;
1086         HttpTransaction* SetCredentials(HttpCredentials& credentials);
1087 private:
1088         HttpAuthentication(void);
1089         HttpAuthentication(const HttpAuthentication& rhs);
1090         HttpAuthentication& operator =(const HttpAuthentication& rhs);
1091 private:
1092         _HttpAuthenticationImpl* __pHttpAuthenticationImpl;
1093         friend class _HttpAuthenticationImpl;
1094 };
1095 // HttpAuthentication
1096
1097 class HttpCredentials {
1098 public:
1099         HttpCredentials(void);
1100         HttpCredentials(const Tizen::Base::String& name,
1101                         const Tizen::Base::String& password);
1102         HttpCredentials(const HttpCredentials& rhs);
1103         virtual ~HttpCredentials(void);
1104         HttpCredentials& operator =(const HttpCredentials& rhs);
1105         result SetName(const Tizen::Base::String& name);
1106         result SetPassword(const Tizen::Base::String& password);
1107         Tizen::Base::String GetName(void) const;
1108         Tizen::Base::String GetPassword(void) const;
1109         virtual bool Equals(const Tizen::Base::Object& rhs) const;
1110         virtual int GetHashCode(void) const;
1111 private:
1112         Tizen::Base::String __userName;
1113         Tizen::Base::String __password;
1114         friend class HttpCredentialsImpl;
1115         class HttpCredentialsImpl* __pHttpCredentialsImpl;
1116 };
1117 // HttpCredentials
1118
1119 class INetConnectionEventListener;
1120
1121 class _NetConnectionImpl;
1122 class NetConnection {
1123 public:
1124         NetConnection(void);
1125         virtual ~NetConnection(void);
1126         result Construct(NetAccountId netAccountId);
1127 public:
1128         result AddNetConnectionListener(INetConnectionEventListener& listener);
1129         result RemoveNetConnectionListener(INetConnectionEventListener& listener);
1130         result Start(void);
1131         result Stop(void);
1132         result Close(void);
1133         NetAccountId GetNetAccountId(void) const;
1134         const NetConnectionInfo* GetNetConnectionInfo(void) const;
1135         static NetConnectionInfo* GetNetConnectionInfoN(NetAccountId netAccountId);
1136         static Tizen::Base::Collection::IList* GetAllNetConnectionInfoN(void);
1137         NetConnectionState GetConnectionState(void) const;
1138 private:
1139         NetConnection(const NetConnection& rhs);
1140         NetConnection& operator =(const NetConnection& rhs);
1141 private:
1142         _NetConnectionImpl* __pNetConnectionImpl;
1143         friend class _NetConnectionImpl;
1144 };
1145 // NetConnection
1146
1147 class IHttpEntity;
1148
1149 class _HttpRequestImpl;
1150 class HttpRequest {
1151 public:
1152         result SetMethod(NetHttpMethod method);
1153         result SetCustomMethod(const Tizen::Base::String& method);
1154         result SetVersion(HttpVersion version);
1155         result SetUri(const Tizen::Base::String& uri);
1156         result WriteBody(const Tizen::Base::ByteBuffer& body);
1157         result SetEntity(IHttpEntity& entity);
1158         HttpHeader* GetHeader(void) const;
1159         result SetCookie(const Tizen::Base::String& cookieString);
1160         Tizen::Base::String GetCookie(void) const;
1161         result SetAcceptEncoding(const Tizen::Base::String& encoding);
1162 protected:
1163         HttpRequest(void);
1164         ~HttpRequest(void);
1165         result Construct(const HttpTransaction& httpTransaction,
1166                         const HttpHeader* pCommonHeader);
1167         NetHttpMethod GetMethod(void) const;
1168         result GetCustomMethod(Tizen::Base::String& method) const;
1169         HttpVersion GetVersion(void) const;
1170         result GetUri(Tizen::Base::String& uri) const;
1171         Tizen::Base::ByteBuffer* ReadBodyN(void);
1172         Tizen::Base::String GetAcceptEncoding(void) const;
1173 private:
1174         HttpRequest(const HttpRequest& rhs);
1175         HttpRequest& operator =(const HttpRequest& rhs);
1176 private:
1177         friend class _HttpRequestImpl;
1178         _HttpRequestImpl* __pHttpRequestImpl;
1179 };
1180
1181 result HttpRequest::SetMethod(NetHttpMethod method)
1182 {
1183         typedef result (HttpRequest::*methodType)(NetHttpMethod method);
1184         static methodType SetMethodp;
1185         result retVal;
1186
1187         BEFORE_ORIGINAL_TIZEN_NET(
1188                         _ZN5Tizen3Net4Http11HttpRequest9SetMethodENS1_13NetHttpMethodE,
1189                         SetMethodp);
1190
1191         retVal = (this->*SetMethodp)(method);
1192
1193         AFTER_ORIGINAL_TIZEN_SOCK("HttpRequest::SetMethod", VT_ULONG, retVal,
1194                         (unsigned int)this, (unsigned int)this, HTTP_API_OTHER, info,
1195                         "d", method);
1196         return retVal;
1197 }
1198
1199 result HttpRequest::SetCustomMethod(const Tizen::Base::String& method)
1200 {
1201         typedef result (HttpRequest::*methodType)(
1202                         const Tizen::Base::String& method);
1203         static methodType SetCustomMethodp;
1204         result retVal;
1205
1206         BEFORE_ORIGINAL_TIZEN_NET(
1207                         _ZN5Tizen3Net4Http11HttpRequest15SetCustomMethodERKNS_4Base6StringE,
1208                         SetCustomMethodp);
1209
1210         retVal = (this->*SetCustomMethodp)(method);
1211
1212         int nSize = method.GetLength();
1213         char temp[nSize];
1214         WcharToChar(temp, method.GetPointer());
1215         info.msg_buf = temp;
1216         info.msg_total_size = nSize;
1217         info.msg_pack_size = nSize;
1218
1219         AFTER_ORIGINAL_TIZEN_SOCK("HttpRequest::SetCustomMethod", VT_ULONG,
1220                                   retVal, (unsigned int)this,
1221                                   (unsigned int)this,
1222                                   HTTP_API_REQUEST, info, "x",
1223                                   voidp_to_uint64(&method));
1224         return retVal;
1225 }
1226
1227 result HttpRequest::SetVersion(HttpVersion version)
1228 {
1229         typedef result (HttpRequest::*methodType)(HttpVersion version);
1230         static methodType SetVersionp;
1231         result retVal;
1232
1233         BEFORE_ORIGINAL_TIZEN_NET(
1234                         _ZN5Tizen3Net4Http11HttpRequest6SetUriERKNS_4Base6StringE,
1235                         SetVersionp);
1236
1237         retVal = (this->*SetVersionp)(version);
1238
1239         AFTER_ORIGINAL_TIZEN_SOCK("HttpRequest::SetVersion", VT_ULONG, retVal,
1240                         (unsigned int)this, (unsigned int)this, HTTP_API_OTHER, info,
1241                         "d", version);
1242         return retVal;
1243 }
1244
1245 result HttpRequest::SetUri(const Tizen::Base::String& uri)
1246 {
1247         typedef result (HttpRequest::*methodType)(const Tizen::Base::String& uri);
1248         static methodType SetUrip;
1249         result retVal;
1250
1251         BEFORE_ORIGINAL_TIZEN_NET(
1252                         _ZN5Tizen3Net4Http11HttpRequest6SetUriERKNS_4Base6StringE, SetUrip);
1253
1254         retVal = (this->*SetUrip)(uri);
1255
1256         int nSize = uri.GetLength();
1257         char temp[nSize];
1258         WcharToChar(temp, uri.GetPointer());
1259
1260         AFTER_ORIGINAL_TIZEN_SOCK("HttpRequest::SetUri", VT_ULONG, retVal,
1261                         (unsigned int)this, (unsigned int)this, HTTP_API_REQUEST, info,
1262                         "s", temp);
1263         return retVal;
1264 }
1265
1266 result HttpRequest::WriteBody(const Tizen::Base::ByteBuffer& body)
1267 {
1268         typedef result (HttpRequest::*methodType)(
1269                         const Tizen::Base::ByteBuffer& body);
1270         static methodType WriteBodyp;
1271         result retVal;
1272
1273         BEFORE_ORIGINAL_TIZEN_NET(
1274                         _ZN5Tizen3Net4Http11HttpRequest9WriteBodyERKNS_4Base10ByteBufferE,
1275                         WriteBodyp);
1276
1277         retVal = (this->*WriteBodyp)(body);
1278
1279         int bufferSize = body.GetLimit();
1280         char* pBuffer = (char*) (body.GetPointer());
1281         Tizen::Base::String strData;
1282         strData.SetCapacity(bufferSize);
1283         strData.Append(pBuffer);
1284         char* out = new char[bufferSize];
1285         WcharToChar(out, strData.GetPointer());
1286
1287         info.msg_buf = out;
1288         info.msg_pack_size = bufferSize > SOCKET_SEND_SIZE ? SOCKET_SEND_SIZE : bufferSize;
1289         info.msg_total_size = bufferSize;
1290
1291         AFTER_ORIGINAL_TIZEN_SOCK("HttpRequest::WriteBody", VT_ULONG, retVal,
1292                                   (unsigned int)this, (unsigned int)this,
1293                                   HTTP_API_REQUEST, info, "x",
1294                                   voidp_to_uint64(&body));
1295         delete [] out;
1296         return retVal;
1297 }
1298
1299 result HttpRequest::SetEntity(IHttpEntity& entity)
1300 {
1301         typedef result (HttpRequest::*methodType)(IHttpEntity& entity);
1302         static methodType SetEntityp;
1303         result retVal;
1304
1305         BEFORE_ORIGINAL_TIZEN_NET(
1306                         _ZN5Tizen3Net4Http11HttpRequest9SetEntityERNS1_11IHttpEntityE,
1307                         SetEntityp);
1308
1309         retVal = (this->*SetEntityp)(entity);
1310
1311         AFTER_ORIGINAL_TIZEN_SOCK("HttpRequest::SetEntity", VT_ULONG, retVal,
1312                                   (unsigned int)this, (unsigned int)this,
1313                                   HTTP_API_OTHER, info,
1314                                   "x", voidp_to_uint64(&entity));
1315         return retVal;
1316 }
1317
1318 HttpHeader* HttpRequest::GetHeader(void) const
1319 {
1320         typedef HttpHeader* (HttpRequest::*methodType)(void) const;
1321         static methodType GetHeaderp;
1322         HttpHeader* retVal;
1323
1324         BEFORE_ORIGINAL_TIZEN_NET( _ZNK5Tizen3Net4Http11HttpRequest9GetHeaderEv,
1325                         GetHeaderp);
1326         retVal = (this->*GetHeaderp)();
1327         if (retVal == NULL)
1328                 newerrno = 1;
1329         AFTER_ORIGINAL_TIZEN_SOCK("HttpRequest::GetHeader", VT_PTR, retVal,
1330                                   (unsigned int)this, (unsigned int)this,
1331                                   HTTP_API_ALLOCATION, info, "s", "void");
1332         return retVal;
1333 }
1334
1335 result HttpRequest::SetCookie(const Tizen::Base::String& cookieString)
1336 {
1337         typedef result (HttpRequest::*methodType)(
1338                         const Tizen::Base::String& cookieString);
1339         static methodType SetCookiep;
1340         result retVal;
1341
1342         BEFORE_ORIGINAL_TIZEN_NET(
1343                         _ZN5Tizen3Net4Http11HttpRequest9SetCookieERKNS_4Base6StringE,
1344                         SetCookiep);
1345
1346         retVal = (this->*SetCookiep)(cookieString);
1347
1348         int nSize = cookieString.GetLength();
1349         char temp[nSize];
1350         WcharToChar(temp, cookieString.GetPointer());
1351         info.msg_buf = temp;
1352         info.msg_total_size = nSize;
1353         info.msg_pack_size = nSize > SOCKET_SEND_SIZE ? SOCKET_SEND_SIZE : nSize;
1354
1355         AFTER_ORIGINAL_TIZEN_SOCK("HttpRequest::SetCookie", VT_ULONG, retVal,
1356                                   (unsigned int)this, (unsigned int)this,
1357                                   HTTP_API_REQUEST, info, "x",
1358                                   voidp_to_uint64(&cookieString));
1359         return retVal;
1360 }
1361
1362 Tizen::Base::String HttpRequest::GetCookie(void) const
1363 {
1364         typedef Tizen::Base::String (HttpRequest::*methodType)(void) const;
1365         static methodType GetCookiep;
1366         Tizen::Base::String retVal;
1367
1368         BEFORE_ORIGINAL_TIZEN_NET( _ZNK5Tizen3Net4Http11HttpRequest9GetCookieEv,
1369                         GetCookiep);
1370
1371         retVal = (this->*GetCookiep)();
1372
1373         int nSize = retVal.GetLength();
1374         char temp[nSize];
1375         WcharToChar(temp, retVal.GetPointer());
1376         info.msg_buf = temp;
1377         info.msg_total_size = nSize;
1378         info.msg_pack_size = nSize > SOCKET_SEND_SIZE ? SOCKET_SEND_SIZE : nSize;
1379
1380         AFTER_ORIGINAL_TIZEN_SOCK("HttpRequest::GetCookie", VT_PTR,
1381                                   (unsigned int)&retVal,
1382                                   (unsigned int)this, (unsigned int)this,
1383                                   HTTP_API_OTHER, info, "s", "void");
1384         return retVal;
1385 }
1386
1387 result HttpRequest::SetAcceptEncoding(const Tizen::Base::String& encoding)
1388 {
1389         typedef result (HttpRequest::*methodType)(const Tizen::Base::String& uri);
1390         static methodType SetAcceptEncodingp;
1391         result retVal;
1392
1393         BEFORE_ORIGINAL_TIZEN_NET(
1394                         _ZN5Tizen3Net4Http11HttpRequest6SetUriERKNS_4Base6StringE,
1395                         SetAcceptEncodingp);
1396
1397         retVal = (this->*SetAcceptEncodingp)(encoding);
1398
1399         int nSize = encoding.GetLength();
1400         char temp[nSize];
1401         WcharToChar(temp, encoding.GetPointer());
1402         info.msg_buf = temp;
1403         info.msg_total_size = nSize;
1404         info.msg_pack_size = nSize > SOCKET_SEND_SIZE ? SOCKET_SEND_SIZE : nSize;
1405
1406         AFTER_ORIGINAL_TIZEN_SOCK("HttpRequest::SetAcceptEncoding", VT_ULONG,
1407                                   retVal, (unsigned int)this, (unsigned int)this,
1408                                   HTTP_API_REQUEST, info, "s", temp);
1409         return retVal;
1410 }
1411
1412 Tizen::Base::ByteBuffer* HttpRequest::ReadBodyN(void)
1413 {
1414         typedef Tizen::Base::ByteBuffer* (HttpRequest::*methodType)(void);
1415         static methodType ReadBodyNp;
1416         Tizen::Base::ByteBuffer* retVal;
1417
1418         BEFORE_ORIGINAL_TIZEN_NET( _ZN5Tizen3Net4Http11HttpRequest9ReadBodyNEv,
1419                         ReadBodyNp);
1420         retVal = (this->*ReadBodyNp)();
1421
1422         int bufferSize = retVal->GetLimit();
1423         Tizen::Base::ByteBuffer copybuffer;
1424         copybuffer.Construct(bufferSize + 4);
1425         copybuffer.CopyFrom(*retVal);
1426
1427         info.msg_buf = (char *)(copybuffer.GetPointer());
1428         info.msg_total_size = bufferSize;
1429         info.msg_pack_size = bufferSize > SOCKET_SEND_SIZE ? SOCKET_SEND_SIZE : bufferSize;
1430
1431         AFTER_ORIGINAL_TIZEN_SOCK("HttpRequest::ReadBodyN", VT_PTR,
1432                                   (unsigned int)&retVal,
1433                                   (unsigned int)this, (unsigned int)this,
1434                                   HTTP_API_OTHER, info, "s", "void");
1435         return retVal;
1436 }
1437
1438 Tizen::Base::String HttpRequest::GetAcceptEncoding(void) const
1439 {
1440         typedef Tizen::Base::String (HttpRequest::*methodType)(void) const;
1441         static methodType HttpRequestp;
1442         Tizen::Base::String retVal;
1443
1444         BEFORE_ORIGINAL_TIZEN_NET(
1445                         _ZNK5Tizen3Net4Http11HttpRequest17GetAcceptEncodingEv,
1446                         HttpRequestp);
1447         retVal = (this->*HttpRequestp)();
1448
1449         int nSize = retVal.GetLength();
1450         char temp[nSize];
1451         WcharToChar(temp, retVal.GetPointer());
1452         info.msg_buf = temp;
1453         info.msg_total_size = nSize;
1454         info.msg_pack_size = nSize > SOCKET_SEND_SIZE ? SOCKET_SEND_SIZE : nSize;
1455
1456         AFTER_ORIGINAL_TIZEN_SOCK("HttpRequest::GetAcceptEncoding", VT_PTR,
1457                                   (unsigned int)&retVal,
1458                                   (unsigned int)this, (unsigned int)this,
1459                                   HTTP_API_OTHER, info, "s", "void");
1460         return retVal;
1461 }
1462
1463 HttpRequest::~HttpRequest() {
1464 }
1465
1466 // HttpRequest
1467
1468 class _HttpResponseImpl;
1469 class HttpResponse {
1470 public:
1471         NetHttpStatusCode GetStatusCode(void) const;
1472         int GetHttpStatusCode(void) const;
1473         Tizen::Base::String GetStatusText(void) const;
1474         Tizen::Base::String GetVersion(void) const;
1475         HttpHeader* GetHeader(void) const;
1476         Tizen::Base::ByteBuffer* ReadBodyN(void);
1477         Tizen::Base::Collection::IList* GetCookies(void) const;
1478 protected:
1479         HttpResponse(void);
1480         virtual ~HttpResponse(void);
1481         result Construct(const HttpTransaction& httpTransaction);
1482 protected:
1483         result SetStatusCode(NetHttpStatusCode statusCode);
1484         result SetHttpStatusCode(int statusCode);
1485         result SetStatusText(const Tizen::Base::String& statusText);
1486         result SetVersion(const Tizen::Base::String& httpVersion);
1487         result WriteBody(const Tizen::Base::ByteBuffer& body);
1488         result Read(int headerLen, int bodyLen, int& rcvHeaderLen, int& rcvBodyLen);
1489         result SetCookie(Tizen::Net::Http::HttpHeader* pHeader);
1490 private:
1491         HttpResponse(const HttpResponse& rhs);
1492         HttpResponse& operator =(const HttpResponse& rhs);
1493 private:
1494         friend class _HttpResponseImpl;
1495         _HttpResponseImpl* __pHttpResponseImpl;
1496
1497 };
1498
1499 NetHttpStatusCode HttpResponse::GetStatusCode(void) const
1500 {
1501         typedef NetHttpStatusCode (HttpResponse::*methodType)(void) const;
1502         static methodType GetHttpStatusCodep;
1503         NetHttpStatusCode retVal;
1504
1505         BEFORE_ORIGINAL_TIZEN_NET(
1506                         _ZNK5Tizen3Net4Http12HttpResponse17GetHttpStatusCodeEv,
1507                         GetHttpStatusCodep);
1508
1509         retVal = (this->*GetHttpStatusCodep)();
1510         AFTER_ORIGINAL_TIZEN_SOCK("HttpResponse::GetStatusCode", VT_INT, retVal,
1511                         (unsigned int)this, (unsigned int)this, HTTP_API_OTHER, info,
1512                         "s", "void");
1513         return retVal;
1514
1515 }
1516
1517 int HttpResponse::GetHttpStatusCode(void) const
1518 {
1519         typedef int (HttpResponse::*methodType)(void) const;
1520         static methodType GetHttpStatusCodep;
1521         int retVal;
1522
1523         BEFORE_ORIGINAL_TIZEN_NET(
1524                         _ZNK5Tizen3Net4Http12HttpResponse17GetHttpStatusCodeEv,
1525                         GetHttpStatusCodep);
1526
1527         retVal = (this->*GetHttpStatusCodep)();
1528
1529         AFTER_ORIGINAL_TIZEN_SOCK("HttpResponse::GetHttpStatusCode", VT_INT, retVal,
1530                         (unsigned int)this, (unsigned int)this, HTTP_API_OTHER, info,
1531                         "s", "void");
1532         return retVal;
1533 }
1534
1535 Tizen::Base::String HttpResponse::GetStatusText(void) const
1536 {
1537         typedef Tizen::Base::String (HttpResponse::*methodType)(void) const;
1538         static methodType GetStatusTextp;
1539         Tizen::Base::String retVal;
1540
1541         BEFORE_ORIGINAL_TIZEN_NET(
1542                         _ZNK5Tizen3Net4Http12HttpResponse13GetStatusTextEv, GetStatusTextp);
1543
1544         retVal = (this->*GetStatusTextp)();
1545         int nSize = retVal.GetLength();
1546         char temp[nSize];
1547         WcharToChar(temp, retVal.GetPointer());
1548
1549         info.msg_buf = temp;
1550         info.msg_total_size = nSize;
1551         info.msg_pack_size = nSize > SOCKET_SEND_SIZE ? SOCKET_SEND_SIZE : nSize;
1552
1553         AFTER_ORIGINAL_TIZEN_SOCK("HttpResponse::GetStatusText", VT_PTR,
1554                         (unsigned int)&retVal, (unsigned int)this, (unsigned int)this,
1555                         HTTP_API_RESPONSE, info, "s", "void");
1556         return retVal;
1557 }
1558
1559 Tizen::Base::String HttpResponse::GetVersion(void) const
1560 {
1561         typedef Tizen::Base::String (HttpResponse::*methodType)(void) const;
1562         static methodType GetVersionp;
1563         Tizen::Base::String retVal;
1564
1565         BEFORE_ORIGINAL_TIZEN_NET( _ZNK5Tizen3Net4Http12HttpResponse10GetVersionEv,
1566                         GetVersionp);
1567
1568         retVal = (this->*GetVersionp)();
1569         int nSize = retVal.GetLength();
1570         char temp[nSize];
1571         WcharToChar(temp, retVal.GetPointer());
1572
1573         info.msg_buf = temp;
1574         info.msg_total_size = nSize;
1575         info.msg_pack_size = nSize > SOCKET_SEND_SIZE ? SOCKET_SEND_SIZE : nSize;
1576
1577         AFTER_ORIGINAL_TIZEN_SOCK("HttpResponse::GetVersion", VT_PTR,
1578                         (unsigned int)&retVal, (unsigned int)this, (unsigned int)this,
1579                         HTTP_API_RESPONSE, info, "s", "void");
1580         return retVal;
1581 }
1582
1583 HttpHeader* HttpResponse::GetHeader(void) const
1584 {
1585         typedef HttpHeader* (HttpResponse::*methodType)(void) const;
1586         static methodType GetHeaderp;
1587         HttpHeader* retVal;
1588
1589         BEFORE_ORIGINAL_TIZEN_NET( _ZNK5Tizen3Net4Http12HttpResponse9GetHeaderEv,
1590                         GetHeaderp);
1591         retVal = (this->*GetHeaderp)();
1592         if (retVal == NULL)
1593                 newerrno = 1;
1594         AFTER_ORIGINAL_TIZEN_SOCK("HttpResponse::GetHeader", VT_PTR, retVal,
1595                         (unsigned int)this, (unsigned int)this, HTTP_API_ALLOCATION,
1596                         info, "s", "void");
1597         return retVal;
1598 }
1599
1600 Tizen::Base::ByteBuffer* HttpResponse::ReadBodyN(void)
1601 {
1602         typedef Tizen::Base::ByteBuffer* (HttpResponse::*methodType)(void);
1603         static methodType ReadBodyNp;
1604         Tizen::Base::ByteBuffer* retVal;
1605
1606         BEFORE_ORIGINAL_TIZEN_NET( _ZN5Tizen3Net4Http12HttpResponse9ReadBodyNEv,
1607                         ReadBodyNp);
1608         retVal = (this->*ReadBodyNp)();
1609         if (retVal == NULL)
1610                 newerrno = 1;
1611
1612         int bufferSize = retVal->GetLimit();
1613         Tizen::Base::ByteBuffer copybuffer;
1614         copybuffer.Construct(bufferSize + 4);
1615         copybuffer.CopyFrom(*retVal);
1616
1617         char* out = (char*) (copybuffer.GetPointer());
1618
1619         info.msg_buf = out;
1620         info.msg_pack_size = bufferSize > SOCKET_SEND_SIZE ? SOCKET_SEND_SIZE : bufferSize;
1621         info.msg_total_size = bufferSize;
1622
1623         AFTER_ORIGINAL_TIZEN_SOCK("HttpResponse::ReadBodyN", VT_PTR,
1624                         (unsigned int)&retVal, (unsigned int)this, (unsigned int)this,
1625                         HTTP_API_RESPONSE, info, "s", "void");
1626         return retVal;
1627 }
1628
1629 Tizen::Base::Collection::IList* HttpResponse::GetCookies(void) const
1630 {
1631         typedef Tizen::Base::Collection::IList* (HttpResponse::*methodType)(
1632                         void) const;
1633         static methodType GetCookiesp;
1634         Tizen::Base::Collection::IList* retVal;
1635
1636         BEFORE_ORIGINAL_TIZEN_NET( _ZNK5Tizen3Net4Http12HttpResponse10GetCookiesEv,
1637                         GetCookiesp);
1638
1639         retVal = (this->*GetCookiesp)();
1640         if (retVal == NULL)
1641                 newerrno = 1;
1642         AFTER_ORIGINAL_TIZEN_SOCK("HttpResponse::GetCookies", VT_PTR,
1643                         (unsigned int)&retVal, (unsigned int)this, (unsigned int)this,
1644                         HTTP_API_OTHER, info, "s", "void");
1645         return retVal;
1646 }
1647
1648 result HttpResponse::SetStatusCode(NetHttpStatusCode statusCode)
1649 {
1650         typedef result (HttpResponse::*methodType)(NetHttpStatusCode statusCode);
1651         static methodType SetStatusCodep;
1652         result retVal;
1653
1654         BEFORE_ORIGINAL_TIZEN_NET(
1655                         _ZN5Tizen3Net4Http12HttpResponse13SetStatusCodeENS1_17NetHttpStatusCodeE,
1656                         SetStatusCodep);
1657
1658         retVal = (this->*SetStatusCodep)(statusCode);
1659
1660         AFTER_ORIGINAL_TIZEN_SOCK("HttpResponse::SetStatusCode", VT_ULONG, retVal,
1661                         (unsigned int)this, (unsigned int)this, HTTP_API_OTHER, info,
1662                         "d", statusCode);
1663         return retVal;
1664 }
1665
1666 result HttpResponse::SetHttpStatusCode(int statusCode)
1667 {
1668         typedef result (HttpResponse::*methodType)(int statusCode);
1669         static methodType SetHttpStatusCodep;
1670         result retVal;
1671
1672         BEFORE_ORIGINAL_TIZEN_NET(
1673                         _ZN5Tizen3Net4Http12HttpResponse17SetHttpStatusCodeEi,
1674                         SetHttpStatusCodep);
1675
1676         retVal = (this->*SetHttpStatusCodep)(statusCode);
1677
1678         AFTER_ORIGINAL_TIZEN_SOCK("HttpResponse::SetHttpStatusCode", VT_ULONG,
1679                                   retVal, (unsigned int)this, (unsigned int)this,
1680                                   HTTP_API_OTHER, info, "d", statusCode);
1681         return retVal;
1682 }
1683
1684 result HttpResponse::SetStatusText(const Tizen::Base::String& statusText)
1685 {
1686         typedef result (HttpResponse::*methodType)(
1687                         const Tizen::Base::String& statusText);
1688         static methodType SetStatusText;
1689         result retVal;
1690
1691         BEFORE_ORIGINAL_TIZEN_NET(
1692                         _ZN5Tizen3Net4Http12HttpResponse13SetStatusTextERKNS_4Base6StringE,
1693                         SetStatusText);
1694
1695         retVal = (this->*SetStatusText)(statusText);
1696
1697         int nSize = statusText.GetLength();
1698         char temp[nSize];
1699         WcharToChar(temp, statusText.GetPointer());
1700
1701         AFTER_ORIGINAL_TIZEN_SOCK("HttpResponse::SetStatusText", VT_ULONG, retVal,
1702                         (unsigned int)this, (unsigned int)this, HTTP_API_OTHER, info,
1703                         "s", temp);
1704         return retVal;
1705 }
1706
1707 result HttpResponse::SetVersion(const Tizen::Base::String& httpVersion)
1708 {
1709         typedef result (HttpResponse::*methodType)(
1710                         const Tizen::Base::String& httpVersion);
1711         static methodType SetVersionp;
1712         result retVal;
1713
1714         BEFORE_ORIGINAL_TIZEN_NET(
1715                         _ZN5Tizen3Net4Http12HttpResponse10SetVersionERKNS_4Base6StringE,
1716                         SetVersionp);
1717
1718         retVal = (this->*SetVersionp)(httpVersion);
1719
1720         int nSize = httpVersion.GetLength();
1721         char temp[nSize];
1722         WcharToChar(temp, httpVersion.GetPointer());
1723
1724         AFTER_ORIGINAL_TIZEN_SOCK("HttpResponse::SetVersion", VT_ULONG, retVal,
1725                         (unsigned int)this, (unsigned int)this, HTTP_API_OTHER, info,
1726                         "s", temp);
1727         return retVal;
1728 }
1729
1730 result HttpResponse::WriteBody(const Tizen::Base::ByteBuffer& body)
1731 {
1732         typedef result (HttpResponse::*methodType)(
1733                         const Tizen::Base::ByteBuffer& body);
1734         static methodType WriteBodyp;
1735         result retVal;
1736
1737         BEFORE_ORIGINAL_TIZEN_NET(
1738                         _ZN5Tizen3Net4Http12HttpResponse9WriteBodyERKNS_4Base10ByteBufferE,
1739                         WriteBodyp);
1740
1741         retVal = (this->*WriteBodyp)(body);
1742
1743         int bufferSize = body.GetLimit();
1744         char* pBuffer = (char*) (body.GetPointer());
1745         Tizen::Base::String strData;
1746         strData.SetCapacity(bufferSize);
1747         strData.Append(pBuffer);
1748         char* out = new char[bufferSize + sizeof(char)];
1749         WcharToChar(out, strData.GetPointer());
1750
1751         info.msg_buf = out;
1752         info.msg_pack_size = bufferSize > SOCKET_SEND_SIZE ? SOCKET_SEND_SIZE : bufferSize;
1753         info.msg_total_size = bufferSize;
1754
1755         AFTER_ORIGINAL_TIZEN_SOCK("HttpResponse::WriteBody", VT_ULONG, retVal,
1756                                   (unsigned int)this, (unsigned int)this,
1757                                   HTTP_API_RESPONSE,
1758                                   info, "x", voidp_to_uint64(&body));
1759         delete out;
1760         return retVal;
1761 }
1762
1763 result HttpResponse::Read(int headerLen, int bodyLen, int& rcvHeaderLen,
1764                 int& rcvBodyLen) {
1765         typedef result (HttpResponse::*methodType)(int headerLen, int bodyLen,
1766                         int& rcvHeaderLen, int& rcvBodyLen);
1767         static methodType Readp;
1768         result retVal;
1769
1770         BEFORE_ORIGINAL_TIZEN_NET( _ZN5Tizen3Net4Http12HttpResponse4ReadEiiRiS3_,
1771                         Readp);
1772
1773         retVal = (this->*Readp)(headerLen, bodyLen, rcvHeaderLen, rcvBodyLen);
1774
1775         AFTER_ORIGINAL_TIZEN_SOCK("HttpResponse::Read", VT_ULONG, retVal,
1776                                   (unsigned int)this, (unsigned int)this,
1777                                   HTTP_API_OTHER, info,
1778                                   "ddxx", headerLen, bodyLen,
1779                                   voidp_to_uint64(&rcvHeaderLen),
1780                                   voidp_to_uint64(&rcvBodyLen));
1781         return retVal;
1782 }
1783
1784 result HttpResponse::SetCookie(Tizen::Net::Http::HttpHeader* pHeader)
1785 {
1786         typedef result (HttpResponse::*methodType)(
1787                         Tizen::Net::Http::HttpHeader* pHeader);
1788         static methodType SetCookiep;
1789         result retVal;
1790
1791         BEFORE_ORIGINAL_TIZEN_NET(
1792                         _ZN5Tizen3Net4Http12HttpResponse9SetCookieEPNS1_10HttpHeaderE,
1793                         SetCookiep);
1794
1795         retVal = (this->*SetCookiep)(pHeader);
1796
1797         AFTER_ORIGINAL_TIZEN_SOCK("HttpResponse::SetCookie", VT_ULONG, retVal,
1798                                   (unsigned int)this, (unsigned int)this,
1799                                   HTTP_API_OTHER, info,
1800                                   "x", voidp_to_uint64(&pHeader));
1801         return retVal;
1802 }
1803
1804 //
1805 //HttpResponse::~HttpResponse(void){
1806 //
1807 //}
1808 // HttpResponse
1809
1810 class _HttpCookieStorageManagerImpl;
1811 class HttpCookieStorageManager {
1812
1813 public:
1814         result GetCookies(const Tizen::Base::String& url,
1815                         Tizen::Base::String& cookies) const;
1816         result RemoveCookies(const Tizen::Base::String& url);
1817         result RemoveAllCookies();
1818 private:
1819         HttpCookieStorageManager();
1820         ~HttpCookieStorageManager();
1821         HttpCookieStorageManager(const HttpCookieStorageManager& rhs);
1822         HttpCookieStorageManager& operator =(const HttpCookieStorageManager& rhs);
1823 private:
1824         friend class _HttpCookieStorageManagerImpl;
1825         _HttpCookieStorageManagerImpl* __pHttpCookieStorageManagerImpl;
1826 };
1827 // HttpCookieStorageManager
1828
1829 class _HttpRequestImpl;
1830 class IHttpEntity {
1831 public:
1832         virtual ~IHttpEntity(void) {
1833         }
1834 public:
1835         virtual long long GetContentLength(void) const = 0;
1836         virtual Tizen::Base::String GetContentType(void) const = 0;
1837 protected:
1838         virtual bool HasNextData(void) = 0;
1839         virtual Tizen::Base::ByteBuffer* GetNextDataN(int recommendedSize) = 0;
1840 protected:
1841         virtual void IHttpEntity_Reserved1(void) {
1842         }
1843         virtual void IHttpEntity_Reserved2(void) {
1844         }
1845         virtual void IHttpEntity_Reserved3(void) {
1846         }
1847         friend class _HttpRequestImpl;
1848 };
1849
1850 class IHttpTransactionEventListener {
1851 public:
1852         virtual ~IHttpTransactionEventListener(void) {
1853         }
1854 public:
1855         virtual void OnTransactionReadyToRead(HttpSession& httpSession,
1856                         HttpTransaction& httpTransaction, int availableBodyLen) = 0;
1857         virtual void OnTransactionAborted(HttpSession& httpSession,
1858                         HttpTransaction& httpTransaction, result r) = 0;
1859         virtual void OnTransactionReadyToWrite(HttpSession& httpSession,
1860                         HttpTransaction& httpTransaction, int recommendedChunkSize) = 0;
1861         virtual void OnTransactionHeaderCompleted(HttpSession& httpSession,
1862                         HttpTransaction& httpTransaction, int headerLen,
1863                         bool bAuthRequired) = 0;
1864         virtual void OnTransactionCompleted(HttpSession& httpSession,
1865                         HttpTransaction& httpTransaction) = 0;
1866         virtual void OnTransactionCertVerificationRequiredN(
1867                         HttpSession& httpSession, HttpTransaction& httpTransaction,
1868                         Tizen::Base::String* pCert) = 0;
1869         virtual bool OnTransactionCertVerificationRequestedN(
1870                         HttpSession&, HttpTransaction&,
1871                         Tizen::Base::Collection::IList* pCertList) {
1872                 std::unique_ptr < Tizen::Base::Collection::IList
1873                                 > upCertList(pCertList);
1874                 return false;
1875         }
1876 protected:
1877         virtual void IHttpTransactionEventListener_Reserved1(void) {
1878         }
1879
1880 };
1881
1882 class IHttpProgressEventListener {
1883 public:
1884         virtual ~IHttpProgressEventListener(void) {
1885         }
1886 public:
1887         virtual void OnHttpUploadInProgress(HttpSession& httpSession,
1888                         HttpTransaction& httpTransaction, long long currentLength,
1889                         long long totalLength) = 0;
1890         virtual void OnHttpDownloadInProgress(HttpSession& httpSession,
1891                         HttpTransaction& httpTransaction, long long currentLength,
1892                         long long totalLength) = 0;
1893 protected:
1894         virtual void IHttpProgressEventListener_Reserved1(void) {
1895         }
1896         virtual void IHttpProgressEventListener_Reserved2(void) {
1897         }
1898         virtual void IHttpProgressEventListener_Reserved3(void) {
1899         }
1900 };
1901
1902 class INetConnectionEventListener {
1903 public:
1904         virtual ~INetConnectionEventListener(void) {
1905         }
1906 public:
1907         virtual void OnNetConnectionStarted(NetConnection& netConnection,
1908                         result r) = 0;
1909         virtual void OnNetConnectionStopped(NetConnection& netConnection,
1910                         result r) = 0;
1911         virtual void OnNetConnectionSuspended(NetConnection& netConnection) = 0;
1912         virtual void OnNetConnectionResumed(NetConnection& netConnection) = 0;
1913 protected:
1914         virtual void INetConnectionEventListener_Reserved1(void) {
1915         }
1916         virtual void INetConnectionEventListener_Reserved2(void) {
1917         }
1918 };
1919 // INetConnectionEventListener
1920
1921 }
1922 }
1923 } // namespace Tizen { namespace Net { namespace Http