2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FCntDownloadRequest.h
19 * @brief This is the header file for the %DownloadRequest class.
21 * This header file contains the declarations of the %DownloadRequest class.
23 #ifndef _FCNT_DOWNLOAD_REQUEST_H_
24 #define _FCNT_DOWNLOAD_REQUEST_H_
26 #include <FBaseResult.h>
27 #include <FBaseString.h>
28 #include <FBaseColIMap.h>
29 #include <FCntTypes.h>
31 namespace Tizen { namespace Content
35 * @class DownloadRequest
36 * @brief This class provides information of a download request.
40 * @final This class is not intended for extension.
42 * The %DownloadRequest class provides information of a download request. It provides the URL of a download request, which is mandatory information. It also provides the destination directory path and the file name. The destination directory path and file name can be set by the SetDirectoryPath() and SetFileName() methods. @n
43 * If the download path is not specified, the data will be downloaded to the default download directory returned by Tizen::System::Environment::GetDefaultDownloadPath().
47 class _OSP_EXPORT_ DownloadRequest
48 : public Tizen::Base::Object
52 * Initializes this instance of %DownloadRequest with the specified URL. @n
53 * The downloaded path is set to a default download directory returned by Tizen::System::Environment::GetDefaultDownloadPath().
57 * @param[in] url The URL of the download request
59 DownloadRequest(const Tizen::Base::String& url);
62 * Initializes this instance of %DownloadRequest with the specified URL and directory path.
66 * @param[in] url The URL of the download request
67 * @param[in] dirPath The directory path of the data that will be downloaded
69 DownloadRequest(const Tizen::Base::String& url, const Tizen::Base::String& dirPath);
72 * Copying of objects using this copy constructor is allowed.
76 * @param[in] rhs An instance of %DownloadRequest to copy
78 DownloadRequest(const DownloadRequest& rhs);
81 * This destructor overrides Tizen::Base::Object::~Object().
85 virtual ~DownloadRequest(void);
88 * Copying of objects using this copy assignment operator is allowed.
90 * @return A reference to this instance
91 * @param[in] rhs An instance of %DownloadRequest
93 DownloadRequest& operator =(const DownloadRequest& rhs);
96 * Checks whether the specified instance of Tizen::Base::Object is equivalent to the current instance of %DownloadRequest.
100 * @return @c true if the specified instance of Tizen::Base::Object is equivalent to the current instance of %DownloadRequest, @n
102 * @param[in] obj The object to compare with the current instance of %DownloadRequest
104 virtual bool Equals(const Tizen::Base::Object& obj) const;
107 * Gets the hash value of the current instance.
111 * @return The hash value of the current instance
113 virtual int GetHashCode(void) const;
116 * Sets the directory path of the data that will be downloaded.
120 * @param[in] dirPath The directory path
122 void SetDirectoryPath(const Tizen::Base::String& dirPath);
125 * Sets the file name of the data to be downloaded.
129 * @param[in] fileName The file name
131 void SetFileName(const Tizen::Base::String& fileName);
134 * Gets the URL of a download request.
138 * @return The URL of this download request
140 Tizen::Base::String GetUrl(void) const;
143 * Gets the directory path of the data that will be downloaded.
147 * @return The directory path
149 Tizen::Base::String GetDirectoryPath(void) const;
152 * Gets the file name of the data to be downloaded.
156 * @return The file name
158 Tizen::Base::String GetFileName(void) const;
161 * Sets to show the download notification by the system or not. @n
162 * If true, the system posts notifications about this download request through the Tizen::Shell::NotificationManager. @n
163 * By default, this value sets to true.
165 * @param[in] enable whether the system should show a notification for this download request
166 * @see Tizen::Shell::NotificationManager
168 void SetNotification(bool enable);
171 * Sets the extra data which is delivered to the application when the notification message is selected. @n
172 * The extra data will be passed to the application through the
173 * Tizen::App::IAppControlProviderEventListener::OnAppControlRequestReceived().
175 * @return An error code
176 * @param[in] pExtraData A pointer to an argument map of the Tizen::Base::String key and Tizen::Base::String value pair
177 * @exception E_SUCCESS The method is successful.
178 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
179 * - The argument is null. @n
180 * - The argument is not a map of Tizen::Base::String key and Tizen::Base::String value pair.
181 * @see Tizen::Shell::NotificationManager
182 * @see Tizen::App::IAppControlProviderEventListener::OnAppControlRequestReceived()
184 result SetNotificationExtraData(const Tizen::Base::Collection::IMap *pExtraData);
187 * Sets the allowed network type. By default, all network types are allowed.
189 * @param[in] type The download network type
191 void SetNetworkType(DownloadNetworkType type);
194 * Checks whether the system should show a notification for this download request.
196 * @return @c true if the system should show a notification for this download request, @n
199 bool IsNotificationEnabled(void) const;
202 * Gets the extra data which is delivered to the application when the notification message is seleted.
204 * @return The extra data map which consists of the Tizen::Base::String key and Tizen::Base::String value pair
206 const Tizen::Base::Collection::IMap* GetNotificationExtraData(void) const;
209 * Gets the allowed network type.
211 * @return network type
213 DownloadNetworkType GetNetworkType(void) const;
216 * Adds an HTTP header field.
218 * @return An error code
219 * @param[in] field The HTTP header field
220 * @param[in] value The value of the header field
221 * @exception E_SUCCESS The method is successful.
222 * @exception E_INVALID_ARG The field is empty or already exist.
224 result AddRequestHeader(const Tizen::Base::String& field, const Tizen::Base::String& value);
227 * Sets an HTTP header field.
229 * @return An error code
230 * @param[in] field The HTTP header field
231 * @param[in] value The value of the header field
232 * @exception E_SUCCESS The method is successful.
233 * @exception E_INVALID_ARG The field is empty or does not exist.
235 result SetRequestHeader(const Tizen::Base::String& field, const Tizen::Base::String& value);
238 * Removes an HTTP header field.
240 * @return An error code
241 * @param[in] field The HTTP header field
242 * @exception E_SUCCESS The method is successful.
243 * @exception E_INVALID_ARG The field is empty or does not exist.
245 result RemoveRequestHeader(const Tizen::Base::String& field);
248 * Gets the value of the HTTP header field.
250 * @return The value of HTTP header field if successful, @n
251 * else null if there is no HTTP header field
252 * @param[in] field The HTTP header field
254 Tizen::Base::String* GetRequestHeaderN(const Tizen::Base::String& field);
258 * This default constructor is intentionally declared as private so that only the platform can create an instance.
260 DownloadRequest(void);
262 friend class _DownloadRequestImpl;
263 class _DownloadRequestImpl * __pDownloadRequestImpl;
265 }; // DownloadRequest
267 } } // Tizen::Content
269 #endif //_FCNT_DOWNLOAD_MANAGER_H_