4dab754d0ffe333545fcfdf68cee8b2674753579
[platform/framework/native/content.git] / inc / FCntDownloadRequest.h
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  * @file                FCntDownloadRequest.h
18  * @brief               This is the header file for the %DownloadRequest class.
19  *
20  * This header file contains the declarations of the %DownloadRequest class.
21  */
22 #ifndef _FCNT_DOWNLOAD_REQUEST_H_
23 #define _FCNT_DOWNLOAD_REQUEST_H_
24
25 #include <FBaseResult.h>
26 #include <FBaseString.h>
27 #include <FBaseColIMap.h>
28 #include <FCntTypes.h>
29
30 namespace Tizen { namespace Content
31 {
32
33 /**
34 * @class    DownloadRequest
35 * @brief    This class provides information of a download request.
36 *
37 * @since 2.0
38 *
39 * @final        This class is not intended for extension.
40 *
41 * The %DownloadRequest class provides information of a download request. It provides the URL of a download request, which is the 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 is downloaded to the default download directory returned by Tizen::System::Environment::GetDefaultDownloadPath().
43 *
44 */
45
46 class _OSP_EXPORT_ DownloadRequest
47         : public Tizen::Base::Object
48 {
49 public:
50         /**
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().
53         *
54         * @since 2.0
55         *
56         * @param[in]  url               The URL of the download request
57         */
58         DownloadRequest(const Tizen::Base::String& url);
59
60         /**
61         * Initializes this instance of %DownloadRequest with the specified URL and directory path.
62         *
63         * @since 2.0
64         *
65         * @param[in]  url               The URL of the download request
66         * @param[in]  dirPath   The directory path of the data that is downloaded
67         */
68         DownloadRequest(const Tizen::Base::String& url, const Tizen::Base::String& dirPath);
69
70         /**
71         * Copying of objects using this copy constructor is allowed.
72         *
73         * @since 2.0
74         *
75         * @param[in]  rhs               An instance of %DownloadRequest to copy
76         */
77         DownloadRequest(const DownloadRequest& rhs);
78
79         /**
80         * This destructor overrides Tizen::Base::Object::~Object().
81         *
82         * @since 2.0
83         */
84         virtual ~DownloadRequest(void);
85
86         /**
87         * Copying of objects using this copy assignment operator is allowed.
88         *
89         * @return               A reference to this instance
90         * @param[in]    rhs             An instance of %DownloadRequest to copy
91         */
92         DownloadRequest& operator =(const DownloadRequest& rhs);
93
94         /**
95          *      Checks whether the specified instance of Tizen::Base::Object is equivalent to the current instance of %DownloadRequest.
96          *
97          *      @since 2.0
98          *
99          *      @return         @c true if the specified instance of Tizen::Base::Object is equivalent to the current instance of %DownloadRequest, @n
100          *              else @c false
101          *      @param[in]      obj The object to compare with the current instance of %DownloadRequest
102          */
103         virtual bool Equals(const Tizen::Base::Object& obj) const;
104
105         /**
106          *      Gets the hash value of the current instance.
107          *
108          *      @since 2.0
109          *
110          *      @return         The hash value of the current instance
111          */
112         virtual int GetHashCode(void) const;
113
114         /**
115         * Sets the directory path of the data that is downloaded.
116         *
117         * @since 2.0
118         *
119         * @param[in]  dirPath   The directory path
120         */
121         void SetDirectoryPath(const Tizen::Base::String& dirPath); 
122
123         /**
124         * Sets the file name of the data that is downloaded.
125         *
126         * @since 2.0
127         *
128         * @param[in]  fileName  The file name
129         */
130         void SetFileName(const Tizen::Base::String& fileName); 
131
132         /**
133         * Gets the URL of the download request.
134         *
135         * @since 2.0
136         *
137         * @return               The URL of this download request
138         */
139         Tizen::Base::String GetUrl(void) const;
140
141         /**
142         * Gets the directory path of the data that is downloaded.
143         *
144         * @since 2.0
145         *
146         * @return               The directory path
147         */
148         Tizen::Base::String GetDirectoryPath(void) const;
149
150         /**
151         * Gets the file name of the data that is downloaded.
152         *
153         * @since 2.0
154         *
155         * @return               The file name
156         */
157         Tizen::Base::String GetFileName(void) const;
158
159         /**
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 is set to @c true.
163         *
164         * @since 2.1
165         *
166         * @param[in] enable Set to @c true if the system shows a notification for this download request, @n
167         *                                       else @c false
168         */
169         void SetNotification(bool enable);
170
171         /**
172         * Sets extra data that is delivered to the application when the notification message is selected. @n
173         * The extra data is passed to the application through the
174         * Tizen::App::IAppControlProviderEventListener::OnAppControlRequestReceived() method.
175         *
176         * @since 2.1
177         *
178         * @return        An error code
179         * @param[in] pExtraData    A pointer to the argument map of the Tizen::Base::String key and the %Tizen::Base::String value pair
180         * @exception E_SUCCESS     The method is successful.
181         * @exception E_INVALID_ARG Either of the following conditions has occurred:
182         *                                               - The argument is @c null.
183         *                                               - The argument is not a map of the Tizen::Base::String key and the %Tizen::Base::String value pair.
184         * @see Tizen::Shell::NotificationManager
185         */
186         result SetNotificationExtraData(const Tizen::Base::Collection::IMap *pExtraData);
187
188         /**
189         * Sets the allowed network type. @n
190         * By default, all network types are allowed.
191         *
192         * @since 2.1
193         *
194         * @param[in] type The download network type
195         */
196         void SetNetworkType(DownloadNetworkType type);
197
198         /**
199         * Checks whether the system should show a notification for this download request.
200         *
201         * @since 2.1
202         *
203         * @return @c true if the system should show a notification for this download request, @n
204         *                 else @c false
205         */
206         bool IsNotificationEnabled(void) const;
207
208         /**
209         * Gets the extra data that is delivered to the application when the notification message is selected.
210         *
211         * @since 2.1
212         *
213         * @return The extra data map that consists of the Tizen::Base::String key and the %Tizen::Base::String value pair
214         */
215         const Tizen::Base::Collection::IMap* GetNotificationExtraData(void) const;
216
217         /**
218         * Gets the allowed network type.
219         *
220         * @since 2.1
221         *
222         * @return The network type
223         */
224         DownloadNetworkType GetNetworkType(void) const;
225
226         /**
227         * Adds the HTTP header field.
228         *
229         * @since 2.1
230         *
231         * @return        An error code
232         * @param[in] field                      The HTTP header field
233         * @param[in] value                      The value of the header field
234         * @exception E_SUCCESS          The method is successful.
235         * @exception E_INVALID_ARG      Either the field is empty or it already exists.
236         */
237         result AddRequestHeader(const Tizen::Base::String& field, const Tizen::Base::String& value);
238
239         /**
240         * Sets the HTTP header field.
241         *
242         * @since 2.1
243         *
244         * @return        An error code
245         * @param[in] field                      The HTTP header field
246         * @param[in] value                      The value of the header field
247         * @exception E_SUCCESS      The method is successful.
248         * @exception E_INVALID_ARG  Either the field is empty or it does not exist.
249         */
250         result SetRequestHeader(const Tizen::Base::String& field, const Tizen::Base::String& value);
251
252         /**
253         * Removes the HTTP header field.
254         *
255         * @since 2.1
256         *
257         * @return        An error code
258         * @param[in] field                      The HTTP header field
259         * @exception E_SUCCESS          The method is successful.
260         * @exception E_INVALID_ARG  Either the field is empty or it does not exist.
261         */
262         result RemoveRequestHeader(const Tizen::Base::String& field);
263
264         /**
265         * Gets the value of the HTTP header field.
266         *
267         * @since 2.1
268         *
269         * @return        The value of the HTTP header field if successful, @n
270         *                        else @c null if there is no HTTP header field
271         * @param[in] field              The HTTP header field
272         */
273         Tizen::Base::String* GetRequestHeaderN(const Tizen::Base::String& field);
274
275 private:
276         /**
277         * This default constructor is intentionally declared as private so that only the platform can create an instance.
278         */
279         DownloadRequest(void);
280
281         friend class _DownloadRequestImpl;
282         class _DownloadRequestImpl * __pDownloadRequestImpl;
283
284 }; // DownloadRequest
285
286 } } // Tizen::Content
287
288 #endif //_FCNT_DOWNLOAD_MANAGER_H_
289