Initialize Tizen 2.3
[framework/osp/net.git] / src / http / FNetHttp_HttpCurl.cpp
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_HttpCurl.cpp
20  * @brief               This is the implementation file for _HttpCurl class.
21  */
22
23 #include <FNetHttpHttpTypes.h>
24 #include <FBaseSysLog.h>
25 #include "FNetHttp_HttpCommon.h"
26 #include "FNetHttp_HttpCurl.h"
27
28 using namespace Tizen::Base;
29
30 namespace Tizen { namespace Net { namespace Http
31 {
32
33 _HttpCurl::_HttpCurl(CURL* pCurl, bool isAuthenticated)
34 {
35         __pCurl = pCurl;
36         __isAuthenticated = isAuthenticated;
37         __refCount = 0;
38         AddRef();
39 }
40
41 _HttpCurl::~_HttpCurl(void)
42 {
43         if (__pCurl != null)
44         {
45                 SysLog(NID_NET_HTTP, "__pCurl[%x, IsAuthenticated:%d] is deleted.", __pCurl, __isAuthenticated);
46                 curl_easy_cleanup(__pCurl);
47                 __pCurl = null;
48         }
49 }
50
51 void
52 _HttpCurl::AddRef(void)
53 {
54         __refCount++;
55         SysLog(NID_NET_HTTP, "The reference count of this instance is %d. __pCurl[%x]", __refCount, __pCurl);
56 }
57
58 void
59 _HttpCurl::Release(void)
60 {
61         __refCount--;
62         SysLog(NID_NET_HTTP, "The reference count of this instance is %d. __pCurl[%x]", __refCount, __pCurl);
63
64         if (__refCount == 0)
65         {
66                 SysLog(NID_NET_HTTP, "The reference count of this instance is 0. So this instance will be deleted.");
67                 delete this;
68         }
69 }
70
71 CURL*
72 _HttpCurl::GetCurl(void) const
73 {
74         return __pCurl;
75 }
76 void
77 _HttpCurl::SetAuthenticated(void)
78 {
79         __isAuthenticated = true;
80 }
81 } } } // Tizen::Net::Http