merge with master
[framework/osp/net.git] / src / http / FNetHttp_HttpDeleter.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FNetHttp_HttpDeleter.h
20  * @brief               This is the header file for defining custom deleter for smart pointer.
21  *
22  * This is the header file for defining custom deleter for smart pointer.
23  */
24
25 #ifndef _FNET_HTTP_INTERNAL_HTTP_DELETER_H_
26 #define _FNET_HTTP_INTERNAL_HTTP_DELETER_H_
27
28 #include <openssl/ssl.h>
29 #include <curl.h>
30 #include <FNetHttpHttpTypes.h>
31 #include <FBaseSysLog.h>
32 #include <FSecCert_CertService.h>
33 #include <FNetHttpHttpRequest.h>
34 #include <FNetHttpHttpResponse.h>
35 #include <FNetHttpHttpCookie.h>
36 #include <FNetHttpHttpCookieStorageManager.h>
37 #include <FNetHttpHttpCookieStorageManager.h>
38 #include "FNetHttp_HttpCookieImpl.h"
39 #include "FNetHttp_HttpRequestImpl.h"
40 #include "FNetHttp_HttpResponseImpl.h"
41 #include "FNetHttp_HttpCookieStorageManagerImpl.h"
42
43 namespace Tizen { namespace Net { namespace Http
44 {
45
46 struct _BIoDeleter
47 {
48         void operator()(BIO* pBIo)
49         {
50                 BIO_free_all(pBIo);
51         }
52 };
53
54 struct _CertInfoDeleter
55 {
56         void operator()(Tizen::Security::Cert::_CertInfo* pCertInfo)
57         {
58                 free(pCertInfo);
59         }
60 };
61
62 struct _HttpCookieDeleter
63 {
64         void operator()(HttpCookie* pCookie)
65         {
66                 _HttpCookieImpl::DeleteHttpCookie(pCookie);
67         }
68 };
69
70 struct _HttpRequestDeleter
71 {
72         void operator()(HttpRequest* pRequest)
73         {
74                 _HttpRequestImpl::DeleteHttpRequest(pRequest);
75         }
76 };
77
78 struct _HttpResponseDeleter
79 {
80         void operator()(HttpResponse* pResponse)
81         {
82                 _HttpResponseImpl::DeleteHttpResponse(pResponse);
83         }
84 };
85
86 struct _HttpCookieStorageManagerDeleter
87 {
88         void operator()(HttpCookieStorageManager* pCookieStorageMgr)
89         {
90                 _HttpCookieStorageManagerImpl::DeleteHttpCookieStorageManager(pCookieStorageMgr);
91         }
92 };
93
94 struct _CollectionDeleter
95 {
96         template<typename Collection>
97         void operator()(Collection* pCollection)
98         {
99                 pCollection->RemoveAll(true);
100                 delete pCollection;
101         }
102 };
103
104 struct _CharDeleter
105 {
106         void operator()(char* pBytes)
107         {
108                 free(pBytes);
109         }
110 };
111
112 struct _X509Deleter
113 {
114         void operator()(X509* pCert)
115         {
116                 X509_free(pCert);
117         }
118 };
119
120 struct _X509ChainDeleter
121 {
122         void operator()(STACK_OF(X509)* pCertChain)
123         {
124                 sk_X509_free(pCertChain);
125         }
126 };
127
128
129 } } } //Tizen::Net::Http
130 #endif // _FNET_HTTP_INTERNAL_HTTP_DELETER_H_