2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
17 * @file FCntDownloadRequest.h
18 * @brief This is the header file for the %DownloadRequest class.
20 * This header file contains the declarations of the %DownloadRequest class.
22 #ifndef _FCNT_DOWNLOAD_REQUEST_H_
23 #define _FCNT_DOWNLOAD_REQUEST_H_
25 #include <FBaseResult.h>
26 #include <FBaseString.h>
27 #include <FBaseColIMap.h>
28 #include <FCntTypes.h>
30 namespace Tizen { namespace Content
34 * @class DownloadRequest
35 * @brief This class provides information of a download request.
39 * @final This class is not intended for extension.
41 * 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
42 * If the download path is not specified, the data will be downloaded to the default download directory returned by Tizen::System::Environment::GetDefaultDownloadPath().
46 class _OSP_EXPORT_ DownloadRequest
47 : public Tizen::Base::Object
51 * Initializes this instance of %DownloadRequest with the specified URL. @n
52 * The downloaded path is set to a default download directory returned by Tizen::System::Environment::GetDefaultDownloadPath().
56 * @param[in] url The URL of the download request
58 DownloadRequest(const Tizen::Base::String& url);
61 * Initializes this instance of %DownloadRequest with the specified URL and directory path.
65 * @param[in] url The URL of the download request
66 * @param[in] dirPath The directory path of the data that will be downloaded
68 DownloadRequest(const Tizen::Base::String& url, const Tizen::Base::String& dirPath);
71 * Copying of objects using this copy constructor is allowed.
75 * @param[in] rhs An instance of %DownloadRequest to copy
77 DownloadRequest(const DownloadRequest& rhs);
80 * This destructor overrides Tizen::Base::Object::~Object().
84 virtual ~DownloadRequest(void);
87 * Copying of objects using this copy assignment operator is allowed.
89 * @return A reference to this instance
90 * @param[in] rhs An instance of %DownloadRequest
92 DownloadRequest& operator =(const DownloadRequest& rhs);
95 * Checks whether the specified instance of Tizen::Base::Object is equivalent to the current instance of %DownloadRequest.
99 * @return @c true if the specified instance of Tizen::Base::Object is equivalent to the current instance of %DownloadRequest, @n
101 * @param[in] obj The object to compare with the current instance of %DownloadRequest
103 virtual bool Equals(const Tizen::Base::Object& obj) const;
106 * Gets the hash value of the current instance.
110 * @return The hash value of the current instance
112 virtual int GetHashCode(void) const;
115 * Sets the directory path of the data that will be downloaded.
119 * @param[in] dirPath The directory path
121 void SetDirectoryPath(const Tizen::Base::String& dirPath);
124 * Sets the file name of the data to be downloaded.
128 * @param[in] fileName The file name
130 void SetFileName(const Tizen::Base::String& fileName);
133 * Gets the URL of a download request.
137 * @return The URL of this download request
139 Tizen::Base::String GetUrl(void) const;
142 * Gets the directory path of the data that will be downloaded.
146 * @return The directory path
148 Tizen::Base::String GetDirectoryPath(void) const;
151 * Gets the file name of the data to be downloaded.
155 * @return The file name
157 Tizen::Base::String GetFileName(void) const;
160 * Determines whether the system should show the download notification or not. @n
161 * If @c true, the system posts notifications about this download request through the Tizen::Shell::NotificationManager. @n
162 * By default, this value sets to @c true.
166 * @param[in] enable Set to @c true if the system shows a notification for this download request, @n
168 * @see Tizen::Shell::NotificationManager
170 void SetNotification(bool enable);
173 * Sets extra data that is delivered to the application when the notification message is selected. @n
174 * The extra data will be passed to the application through the
175 * Tizen::App::IAppControlProviderEventListener::OnAppControlRequestReceived() method.
179 * @return An error code
180 * @param[in] pExtraData A pointer to an argument map of the Tizen::Base::String key and the Tizen::Base::String value pair
181 * @exception E_SUCCESS The method is successful.
182 * @exception E_INVALID_ARG Either of the following conditions has occurred:
183 * - The argument is @c null.
184 * - The argument is not a map of the Tizen::Base::String key and the Tizen::Base::String value pair.
185 * @see Tizen::Shell::NotificationManager
186 * @see Tizen::App::IAppControlProviderEventListener::OnAppControlRequestReceived()
188 result SetNotificationExtraData(const Tizen::Base::Collection::IMap *pExtraData);
191 * Sets to an allowed network type. @n
192 * By default, all network types are allowed.
196 * @param[in] type The download network type
198 void SetNetworkType(DownloadNetworkType type);
201 * Checks whether the system should show a notification for this download request.
205 * @return @c true if the system should show a notification for this download request, @n
208 bool IsNotificationEnabled(void) const;
211 * Gets extra data that is delivered to the application when the notification message is selected.
215 * @return The extra data map that consists of the Tizen::Base::String key and the Tizen::Base::String value pair
217 const Tizen::Base::Collection::IMap* GetNotificationExtraData(void) const;
220 * Gets an allowed network type.
224 * @return The network type
226 DownloadNetworkType GetNetworkType(void) const;
229 * Adds an HTTP header field.
233 * @return An error code
234 * @param[in] field The HTTP header field
235 * @param[in] value The value of the header field
236 * @exception E_SUCCESS The method is successful.
237 * @exception E_INVALID_ARG Either the field is empty or it already exists.
239 result AddRequestHeader(const Tizen::Base::String& field, const Tizen::Base::String& value);
242 * Sets an HTTP header field.
246 * @return An error code
247 * @param[in] field The HTTP header field
248 * @param[in] value The value of the header field
249 * @exception E_SUCCESS The method is successful.
250 * @exception E_INVALID_ARG Either the field is empty or it does not exist.
252 result SetRequestHeader(const Tizen::Base::String& field, const Tizen::Base::String& value);
255 * Removes an HTTP header field.
259 * @return An error code
260 * @param[in] field The HTTP header field
261 * @exception E_SUCCESS The method is successful.
262 * @exception E_INVALID_ARG Either the field is empty or it does not exist.
264 result RemoveRequestHeader(const Tizen::Base::String& field);
267 * Gets the value of an HTTP header field.
271 * @return The value of the HTTP header field if successful, @n
272 * else @c null if there is no HTTP header field
273 * @param[in] field The HTTP header field
275 Tizen::Base::String* GetRequestHeaderN(const Tizen::Base::String& field);
279 * This default constructor is intentionally declared as private so that only the platform can create an instance.
281 DownloadRequest(void);
283 friend class _DownloadRequestImpl;
284 class _DownloadRequestImpl * __pDownloadRequestImpl;
286 }; // DownloadRequest
288 } } // Tizen::Content
290 #endif //_FCNT_DOWNLOAD_MANAGER_H_