Add DOWNLOAD_ERROR_NOT_SUPPORTED enum
[platform/core/api/url-download.git] / include / download.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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 #ifndef __TIZEN_WEB_DOWNLOAD_H__
18 #define __TIZEN_WEB_DOWNLOAD_H__
19
20 #include <tizen.h>
21 #include <bundle.h>
22
23 #ifndef DEPRECATED
24         #define DEPRECATED __attribute__((deprecated))
25 #endif
26
27 #ifdef __cplusplus
28 extern "C"
29 {
30 #endif
31
32  /**
33  * @addtogroup CAPI_WEB_DOWNLOAD_MODULE
34  * @{
35  */
36
37 /**
38  * @brief Enumeration of error code for URL download
39  */
40 typedef enum
41 {
42         DOWNLOAD_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
43         DOWNLOAD_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
44         DOWNLOAD_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
45         DOWNLOAD_ERROR_NETWORK_UNREACHABLE = TIZEN_ERROR_NETWORK_UNREACHABLE, /**< Network is unreachable */
46         DOWNLOAD_ERROR_CONNECTION_TIMED_OUT = TIZEN_ERROR_CONNECTION_TIME_OUT, /**< Http session time-out */
47         DOWNLOAD_ERROR_NO_SPACE = TIZEN_ERROR_FILE_NO_SPACE_ON_DEVICE, /**< No space left on device */
48         DOWNLOAD_ERROR_FIELD_NOT_FOUND = TIZEN_ERROR_KEY_NOT_AVAILABLE, /**< Specified field not found */
49         DOWNLOAD_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
50         DOWNLOAD_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED,               /**< Not supported */
51         DOWNLOAD_ERROR_INVALID_STATE = TIZEN_ERROR_WEB_CLASS | 0x21, /**< Invalid state */
52         DOWNLOAD_ERROR_CONNECTION_FAILED = TIZEN_ERROR_WEB_CLASS | 0x22, /**< Connection failed */
53         DOWNLOAD_ERROR_INVALID_URL = TIZEN_ERROR_WEB_CLASS | 0x24, /**< Invalid URL */
54         DOWNLOAD_ERROR_INVALID_DESTINATION = TIZEN_ERROR_WEB_CLASS | 0x25, /**< Invalid destination */
55         DOWNLOAD_ERROR_TOO_MANY_DOWNLOADS = TIZEN_ERROR_WEB_CLASS | 0x26, /**< Full of available simultaneous downloads */
56         DOWNLOAD_ERROR_QUEUE_FULL = TIZEN_ERROR_WEB_CLASS | 0x27, /**< Full of available downloading items from server*/
57         DOWNLOAD_ERROR_ALREADY_COMPLETED = TIZEN_ERROR_WEB_CLASS | 0x28, /**< The download is already completed */
58         DOWNLOAD_ERROR_FILE_ALREADY_EXISTS = TIZEN_ERROR_WEB_CLASS | 0x29, /**< It is failed to rename the downloaded file */
59         DOWNLOAD_ERROR_CANNOT_RESUME = TIZEN_ERROR_WEB_CLASS | 0x2a, /**< It cannot resume */
60         DOWNLOAD_ERROR_TOO_MANY_REDIRECTS = TIZEN_ERROR_WEB_CLASS | 0x30, /**< In case of too may redirects from http response header*/
61         DOWNLOAD_ERROR_UNHANDLED_HTTP_CODE = TIZEN_ERROR_WEB_CLASS | 0x31,  /**< The download cannot handle the http status value */
62         DOWNLOAD_ERROR_REQUEST_TIMEOUT = TIZEN_ERROR_WEB_CLASS | 0x32, /**< There are no action after client create a download id*/
63         DOWNLOAD_ERROR_RESPONSE_TIMEOUT = TIZEN_ERROR_WEB_CLASS | 0x33, /**< It does not call start API in some time although the download is created*/
64         DOWNLOAD_ERROR_SYSTEM_DOWN = TIZEN_ERROR_WEB_CLASS | 0x34, /**< There are no response from client after rebooting download daemon*/
65         DOWNLOAD_ERROR_ID_NOT_FOUND = TIZEN_ERROR_WEB_CLASS | 0x35, /**< The download id is not existed in download service module*/
66         DOWNLOAD_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA, /**< No data because the set API is not called */
67         DOWNLOAD_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR , /**< Internal I/O error */
68 } download_error_e;
69
70
71 /**
72  * @brief Enumerations of state of download
73  */
74 typedef enum
75 {
76         DOWNLOAD_STATE_NONE, /**< It is ready to download */
77         DOWNLOAD_STATE_READY, /**< It is ready to download */
78         DOWNLOAD_STATE_QUEUED, /**< It is queued to start downloading */
79         DOWNLOAD_STATE_DOWNLOADING, /**< The download is currently running */
80         DOWNLOAD_STATE_PAUSED, /**< The download is waiting to resume */
81         DOWNLOAD_STATE_COMPLETED, /**< The download is completed. */
82         DOWNLOAD_STATE_FAILED, /**< The download failed. */
83         DOWNLOAD_STATE_CANCELED, /**< User cancel the download item. */
84 } download_state_e;
85
86 /**
87  * @brief Enumerations of network type for download
88  */
89 typedef enum
90 {
91         DOWNLOAD_NETWORK_DATA_NETWORK, /**< Download is available through data network */
92         DOWNLOAD_NETWORK_WIFI, /**< Download is available through WiFi */
93         DOWNLOAD_NETWORK_WIFI_DIRECT, /**< Download is available through WiFi-Direct */
94         DOWNLOAD_NETWORK_ALL /**< Download is available through either data network or WiFi */
95 } download_network_type_e ;
96
97
98 /**
99  * @brief Enumerations of notification type when client want to register
100  * @see #download_set_notification_type()
101  * @see #download_get_notification_type()
102  */
103 typedef enum
104 {
105         DOWNLOAD_NOTIFICATION_TYPE_NONE = 0, /**< Do not register notification */
106         DOWNLOAD_NOTIFICATION_TYPE_COMPLETE_ONLY, /**< For success state and failed state */
107         DOWNLOAD_NOTIFICATION_TYPE_ALL /**< For ongoing state, success state and failed state */
108 } download_notification_type_e;
109
110
111 /**
112  * @brief Enumerations of the type about notification bundle which client want to set when registering notification
113  * @see #download_set_notification_bundle()
114  * @see #download_get_notification_bundle()
115  */
116 typedef enum
117 {
118         DOWNLOAD_NOTIFICATION_BUNDLE_TYPE_ONGOING = 0, /**< For bundle for failed and ongoing notification */
119         DOWNLOAD_NOTIFICATION_BUNDLE_TYPE_COMPLETE, /**< For bundle for completed notification */
120         DOWNLOAD_NOTIFICATION_BUNDLE_TYPE_FAILED /**< For bundle for failed notification*/
121 } download_notification_bundle_type_e;
122
123
124 /**
125  * @brief Called when the download status is changed.
126  *
127  * @param [in] download The download id
128  * @param [in] state The state of download 
129  * @param [in] user_data The user data passed from download_set_state_changed_cb()
130  * @pre download_start()  will cause this callback if you register this callback using download_set_state_changed_cb()
131  * @see download_set_state_changed_cb()
132  * @see download_unset_state_changed_cb()
133  */
134 typedef void (*download_state_changed_cb) (int download_id,
135         download_state_e state, void *user_data);
136
137 /**
138  * @brief Called when the progress of download changes.
139  *
140  * @remarks This callback function is only invoked in the downloading state.
141  * @param [in] download The download id
142  * @param [in] received The size of the data received in bytes
143  * @param [in] user_data The user data passed from download_set_progress_cb()
144  * @pre This callback function is invoked if you register this callback using download_set_progress_cb().
145  * @see download_cancel()
146  * @see download_set_progress_cb()
147  * @see download_unset_progress_cb()
148  */
149 typedef void (*download_progress_cb) (int download_id, unsigned long long received, void *user_data);
150
151 /**
152  * @brief Creates a download id.
153  *
154  * @remarks The @a download is released with download_destroy() by client.\n
155  * @param [out] download A download id to be newly created on success
156  * @return 0 on success, otherwise a negative error value.
157  * @retval #DOWNLOAD_ERROR_NONE Successful
158  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
159  * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
160  * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
161  * @retval #DOWNLOAD_ERROR_QUEUE_FULL Full of queue from download server
162  * @post The download state will be #DOWNLOAD_STATE_READY
163  * @see download_destroy()
164  */
165 int download_create(int *download_id);
166
167
168 /**
169  * @brief Unload all data concerning a download id from memory.
170  *
171  * @detail After calling this API, a download ID is existed at DB in certain time.\n
172  * Within that time, it is able to use the other API with the download ID.
173  * @remark If #DOWNLOAD_ERROR_ID_NOT_FOUND is returned, it means that the download ID is completely removed from DB.
174  * @param [in] download The download id
175  * @return 0 on success, otherwise a negative error value.
176  * @retval #DOWNLOAD_ERROR_NONE Successful
177  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
178  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
179  * @see download_create()
180  */
181 int download_destroy(int download_id);
182
183
184 /**
185  * @brief Sets the URL to download.
186  *
187  * @remarks This function should be called before downloading (See download_start())
188  * @param [in] download The download id
189  * @param [in] url The URL to download \n
190  *  If the @a url is NULL, it clears the previous value.
191  * @return 0 on success, otherwise a negative error value.
192  * @retval #DOWNLOAD_ERROR_NONE Successful
193  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
194  * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
195  * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
196  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
197  * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
198  * @see download_get_url()
199  */
200 int download_set_url(int download_id, const char *url);
201
202
203 /**
204  * @brief Gets the URL to download.
205  *
206  * @remarks The @a url must be released with free() by you.
207  * @param [in] download The download id
208  * @param [out] url The URL to download
209  * @return 0 on success, otherwise a negative error value.
210  * @retval #DOWNLOAD_ERROR_NONE Successful
211  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
212  * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
213  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
214  * @see download_set_url()
215  */
216 int download_get_url(int download_id, char **url);
217
218
219 /**
220  * @brief Sets the allowed network type for the downloaded file
221  *
222  * @details The file can be downloaded only under the allowed network.
223  *
224  * @remarks This function should be called before downloading (see download_start())
225  * @param [in] download The download id
226  * @param [in] net_type The network type which the client prefer
227  * @return 0 on success, otherwise a negative error value.
228  * @retval #DOWNLOAD_ERROR_NONE Successful
229  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
230  * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
231  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
232  * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
233  * @see download_get_network_type()
234  * @see #download_network_type_e
235  */
236 int download_set_network_type(int download_id, download_network_type_e net_type);
237
238
239 /**
240  * @brief Gets the network type for the downloaded file
241  *
242  * @param [in] download The download id
243  * @param [out] net_type The network type which is defined by client. 
244  * @return 0 on success, otherwise a negative error value.
245  * @retval #DOWNLOAD_ERROR_NONE Successful
246  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
247  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
248  * @see download_set_network_type()
249  * @see #download_network_type_e
250  */
251 int download_get_network_type(int download_id, download_network_type_e *net_type);
252
253
254 /**
255  * @brief Sets the destination for the downloaded file.
256  *
257  * @details The file will be downloaded to the specified destination.
258  * The downloaded file is saved to an auto-generated file name in the destination.
259  * If the destination is not specified, the file will be downloaded to default storage. (See the @ref CAPI_STORAGE_MODULE API)
260  *
261  * @remarks This function should be called before downloading (see download_start())
262  * @param [in] download The download id
263  * @param [in] path The absolute path to the downloaded file
264  *  If the @a path is NULL, it clears the previous value.
265  * @return 0 on success, otherwise a negative error value.
266  * @retval #DOWNLOAD_ERROR_NONE Successful
267  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
268  * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
269  * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
270  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
271  * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
272  * @see download_get_destination()
273  */
274 int download_set_destination(int download_id, const char *path);
275
276
277 /**
278  * @brief Gets the destination for the downloaded file.
279  *
280  * @remarks The @a path must be released with free() by you.
281  * @param [in] download The download id
282  * @param [out] path The absolute path to the downloaded file
283  * @return 0 on success, otherwise a negative error value.
284  * @retval #DOWNLOAD_ERROR_NONE Successful
285  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
286  * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
287  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
288  * @see download_set_destination()
289  */
290 int download_get_destination(int download_id, char **path);
291
292
293 /**
294  * @brief Sets the name for the downloaded file.
295  *
296  * @details The file will be downloaded to the specified destination as the given file name.
297  * If the file name is not specified, the downloaded file is saved to an auto-generated file name in the destination.
298  *
299  * @remarks This function should be called before downloading (see download_start())
300  * @param [in] download The download id
301  * @param [in] file_name The file name for the downloaded file
302  *  If the @a name is NULL, it clears the previous value.
303  * @return 0 on success, otherwise a negative error value.
304  * @retval #DOWNLOAD_ERROR_NONE Successful
305  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
306  * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
307  * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
308  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
309  * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
310  * @see download_get_file_name()
311  */
312 int download_set_file_name(int download_id, const char *file_name);
313
314
315 /**
316  * @brief Gets the name which is set by user.
317  *
318  * @details If user do not set any name, it returns NULL.
319  *
320  * @remarks The @a file_name must be released with free() by you.
321  * @param [in] download The download id
322  * @param [out] file_name The file name which is set by user.
323  * @return 0 on success, otherwise a negative error value.
324  * @retval #DOWNLOAD_ERROR_NONE Successful
325  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
326  * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
327  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
328  * @see download_set_file_name()
329  */
330 int download_get_file_name(int download_id, char **file_name);
331
332
333 /**
334  * @brief Sets the option value to register notification messages by download service module.
335  * @details The three types of notification message can be posted. Those are completion, failed and ongoing type.
336  * When the notification message of failed and ongoing types from the notification tray, \n
337  * the client application which call this API will be launched. \n
338  *
339  * @remarks The extra param should be set together (See download_set_notification_extra_param()). \n
340  * The downloading and failed notification can be registered only if the extra param for notification message is set. \n
341  * If it is not, the client application can not know who request to launch itself. \n
342  * It should be necessary to understand the action operation of notification click event.
343  * @remarks If the competition notification message is selected from the notification tray,\n
344  * the proper player application is launched automatically.
345  * @remarks The default value is false. So if the client don't enable it, any notification messages are not registered.
346  * @remarks This function should be called before downloading (See download_start())
347  * @param[in] download The download id
348  * @param[in] enable The boolean type. The true or false value is available.
349  * @return 0 on success, otherwise a negative error value.
350  * @retval #DOWNLOAD_ERROR_NONE Successful
351  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
352  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
353  * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
354  * @see download_get_notification()
355  * @see service_get_operation()
356  * @deprecated This API can be replaced with download_set_notification_type()
357  @code
358  int ret = 0;
359  //ret = download_set_notification(id, true);
360  ret = download_set_notification_type(id, DOWNLOAD_NOTIFICATION_TYPE_ALL);
361  //ret = download_set_notification(id, false);
362  ret = download_set_notification_type(id, DOWNLOAD_NOTIFICATION_TYPE_NONE);
363  @endcode
364  */
365 DEPRECATED int download_set_notification(int download_id, bool enable);
366
367 /**
368  * @brief Gets the option value to register notification messages by download service module.
369  * @param[in] download The download id
370  * @param[out] enable The boolean type. The true or false value is returned
371  * @return 0 on success, otherwise a negative error value.
372  * @retval #DOWNLOAD_ERROR_NONE Successful
373  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
374  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
375  * @see download_set_notification()
376  * @deprecated This API can be replaced with download_get_notification_type()
377  @code
378  int ret = 0;
379  bool val = 0;
380  download_notification_type_e type;
381  //ret = download_get_notification(id, &val);
382  ret = download_get_notification_type(id, &type);
383  @endcode
384  */
385 DEPRECATED int download_get_notification(int download_id, bool *enable);
386
387 /**
388  * @brief Sets the extra param data which pass by application service data when notification message is clicked
389  * @details When client set the extra param data for ongoing notification action, \n
390  * it can get the data through service_get_extra_data() when client application is launched by notification action.
391  *
392  * @remarks This function should be called before downloading (See download_start())
393  *
394  * @param[in] download The download id
395  * @param[in] key The character pointer type. The extra param has a pair of key and value
396  * @param[in] values The character pointer array type. The extra param has a pair of key and value array
397  * @param[in] length The length of value array
398  * @return 0 on success, otherwise a negative error value.
399  * @retval #DOWNLOAD_ERROR_NONE Successful
400  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
401  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
402  * @see download_get_notification_extra_param()
403  * @see download_remove_notification_extra_param()
404  * @deprecated This API can be replaced with download_set_notification_bundle()
405  @code
406  #include <bundle.h>
407  int ret = 0;
408  // char *value[1] = ("12345",};
409  //ret = download_add_notification_extra_param(id, "specific_id", value[0], 1);
410  bundle *b = bundle_create();
411  char buff[MAX_BUF_LEN] = {0,};
412  appsvc_set_pkgname(b, "com.samsung.test-app");
413  appsvc_add_data(b, "specific_id", "12345");
414  ret = download_set_notification_bundle(id, DOWNLOAD_NOTIFICATION_BUNDLE_TYPE_ALL, b);
415  bundle_free(b);
416  @endcode
417  */
418 DEPRECATED int download_add_notification_extra_param(int download_id, const char *key, const char **values, const unsigned int length);
419
420 /**
421  * @brief Remove the extra param data which pass by application service data when notification message is clicked
422  *
423  * @remarks This function should be called before downloading (See download_start())
424  *
425  * @param[in] download The download id
426  * @param[in] key The character pointer type. The extra param has a pair of key and value
427  * @return 0 on success, otherwise a negative error value.
428  * @retval #DOWNLOAD_ERROR_NONE Successful
429  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
430  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
431  * @see download_add_notification_extra_param()
432  * @see download_get_notification_extra_param()
433  */
434 DEPRECATED int download_remove_notification_extra_param(int download_id, const char *key);
435
436 /**
437  * @brief Gets the extra param value to set by download_set_notification_extra_param
438  * @param[in] download The download id
439  * @param[out] key The character pointer type. The extra param has a pair of key and value
440  * @param[out] values param The character pointer array type. The extra param has a pair of key and value array
441  * @param[out] length The length of value array
442  * @return 0 on success, otherwise a negative error value.
443  * @retval #DOWNLOAD_ERROR_NONE Successful
444  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
445  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
446  * @see download_set_notification_extra_param()
447  */
448 DEPRECATED int download_get_notification_extra_param(int download_id, const char *key, char ***values, unsigned int *length);
449
450 /**
451  * @brief Gets the absolute path to save the downloaded file
452  *
453  * @remarks This function returns #DOWNLOAD_ERROR_INVALID_STATE if the download is not completed. \n
454  * The @a path must be released with free() by you.
455  * @param [in] download The download id
456  * @param [out] path The absolute path to the downloaded file
457  * @return 0 on success, otherwise a negative error value.
458  * @retval #DOWNLOAD_ERROR_NONE Successful
459  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
460  * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
461  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
462  * @pre The download state must be #DOWNLOAD_STATE_COMPLETED.
463  * @see download_set_file_name()
464  * @see download_set_destination()
465  */
466 int download_get_downloaded_file_path(int download_id, char **path);
467
468
469 /**
470  * @brief Gets the mime type for downloading a content.
471  *
472  * @remarks This function returns #DOWNLOAD_ERROR_INVALID_STATE if the download has not been started. \n
473  * The @a mime_type must be released with free() by you.
474  * @param [in] download The download id
475  * @param [out] mime_type The MIME type of the downloaded file
476  * @return 0 on success, otherwise a negative error value.
477  * @retval #DOWNLOAD_ERROR_NONE Successful
478  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
479  * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
480  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
481  * @see download_set_file_name()
482  * @see download_set_destination()
483  * @see download_get_downloaded_file_path()
484  */
485 int download_get_mime_type(int download_id, char **mime_type);
486
487
488 /**
489  * @brief Sets the option for auto download.
490  * @details If this option is enabled, \n
491  *  the previous downloading item is restarted automatically as soon as the download daemon is restarted. \n
492  * And the download progress keep going after the client process is terminated.  \n
493  * @remarks The client should call download_set_notification() and download_set_notification_extra_param() after call this API. \n
494  *  If it is not, user do not receive the download result in case the client process is not alive.
495  * @remarks The default value is false.
496  * @param[in] download The download id
497  * @param[in] enable The boolean value for auto download which is defined by client.
498  * @return 0 on success, otherwise a negative error value.
499  * @retval #DOWNLOAD_ERROR_NONE Successful
500  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
501  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
502  * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
503  * @see download_get_auto_download()
504  * @see download_set_notification()
505  * @see download_set_notification_extra_param()
506  *
507  */
508 int download_set_auto_download(int download_id, bool enable);
509
510
511 /**
512  * @brief Gets the value of option for auto download.
513  *
514  * @param [in] download The download id
515  * @param [out] enable The boolean value for auto download which is defined by client.
516  * @return 0 on success, otherwise a negative error value.
517  * @retval #DOWNLOAD_ERROR_NONE Successful
518  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
519  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
520  * @see download_set_auto_download()
521  */
522 int download_get_auto_download(int download_id, bool *enable);
523
524
525 /**
526  * @brief Adds an HTTP header field to the download request
527  *
528  * @details The given HTTP header field will be included with the HTTP request of the download request. \n
529  * Refer to the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2">HTTP/1.1: HTTP Message Headers</a>
530  * @remarks This function should be called before downloading (see download_start()) \n
531  * This function replaces any existing value for the given key. \n
532  * This function returns #DOWNLOAD_ERROR_INVALID_PARAMETER if field or value is zero-length string. 
533  * @param [in] download The download id
534  * @param [in] field The name of the HTTP header field
535  * @param [in] value The value associated with given field
536  * @return 0 on success, otherwise a negative error value.
537  * @retval #DOWNLOAD_ERROR_NONE Successful
538  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
539  * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
540  * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
541  * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
542  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
543  * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
544  * @see download_get_http_header_field()
545  * @see download_remove_http_header_field()
546  */
547 int download_add_http_header_field(int download_id, const char *field, const char *value);
548
549
550 /**
551  * @brief Gets the value associated with given HTTP header field from the download
552  *
553  * @remarks This function returns #DOWNLOAD_ERROR_INVALID_PARAMETER if field is zero-length string. \n
554  * The @a value must be released with free() by you.
555  * @param [in] download The download id
556  * @param [in] field The name of the HTTP header field
557  * @param [out] value The value associated with given field
558  * @return 0 on success, otherwise a negative error value.
559  * @retval #DOWNLOAD_ERROR_NONE Successful
560  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
561  * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
562  * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
563  * @retval #DOWNLOAD_ERROR_FIELD_NOT_FOUND Specified field not found
564  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
565  * @see download_add_http_header_field()
566  * @see download_remove_http_header_field()
567  */
568 int download_get_http_header_field(int download_id, const char *field, char **value);
569
570 /**
571  * @brief Gets all of the field added to the download request
572  *
573  * @remarks The @a value must be released with free() by you.
574  * @param [in] download The download id
575  * @param [out] the array of the HTTP header fields
576  * @param [out] the number of the HTTP header fields
577  * @return 0 on success, otherwise a negative error value.
578  * @retval #DOWNLOAD_ERROR_NONE Successful
579  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
580  * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
581  * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
582  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
583  * @see download_add_http_header_field()
584  * @see download_remove_http_header_field()
585  */
586 int download_get_http_header_field_list(int download_id, char ***fields, int *length);
587
588 /**
589  * @brief Removes the given HTTP header field from the download
590  *
591  * @remarks This function should be called before downloading (see download_start()) \n
592  * This function returns #DOWNLOAD_ERROR_INVALID_PARAMETER if field is zero-length string. 
593  * @param [in] download The download id
594  * @param [in] field The name of the HTTP header field
595  * @return 0 on success, otherwise a negative error value.
596  * @retval #DOWNLOAD_ERROR_NONE Successful
597  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
598  * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
599  * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
600  * @retval #DOWNLOAD_ERROR_FIELD_NOT_FOUND Specified field not found
601  * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
602  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
603  * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
604  * @see download_add_http_header_field()
605  * @see download_get_http_header_field()
606  */
607 int download_remove_http_header_field(int download_id, const char *field);
608
609
610 /**
611  * @brief Registers a callback function to be invoked when the download state is changed.
612  *
613  * @remarks This function should be called before downloading (see download_start())
614  * @param [in] download The download id
615  * @param [in] callback The callback function to register
616  * @param [in] user_data The user data to be passed to the callback function
617  * @return 0 on success, otherwise a negative error value.
618  * @retval #DOWNLOAD_ERROR_NONE Successful
619  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
620  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
621  * @post download_state_changed_cb() will be invoked.
622  * @see download_unset_state_changed_cb()
623  * @see download_state_changed_cb()
624 */
625 int download_set_state_changed_cb(int download_id, download_state_changed_cb callback, void* user_data);
626
627
628 /**
629  * @brief Unregisters the callback function.
630  *
631  * @remarks This function should be called before downloading (see download_start())
632  * @param [in] download The download id
633  * @return 0 on success, otherwise a negative error value.
634  * @retval #DOWNLOAD_ERROR_NONE Successful
635  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
636  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
637  * @see download_set_state_changed_cb()
638  * @see download_state_changed_cb()
639 */
640 int download_unset_state_changed_cb(int download_id);
641
642
643 /**
644  * @brief Registers a callback function to be invoked when progress of the download changes
645  *
646  * @remarks This function should be called before downloading (see download_start())
647  * @param [in] download The download id
648  * @param [in] callback The callback function to register
649  * @param [in] user_data The user data to be passed to the callback function
650  * @return 0 on success, otherwise a negative error value.
651  * @retval #DOWNLOAD_ERROR_NONE Successful
652  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
653  * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
654  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
655  * @post download_progress_cb() will be invoked.
656  * @see download_unset_progress_cb()
657  * @see download_progress_cb()
658 */
659 int download_set_progress_cb(int download_id, download_progress_cb callback, void *user_data);
660
661
662 /**
663  * @brief Unregisters the callback function.
664  *
665  * @remarks This function should be called before downloading (see download_start())
666  * @param [in] download The download id
667  * @return 0 on success, otherwise a negative error value.
668  * @retval #DOWNLOAD_ERROR_NONE Successful
669  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
670  * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
671  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
672  * @see download_set_progress_cb()
673  * @see download_progress_cb()
674 */
675 int download_unset_progress_cb(int download_id);
676
677
678 /**
679  * @brief Starts or resumes the download, asynchronously.
680  *
681  * @details This function starts to download the current URL, or resumes the download if paused.
682  *
683  * @remarks The URL is the mandatory information to start the download.
684  * @remarks It should call download_set_progress_cb() and download_set_state_changed_cb() again \n
685  *  after the client process is restarted or download_destry() is called
686  * @param [in] download The download id
687  * @return 0 on success, otherwise a negative error value.
688  * @retval #DOWNLOAD_ERROR_NONE Successful
689  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
690  * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
691  * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
692  * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
693  * @retval #DOWNLOAD_ERROR_URL Invalid URL
694  * @retval #DOWNLOAD_ERROR_DESTINATION Invalid destination
695  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
696  * @retval #DOWNLOAD_ERROR_QUEUE_FULL Full of queue from download server
697  * @pre The download state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_PAUSED, #DOWNLOAD_STATE_CANCELED, #DOWNLOAD_STATE_FAILED.
698  * @post The download state will be #DOWNLOAD_STATE_QUEUED or #DOWNLOAD_STATE_DOWNLOADING
699  * @see download_set_url()
700  * @see download_pause()
701  * @see download_cancel()
702  */
703 int download_start(int download_id);
704
705
706 /**
707  * @brief Pauses the download, asynchronously.
708  *
709  * @remarks The paused download can be restarted with download_start() or canceled with download_cancel()
710  * @param [in] download The download id
711  * @return 0 on success, otherwise a negative error value.
712  * @retval #DOWNLOAD_ERROR_NONE Successful
713  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
714  * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
715  * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
716  * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
717  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
718  * @pre The download state must be #DOWNLOAD_STATE_DOWNLOADING.
719  * @post The download state will be #DOWNLOAD_STATE_PAUSED.
720  * @see download_start()
721  * @see download_cancel()
722  */
723 int download_pause(int download_id);
724
725
726 /**
727  * @brief Cancel the download, asynchronously.
728  *
729  * @details This function cancels the running download and its state will be #DOWNLOAD_STATE_READY
730  * @remarks The canceled download can be restarted with download_start().
731  * @param [in] download The download id
732  * @return 0 on success, otherwise a negative error value.
733  * @retval #DOWNLOAD_ERROR_NONE Successful
734  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
735  * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
736  * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
737  * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
738  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
739  * @pre The download state must be #DOWNLOAD_STATE_QUEUED, #DOWNLOAD_STATE_DOWNLOADING, #DOWNLOAD_STATE_PAUSED.
740  * @post The download state will be #DOWNLOAD_STATE_CANCELED.
741  * @see download_start()
742  */
743 int download_cancel(int download_id);
744
745
746 /**
747  * @brief Gets the download's current state.
748  *
749  * @param [in] download The download id
750  * @param [out] state The current state of the download
751  * @return 0 on success, otherwise a negative error value.
752  * @retval #DOWNLOAD_ERROR_NONE Successful
753  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
754  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
755  * @see #download_state_e
756  */
757 int download_get_state(int download_id, download_state_e *state);
758
759
760 /**
761  * @brief Gets the full path of temporary file for downloading a content.
762  *
763  * @param [in] download The download id
764  * @param [out] temp_path The full path of temporary file 
765  * @return 0 on success, otherwise a negative error value.
766  * @retval #DOWNLOAD_ERROR_NONE Successful
767  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
768  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
769  * @pre The download state must be one of state after #DOWNLOAD_STATE_DOWNLOADING.
770  * @see #download_set_state_changed_cb()
771  * @see #download_unset_state_changed_cb()
772  * @see download_start()
773  */
774 int download_get_temp_path(int download_id, char **temp_path);
775
776
777 /**
778  * @brief Gets the content name for downloading a file.
779  *
780  * @details This can be defined with reference of HTTP response header data.
781  * The content name can be received when HTTP response header is received.
782  *
783  * @param [in] download The download id
784  * @param [out] content_name The content name for displaying to user
785  * @return 0 on success, otherwise a negative error value.
786  * @retval #DOWNLOAD_ERROR_NONE Successful
787  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
788  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
789  * @pre The download state must be one of state after #DOWNLOAD_STATE_DOWNLOADING.
790  * @see #download_set_state_changed_cb()
791  * @see #download_unset_state_changed_cb()
792  * @see download_start()
793  */
794 int download_get_content_name(int download_id, char **content_name);
795
796
797 /**
798  * @brief Gets the total size for downloading a content.
799  *
800  * @details This data receive from content server. If the content sever don't send total size of the content, the value set as zero.
801  *
802  * @param [in] download The download id
803  * @param [out] content_size The content size for displaying to user
804  * @return 0 on success, otherwise a negative error value.
805  * @retval #DOWNLOAD_ERROR_NONE Successful
806  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
807  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
808  * @pre The download state must be one of state after #DOWNLOAD_STATE_DOWNLOADING.
809  * @see #download_set_state_changed_cb()
810  * @see #download_unset_state_changed_cb()
811  * @see download_start()
812  */
813 int download_get_content_size(int download_id, unsigned long long *content_size);
814
815
816 /**
817  * @brief Gets the error value when the download is failed.
818  *
819  * @param [in] download The download id
820  * @param [out] error The error value 
821  * @return 0 on success, otherwise a negative error value.
822  * @retval #DOWNLOAD_ERROR_NONE Successful
823  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
824  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
825  * @pre The download state must be #DOWNLOAD_STATE_FAILED.
826  * @pre The download state must be #DOWNLOAD_STATE_CANCELED.
827  * @see #download_set_state_changed_cb()
828  * @see #download_unset_state_changed_cb()
829  * @see download_start()
830  * @see download_error_e
831  */
832 int download_get_error(int download_id, download_error_e *error);
833
834
835 /**
836  * @brief Gets the http status code when the download error is happened.
837  *
838  * @param [in] download The download id
839  * @param [out] http_status The http status code which is defined in RFC 2616 
840  * @return 0 on success, otherwise a negative error value.
841  * @retval #DOWNLOAD_ERROR_NONE Successful
842  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
843  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
844  * @pre The download state must be #DOWNLOAD_STATE_FAILED.
845  * @see #download_set_download_status_cb()
846  * @see #download_unset_download_status_cb()
847  * @see download_start()
848  */
849 int download_get_http_status(int download_id, int *http_status);
850
851 /**
852  * @brief Sets bundle data to register notification messages.
853  * @details The three types of notification message can be posted. Those are completion, failed and ongoing type.
854  *
855  * @remarks When the notification message is clicked, the action is decided by bundle data. \n
856  * If the bundle data is not set, the following default operation is executed when the notification message is clicked. \n
857  * 1) Download completed state : The viewer application is executed according to extension name of downloaded content. \n
858  * 2) Download failed state and ongoing state : The client application is executed. \n
859  * @remarks This function should be called before starting download.
860  * @remarks The bundle data MUST BE FREED by client when it is not used any more.
861  * @param[in] download The download id
862  * @param[in] type The enumeration type. See #download_notification_bundle_type_e.
863  * @param[in] bundle The bundle pointer value.
864  * @return 0 on success, otherwise a negative error value.
865  * @retval #DOWNLOAD_ERROR_NONE Successful
866  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
867  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
868  * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
869  * @see download_set_notification_type()
870  * @see download_get_notification_bundle()
871  */
872 int download_set_notification_bundle(int download_id, download_notification_bundle_type_e type, bundle *b);
873
874 /**
875  * @brief Get the bundle data to register notification messages which is set in download_set_notification_bundle().
876  *
877  * @details When the notification message is clicked, the action is decided by bundle data. \n
878  * @param[in] download The download id
879  * @param[in] type The enumeration type. See #download_notification_bundle_type_e.
880  * @param[out] bundle The bundle pointer value.
881  * @remarks The bundle data MUST BE FREED by client when it is not used any more.
882  * @return 0 on success, otherwise a negative error value.
883  * @retval #DOWNLOAD_ERROR_NONE Successful
884  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
885  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
886  * @retval #DOWNLOAD_ERROR_NO_DATA the bundle have not been set
887  * @see download_set_notification_bundle()
888  */
889 int download_get_notification_bundle(int download_id, download_notification_bundle_type_e type, bundle **b);
890
891 /**
892  * @brief Set the title of notification.
893  *
894  * @details When registering notification, the title is displayed at title area of notification message
895  *
896  * @param [in] download The download id
897  * @param [in] title The title for displaying to user
898  * @return 0 on success, otherwise a negative error value.
899  * @retval #DOWNLOAD_ERROR_NONE Successful
900  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
901  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
902  * @pre If the notification option is not enable, this title is not shown to user
903  * @see #download_set_notification_type()
904  * @see #download_get_notification_title()
905   */
906 int download_set_notification_title(int download_id, const char *title);
907
908 /**
909  * @brief Gets the title of notification when set in #download_set_notification_title()
910  *
911  * @details When registering notification, the title is displayed at title area of notification message
912  *
913  * @param [in] download The download id
914  * @param [out] title The title for displaying to user
915  * @return 0 on success, otherwise a negative error value.
916  * @retval #DOWNLOAD_ERROR_NONE Successful
917  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
918  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
919  * @retval #DOWNLOAD_ERROR_NO_DATA the title have not been set
920  * @pre It can get the title value before calling this API.
921  * @see #download_set_notification_title()
922   */
923 int download_get_notification_title(int download_id, char **title);
924
925 /**
926  * @brief Set the description of notification.
927  *
928  * @details When registering notification, the description is displayed at description area of notification message
929  *
930  * @param [in] download The download id
931  * @param [in] description The description for displaying to user
932  * @return 0 on success, otherwise a negative error value.
933  * @retval #DOWNLOAD_ERROR_NONE Successful
934  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
935  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
936  * @pre If the notification option is not enable, this description is not shown to user
937  * @see #download_set_notification_type()
938  * @see #download_get_notification_description()
939   */
940 int download_set_notification_description(int download_id, const char *description);
941
942 /**
943  * @brief Gets the description of notification when set in #download_set_notification_description()
944  *
945  * @details When registering notification, the description is displayed at description area of notification message
946  *
947  * @param [in] download The download id
948  * @param [out] description The description for displaying to user
949  * @return 0 on success, otherwise a negative error value.
950  * @retval #DOWNLOAD_ERROR_NONE Successful
951  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
952  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
953  * @retval #DOWNLOAD_ERROR_NO_DATA the description have not been set
954  * @pre It can get the title value before calling this API.
955  * @see #download_set_notification_description()
956   */
957 int download_get_notification_description(int download_id, char **description);
958
959 /**
960  * @brief Sets the option value to register notification messages.
961  * @details The three types of notification message can be posted. Those are completion, failed and ongoing type.
962  *
963  * @remarks When the notification message is clicked, the action is decided by bundle data from download_set_notification_bundle(). \n
964  * If the bundle data is not set, the following default operation is executed when the notification message is clicked. \n
965  * 1) Download completed state : The viewer application is executed according to extension name of downloaded content. \n
966  * 2) Download failed state and ongoing state : The client application is executed. \n
967  * @remarks The default type is #DOWNLOAD_NOTIFICATION_TYPE_NONE.
968  * @remarks This function should be called before starting download.
969  * @param[in] download The download id
970  * @param[in] type The enumeration type. See #download_notification_type_e.
971  * @return 0 on success, otherwise a negative error value.
972  * @retval #DOWNLOAD_ERROR_NONE Successful
973  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
974  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
975  * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
976  * @see download_set_notification_bundle()
977  * @see download_get_notification_type()
978  */
979 int download_set_notification_type(int download_id, download_notification_type_e type);
980
981 /**
982  * @brief Get the option value to register notification messages which is set in download_set_notification_type().
983  *
984  * @remarks When the notification message is clicked, the action is decided by bundle data from download_set_notification_bundle(). \n
985  * @remarks The default type is #DOWNLOAD_NOTIFICATION_TYPE_NONE.
986  * @param[in] download The download id
987  * @param[out] type The enumeration type. See #download_notification_type_e.
988  * @return 0 on success, otherwise a negative error value.
989  * @retval #DOWNLOAD_ERROR_NONE Successful
990  * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
991  * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
992  * @see download_set_notification_type()
993  */
994 int download_get_notification_type(int download_id, download_notification_type_e *type);
995
996 /**
997  * @}
998  */
999
1000 #ifdef __cplusplus
1001 }
1002 #endif
1003
1004 #endif /* __TIZEN_WEB_DOWNLOAD_H__ */