Fix : Search APIs don't return exception despite the content in DB doesn't match...
[platform/framework/native/content.git] / src / FCntDownloadRequest.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file        FCntDownloadRequest.cpp
19  * @brief       This is the implementation file for the DownloadRequest class.
20  *
21  */
22
23 #include <FBaseSysLog.h>
24 #include <FCntDownloadRequest.h>
25 #include "FCnt_DownloadRequestImpl.h"
26
27 using namespace Tizen::Base;
28 using namespace Tizen::Base::Collection;
29
30 namespace Tizen { namespace Content
31 {
32
33 DownloadRequest::DownloadRequest(void)
34         : __pDownloadRequestImpl(null)
35 {
36         __pDownloadRequestImpl = new (std::nothrow) _DownloadRequestImpl();
37         SysTryReturnVoidResult(NID_CNT, __pDownloadRequestImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
38 }
39
40 DownloadRequest::DownloadRequest(const String& url)
41 {
42         __pDownloadRequestImpl = new (std::nothrow) _DownloadRequestImpl(url);
43         SysTryReturnVoidResult(NID_CNT, __pDownloadRequestImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
44 }
45
46 DownloadRequest::DownloadRequest(const String& url, const String& dirPath)
47 {
48         __pDownloadRequestImpl = new (std::nothrow) _DownloadRequestImpl(url, dirPath);
49         SysTryReturnVoidResult(NID_CNT, __pDownloadRequestImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
50 }
51
52 DownloadRequest::DownloadRequest(const DownloadRequest& rhs)
53 {
54         __pDownloadRequestImpl = new (std::nothrow) _DownloadRequestImpl(*rhs.__pDownloadRequestImpl);
55         SysTryReturnVoidResult(NID_CNT, __pDownloadRequestImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
56 }
57
58 DownloadRequest::~DownloadRequest(void)
59 {
60         delete __pDownloadRequestImpl;
61 }
62
63
64 DownloadRequest&
65 DownloadRequest::operator =(const DownloadRequest& rhs)
66 {
67         if (&rhs != this)
68         {
69                 delete __pDownloadRequestImpl;
70
71                 __pDownloadRequestImpl = new (std::nothrow) _DownloadRequestImpl(*rhs.__pDownloadRequestImpl);
72
73                 SysTryReturn(NID_CNT, __pDownloadRequestImpl != null, *this, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
74         }
75
76         return *this;
77 }
78
79 bool
80 DownloadRequest::Equals(const Object& obj) const
81 {
82         if (&obj == this)
83         {
84                 return true;
85         }
86
87         const DownloadRequest* pOther = dynamic_cast< const DownloadRequest* >(&obj);
88         if (pOther == null)
89         {
90                 return false;
91         }
92
93         return __pDownloadRequestImpl->Equals(*pOther->__pDownloadRequestImpl);
94 }
95
96 int
97 DownloadRequest::GetHashCode(void) const
98 {
99         return __pDownloadRequestImpl->GetHashCode();
100 }
101
102 void
103 DownloadRequest::SetDirectoryPath(const String& dirPath)
104 {
105         __pDownloadRequestImpl->SetDirectoryPath(dirPath);
106 }
107
108 void
109 DownloadRequest::SetFileName(const String& fileName)
110 {
111         __pDownloadRequestImpl->SetFileName(fileName);
112 }
113
114 String
115 DownloadRequest::GetUrl(void) const
116 {
117         return __pDownloadRequestImpl->GetUrl();
118 }
119
120 String
121 DownloadRequest::GetDirectoryPath(void) const
122 {
123         return __pDownloadRequestImpl->GetDirectoryPath();
124 }
125
126 String
127 DownloadRequest::GetFileName(void) const
128 {
129         return __pDownloadRequestImpl->GetFileName();
130 }
131
132 void
133 DownloadRequest::SetNotification(bool enable)
134 {
135         __pDownloadRequestImpl->SetNotification(enable);
136 }
137
138 result
139 DownloadRequest::SetNotificationExtraData(const IMap *pExtraData)
140 {
141         SysTryReturnResult(NID_CNT, pExtraData != null, E_INVALID_ARG, "pExtraData is null.");
142         return __pDownloadRequestImpl->SetNotificationExtraData(pExtraData);
143 }
144
145 void
146 DownloadRequest::SetNetworkType(DownloadNetworkType type)
147 {
148         __pDownloadRequestImpl->SetNetworkType(type);
149 }
150
151 bool
152 DownloadRequest::IsNotificationEnabled(void) const
153 {
154         return __pDownloadRequestImpl->IsNotificationEnabled();
155 }
156
157 const IMap*
158 DownloadRequest::GetNotificationExtraData(void) const
159 {
160         return __pDownloadRequestImpl->GetNotificationExtraData();
161 }
162
163 DownloadNetworkType
164 DownloadRequest::GetNetworkType(void) const
165 {
166         return __pDownloadRequestImpl->GetNetworkType();
167 }
168
169 result
170 DownloadRequest::AddRequestHeader(const String& field, const String& value)
171 {
172         return __pDownloadRequestImpl->AddRequestHeader(field, value);
173 }
174
175 result
176 DownloadRequest::SetRequestHeader(const String& field, const String& value)
177 {
178         return __pDownloadRequestImpl->SetRequestHeader(field, value);
179 }
180
181 result
182 DownloadRequest::RemoveRequestHeader(const String& field)
183 {
184         return __pDownloadRequestImpl->RemoveRequestHeader(field);
185 }
186
187 String*
188 DownloadRequest::GetRequestHeaderN(const String& field)
189 {
190         return __pDownloadRequestImpl->GetRequestHeaderN(field);
191 }
192
193 } } // Tizen::Content