2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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 #ifndef __TIZEN_WEB_DOWNLOAD_H__
18 #define __TIZEN_WEB_DOWNLOAD_H__
24 #define DEPRECATED __attribute__((deprecated))
33 * @addtogroup CAPI_WEB_DOWNLOAD_MODULE
38 * @brief Enumeration of error code for URL download
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_INVALID_NETWORK_TYPE = TIZEN_ERROR_DOWNLOAD | 0x36, /**< Network bonding is set but network type is not set as DOWNLOAD_NETWORK_ALL*/
67 DOWNLOAD_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA, /**< No data because the set API is not called */
68 DOWNLOAD_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR , /**< Internal I/O error */
73 * @brief Enumerations of state of download
77 DOWNLOAD_STATE_NONE, /**< It is ready to download */
78 DOWNLOAD_STATE_READY, /**< It is ready to download */
79 DOWNLOAD_STATE_QUEUED, /**< It is queued to start downloading */
80 DOWNLOAD_STATE_DOWNLOADING, /**< The download is currently running */
81 DOWNLOAD_STATE_PAUSED, /**< The download is waiting to resume */
82 DOWNLOAD_STATE_COMPLETED, /**< The download is completed. */
83 DOWNLOAD_STATE_FAILED, /**< The download failed. */
84 DOWNLOAD_STATE_CANCELED, /**< User cancel the download item. */
88 * @brief Enumerations of network type for download
92 DOWNLOAD_NETWORK_DATA_NETWORK, /**< Download is available through data network */
93 DOWNLOAD_NETWORK_WIFI, /**< Download is available through WiFi */
94 DOWNLOAD_NETWORK_WIFI_DIRECT, /**< Download is available through WiFi-Direct */
95 DOWNLOAD_NETWORK_ALL /**< Download is available through either data network or WiFi */
96 } download_network_type_e ;
100 * @brief Enumerations of notification type when client want to register
101 * @see #download_set_notification_type()
102 * @see #download_get_notification_type()
106 DOWNLOAD_NOTIFICATION_TYPE_NONE = 0, /**< Do not register notification */
107 DOWNLOAD_NOTIFICATION_TYPE_COMPLETE_ONLY, /**< For success state and failed state */
108 DOWNLOAD_NOTIFICATION_TYPE_ALL /**< For ongoing state, success state and failed state */
109 } download_notification_type_e;
113 * @brief Enumerations of the type about notification bundle which client want to set when registering notification
114 * @see #download_set_notification_bundle()
115 * @see #download_get_notification_bundle()
119 DOWNLOAD_NOTIFICATION_BUNDLE_TYPE_ONGOING = 0, /**< For bundle for failed and ongoing notification */
120 DOWNLOAD_NOTIFICATION_BUNDLE_TYPE_COMPLETE, /**< For bundle for completed notification */
121 DOWNLOAD_NOTIFICATION_BUNDLE_TYPE_FAILED /**< For bundle for failed notification*/
122 } download_notification_bundle_type_e;
126 * @brief Called when the download status is changed.
128 * @param [in] download The download id
129 * @param [in] state The state of download
130 * @param [in] user_data The user data passed from download_set_state_changed_cb()
131 * @pre download_start() will cause this callback if you register this callback using download_set_state_changed_cb()
132 * @see download_set_state_changed_cb()
133 * @see download_unset_state_changed_cb()
135 typedef void (*download_state_changed_cb) (int download_id,
136 download_state_e state, void *user_data);
139 * @brief Called when the progress of download changes.
141 * @remarks This callback function is only invoked in the downloading state.
142 * @param [in] download The download id
143 * @param [in] received The size of the data received in bytes
144 * @param [in] user_data The user data passed from download_set_progress_cb()
145 * @pre This callback function is invoked if you register this callback using download_set_progress_cb().
146 * @see download_cancel()
147 * @see download_set_progress_cb()
148 * @see download_unset_progress_cb()
150 typedef void (*download_progress_cb) (int download_id, unsigned long long received, void *user_data);
153 * @brief Creates a download id.
155 * @remarks The @a download is released with download_destroy() by client.\n
156 * @param [out] download A download id to be newly created on success
157 * @return 0 on success, otherwise a negative error value.
158 * @retval #DOWNLOAD_ERROR_NONE Successful
159 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
160 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
161 * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
162 * @retval #DOWNLOAD_ERROR_QUEUE_FULL Full of queue from download server
163 * @post The download state will be #DOWNLOAD_STATE_READY
164 * @see download_destroy()
166 int download_create(int *download_id);
170 * @brief Unload all data concerning a download id from memory.
172 * @detail After calling this API, a download ID is existed at DB in certain time.\n
173 * Within that time, it is able to use the other API with the download ID.
174 * @remark If #DOWNLOAD_ERROR_ID_NOT_FOUND is returned, it means that the download ID is completely removed from DB.
175 * @param [in] download The download id
176 * @return 0 on success, otherwise a negative error value.
177 * @retval #DOWNLOAD_ERROR_NONE Successful
178 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
179 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
180 * @see download_create()
182 int download_destroy(int download_id);
186 * @brief Sets the URL to download.
188 * @remarks This function should be called before downloading (See download_start())
189 * @param [in] download The download id
190 * @param [in] url The URL to download \n
191 * If the @a url is NULL, it clears the previous value.
192 * @return 0 on success, otherwise a negative error value.
193 * @retval #DOWNLOAD_ERROR_NONE Successful
194 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
195 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
196 * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
197 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
198 * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
199 * @see download_get_url()
201 int download_set_url(int download_id, const char *url);
205 * @brief Gets the URL to download.
207 * @remarks The @a url must be released with free() by you.
208 * @param [in] download The download id
209 * @param [out] url The URL to download
210 * @return 0 on success, otherwise a negative error value.
211 * @retval #DOWNLOAD_ERROR_NONE Successful
212 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
213 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
214 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
215 * @see download_set_url()
217 int download_get_url(int download_id, char **url);
221 * @brief Sets the allowed network type for the downloaded file
223 * @details The file can be downloaded only under the allowed network.
225 * @remarks This function should be called before downloading (see download_start())
226 * @param [in] download The download id
227 * @param [in] net_type The network type which the client prefer
228 * @return 0 on success, otherwise a negative error value.
229 * @retval #DOWNLOAD_ERROR_NONE Successful
230 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
231 * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
232 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
233 * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
234 * @see download_get_network_type()
235 * @see #download_network_type_e
237 int download_set_network_type(int download_id, download_network_type_e net_type);
241 * @brief Gets the network type for the downloaded file
243 * @param [in] download The download id
244 * @param [out] net_type The network type which is defined by client.
245 * @return 0 on success, otherwise a negative error value.
246 * @retval #DOWNLOAD_ERROR_NONE Successful
247 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
248 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
249 * @see download_set_network_type()
250 * @see #download_network_type_e
252 int download_get_network_type(int download_id, download_network_type_e *net_type);
256 * @brief Sets the destination for the downloaded file.
258 * @details The file will be downloaded to the specified destination.
259 * The downloaded file is saved to an auto-generated file name in the destination.
260 * If the destination is not specified, the file will be downloaded to default storage. (See the @ref CAPI_STORAGE_MODULE API)
262 * @remarks This function should be called before downloading (see download_start())
263 * @param [in] download The download id
264 * @param [in] path The absolute path to the downloaded file
265 * If the @a path is NULL, it clears the previous value.
266 * @return 0 on success, otherwise a negative error value.
267 * @retval #DOWNLOAD_ERROR_NONE Successful
268 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
269 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
270 * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
271 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
272 * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
273 * @see download_get_destination()
275 int download_set_destination(int download_id, const char *path);
279 * @brief Gets the destination for the downloaded file.
281 * @remarks The @a path must be released with free() by you.
282 * @param [in] download The download id
283 * @param [out] path The absolute path to the downloaded file
284 * @return 0 on success, otherwise a negative error value.
285 * @retval #DOWNLOAD_ERROR_NONE Successful
286 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
287 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
288 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
289 * @see download_set_destination()
291 int download_get_destination(int download_id, char **path);
295 * @brief Sets the name for the downloaded file.
297 * @details The file will be downloaded to the specified destination as the given file name.
298 * If the file name is not specified, the downloaded file is saved to an auto-generated file name in the destination.
300 * @remarks This function should be called before downloading (see download_start())
301 * @param [in] download The download id
302 * @param [in] file_name The file name for the downloaded file
303 * If the @a name is NULL, it clears the previous value.
304 * @return 0 on success, otherwise a negative error value.
305 * @retval #DOWNLOAD_ERROR_NONE Successful
306 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
307 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
308 * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
309 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
310 * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
311 * @see download_get_file_name()
313 int download_set_file_name(int download_id, const char *file_name);
317 * @brief Gets the name which is set by user.
319 * @details If user do not set any name, it returns NULL.
321 * @remarks The @a file_name must be released with free() by you.
322 * @param [in] download The download id
323 * @param [out] file_name The file name which is set by user.
324 * @return 0 on success, otherwise a negative error value.
325 * @retval #DOWNLOAD_ERROR_NONE Successful
326 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
327 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
328 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
329 * @see download_set_file_name()
331 int download_get_file_name(int download_id, char **file_name);
335 * @brief Sets the option value to register notification messages by download service module.
336 * @details The three types of notification message can be posted. Those are completion, failed and ongoing type.
337 * When the notification message of failed and ongoing types from the notification tray, \n
338 * the client application which call this API will be launched. \n
340 * @remarks The extra param should be set together (See download_set_notification_extra_param()). \n
341 * The downloading and failed notification can be registered only if the extra param for notification message is set. \n
342 * If it is not, the client application can not know who request to launch itself. \n
343 * It should be necessary to understand the action operation of notification click event.
344 * @remarks If the competition notification message is selected from the notification tray,\n
345 * the proper player application is launched automatically.
346 * @remarks The default value is false. So if the client don't enable it, any notification messages are not registered.
347 * @remarks This function should be called before downloading (See download_start())
348 * @param[in] download The download id
349 * @param[in] enable The boolean type. The true or false value is available.
350 * @return 0 on success, otherwise a negative error value.
351 * @retval #DOWNLOAD_ERROR_NONE Successful
352 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
353 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
354 * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
355 * @see download_get_notification()
356 * @see service_get_operation()
357 * @deprecated This API can be replaced with download_set_notification_type()
360 //ret = download_set_notification(id, true);
361 ret = download_set_notification_type(id, DOWNLOAD_NOTIFICATION_TYPE_ALL);
362 //ret = download_set_notification(id, false);
363 ret = download_set_notification_type(id, DOWNLOAD_NOTIFICATION_TYPE_NONE);
366 DEPRECATED int download_set_notification(int download_id, bool enable);
369 * @brief Gets the option value to register notification messages by download service module.
370 * @param[in] download The download id
371 * @param[out] enable The boolean type. The true or false value is returned
372 * @return 0 on success, otherwise a negative error value.
373 * @retval #DOWNLOAD_ERROR_NONE Successful
374 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
375 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
376 * @see download_set_notification()
377 * @deprecated This API can be replaced with download_get_notification_type()
381 download_notification_type_e type;
382 //ret = download_get_notification(id, &val);
383 ret = download_get_notification_type(id, &type);
386 DEPRECATED int download_get_notification(int download_id, bool *enable);
389 * @brief Sets the extra param data which pass by application service data when notification message is clicked
390 * @details When client set the extra param data for ongoing notification action, \n
391 * it can get the data through service_get_extra_data() when client application is launched by notification action.
393 * @remarks This function should be called before downloading (See download_start())
395 * @param[in] download The download id
396 * @param[in] key The character pointer type. The extra param has a pair of key and value
397 * @param[in] values The character pointer array type. The extra param has a pair of key and value array
398 * @param[in] length The length of value array
399 * @return 0 on success, otherwise a negative error value.
400 * @retval #DOWNLOAD_ERROR_NONE Successful
401 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
402 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
403 * @see download_get_notification_extra_param()
404 * @see download_remove_notification_extra_param()
405 * @deprecated This API can be replaced with download_set_notification_bundle()
409 // char *value[1] = ("12345",};
410 //ret = download_add_notification_extra_param(id, "specific_id", value[0], 1);
411 bundle *b = bundle_create();
412 char buff[MAX_BUF_LEN] = {0,};
413 appsvc_set_pkgname(b, "com.samsung.test-app");
414 appsvc_add_data(b, "specific_id", "12345");
415 ret = download_set_notification_bundle(id, DOWNLOAD_NOTIFICATION_BUNDLE_TYPE_ALL, b);
419 DEPRECATED int download_add_notification_extra_param(int download_id, const char *key, const char **values, const unsigned int length);
422 * @brief Remove the extra param data which pass by application service data when notification message is clicked
424 * @remarks This function should be called before downloading (See download_start())
426 * @param[in] download The download id
427 * @param[in] key The character pointer type. The extra param has a pair of key and value
428 * @return 0 on success, otherwise a negative error value.
429 * @retval #DOWNLOAD_ERROR_NONE Successful
430 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
431 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
432 * @see download_add_notification_extra_param()
433 * @see download_get_notification_extra_param()
435 DEPRECATED int download_remove_notification_extra_param(int download_id, const char *key);
438 * @brief Gets the extra param value to set by download_set_notification_extra_param
439 * @param[in] download The download id
440 * @param[out] key The character pointer type. The extra param has a pair of key and value
441 * @param[out] values param The character pointer array type. The extra param has a pair of key and value array
442 * @param[out] length The length of value array
443 * @return 0 on success, otherwise a negative error value.
444 * @retval #DOWNLOAD_ERROR_NONE Successful
445 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
446 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
447 * @see download_set_notification_extra_param()
449 DEPRECATED int download_get_notification_extra_param(int download_id, const char *key, char ***values, unsigned int *length);
452 * @brief Gets the absolute path to save the downloaded file
454 * @remarks This function returns #DOWNLOAD_ERROR_INVALID_STATE if the download is not completed. \n
455 * The @a path must be released with free() by you.
456 * @param [in] download The download id
457 * @param [out] path The absolute path to the downloaded file
458 * @return 0 on success, otherwise a negative error value.
459 * @retval #DOWNLOAD_ERROR_NONE Successful
460 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
461 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
462 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
463 * @pre The download state must be #DOWNLOAD_STATE_COMPLETED.
464 * @see download_set_file_name()
465 * @see download_set_destination()
467 int download_get_downloaded_file_path(int download_id, char **path);
471 * @brief Gets the mime type for downloading a content.
473 * @remarks This function returns #DOWNLOAD_ERROR_INVALID_STATE if the download has not been started. \n
474 * The @a mime_type must be released with free() by you.
475 * @param [in] download The download id
476 * @param [out] mime_type The MIME type of the downloaded file
477 * @return 0 on success, otherwise a negative error value.
478 * @retval #DOWNLOAD_ERROR_NONE Successful
479 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
480 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
481 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
482 * @see download_set_file_name()
483 * @see download_set_destination()
484 * @see download_get_downloaded_file_path()
486 int download_get_mime_type(int download_id, char **mime_type);
490 * @brief Sets the option for auto download.
491 * @details If this option is enabled, \n
492 * the previous downloading item is restarted automatically as soon as the download daemon is restarted. \n
493 * And the download progress keep going after the client process is terminated. \n
494 * @remarks The client should call download_set_notification() and download_set_notification_extra_param() after call this API. \n
495 * If it is not, user do not receive the download result in case the client process is not alive.
496 * @remarks The default value is false.
497 * @param[in] download The download id
498 * @param[in] enable The boolean value for auto download which is defined by client.
499 * @return 0 on success, otherwise a negative error value.
500 * @retval #DOWNLOAD_ERROR_NONE Successful
501 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
502 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
503 * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
504 * @see download_get_auto_download()
505 * @see download_set_notification()
506 * @see download_set_notification_extra_param()
509 int download_set_auto_download(int download_id, bool enable);
513 * @brief Gets the value of option for auto download.
515 * @param [in] download The download id
516 * @param [out] enable The boolean value for auto download which is defined by client.
517 * @return 0 on success, otherwise a negative error value.
518 * @retval #DOWNLOAD_ERROR_NONE Successful
519 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
520 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
521 * @see download_set_auto_download()
523 int download_get_auto_download(int download_id, bool *enable);
527 * @brief Adds an HTTP header field to the download request
529 * @details The given HTTP header field will be included with the HTTP request of the download request. \n
530 * Refer to the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2">HTTP/1.1: HTTP Message Headers</a>
531 * @remarks This function should be called before downloading (see download_start()) \n
532 * This function replaces any existing value for the given key. \n
533 * This function returns #DOWNLOAD_ERROR_INVALID_PARAMETER if field or value is zero-length string.
534 * @param [in] download The download id
535 * @param [in] field The name of the HTTP header field
536 * @param [in] value The value associated with given field
537 * @return 0 on success, otherwise a negative error value.
538 * @retval #DOWNLOAD_ERROR_NONE Successful
539 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
540 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
541 * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
542 * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
543 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
544 * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
545 * @see download_get_http_header_field()
546 * @see download_remove_http_header_field()
548 int download_add_http_header_field(int download_id, const char *field, const char *value);
552 * @brief Gets the value associated with given HTTP header field from the download
554 * @remarks This function returns #DOWNLOAD_ERROR_INVALID_PARAMETER if field is zero-length string. \n
555 * The @a value must be released with free() by you.
556 * @param [in] download The download id
557 * @param [in] field The name of the HTTP header field
558 * @param [out] value The value associated with given field
559 * @return 0 on success, otherwise a negative error value.
560 * @retval #DOWNLOAD_ERROR_NONE Successful
561 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
562 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
563 * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
564 * @retval #DOWNLOAD_ERROR_FIELD_NOT_FOUND Specified field not found
565 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
566 * @see download_add_http_header_field()
567 * @see download_remove_http_header_field()
569 int download_get_http_header_field(int download_id, const char *field, char **value);
572 * @brief Gets all of the field added to the download request
574 * @remarks The @a value must be released with free() by you.
575 * @param [in] download The download id
576 * @param [out] the array of the HTTP header fields
577 * @param [out] the number of the HTTP header fields
578 * @return 0 on success, otherwise a negative error value.
579 * @retval #DOWNLOAD_ERROR_NONE Successful
580 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
581 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
582 * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
583 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
584 * @see download_add_http_header_field()
585 * @see download_remove_http_header_field()
587 int download_get_http_header_field_list(int download_id, char ***fields, int *length);
590 * @brief Removes the given HTTP header field from the download
592 * @remarks This function should be called before downloading (see download_start()) \n
593 * This function returns #DOWNLOAD_ERROR_INVALID_PARAMETER if field is zero-length string.
594 * @param [in] download The download id
595 * @param [in] field The name of the HTTP header field
596 * @return 0 on success, otherwise a negative error value.
597 * @retval #DOWNLOAD_ERROR_NONE Successful
598 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
599 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
600 * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
601 * @retval #DOWNLOAD_ERROR_FIELD_NOT_FOUND Specified field not found
602 * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
603 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
604 * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
605 * @see download_add_http_header_field()
606 * @see download_get_http_header_field()
608 int download_remove_http_header_field(int download_id, const char *field);
612 * @brief Registers a callback function to be invoked when the download state is changed.
614 * @remarks This function should be called before downloading (see download_start())
615 * @param [in] download The download id
616 * @param [in] callback The callback function to register
617 * @param [in] user_data The user data to be passed to the callback function
618 * @return 0 on success, otherwise a negative error value.
619 * @retval #DOWNLOAD_ERROR_NONE Successful
620 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
621 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
622 * @post download_state_changed_cb() will be invoked.
623 * @see download_unset_state_changed_cb()
624 * @see download_state_changed_cb()
626 int download_set_state_changed_cb(int download_id, download_state_changed_cb callback, void* user_data);
630 * @brief Unregisters the callback function.
632 * @remarks This function should be called before downloading (see download_start())
633 * @param [in] download The download id
634 * @return 0 on success, otherwise a negative error value.
635 * @retval #DOWNLOAD_ERROR_NONE Successful
636 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
637 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
638 * @see download_set_state_changed_cb()
639 * @see download_state_changed_cb()
641 int download_unset_state_changed_cb(int download_id);
645 * @brief Registers a callback function to be invoked when progress of the download changes
647 * @remarks This function should be called before downloading (see download_start())
648 * @param [in] download The download id
649 * @param [in] callback The callback function to register
650 * @param [in] user_data The user data to be passed to the callback function
651 * @return 0 on success, otherwise a negative error value.
652 * @retval #DOWNLOAD_ERROR_NONE Successful
653 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
654 * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
655 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
656 * @post download_progress_cb() will be invoked.
657 * @see download_unset_progress_cb()
658 * @see download_progress_cb()
660 int download_set_progress_cb(int download_id, download_progress_cb callback, void *user_data);
664 * @brief Unregisters the callback function.
666 * @remarks This function should be called before downloading (see download_start())
667 * @param [in] download The download id
668 * @return 0 on success, otherwise a negative error value.
669 * @retval #DOWNLOAD_ERROR_NONE Successful
670 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
671 * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
672 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
673 * @see download_set_progress_cb()
674 * @see download_progress_cb()
676 int download_unset_progress_cb(int download_id);
680 * @brief Starts or resumes the download, asynchronously.
682 * @details This function starts to download the current URL, or resumes the download if paused.
684 * @remarks The URL is the mandatory information to start the download.
685 * @remarks It should call download_set_progress_cb() and download_set_state_changed_cb() again \n
686 * after the client process is restarted or download_destry() is called
687 * @param [in] download The download id
688 * @return 0 on success, otherwise a negative error value.
689 * @retval #DOWNLOAD_ERROR_NONE Successful
690 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
691 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
692 * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
693 * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
694 * @retval #DOWNLOAD_ERROR_URL Invalid URL
695 * @retval #DOWNLOAD_ERROR_DESTINATION Invalid destination
696 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
697 * @retval #DOWNLOAD_ERROR_QUEUE_FULL Full of queue from download server
698 * @pre The download state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_PAUSED, #DOWNLOAD_STATE_CANCELED, #DOWNLOAD_STATE_FAILED.
699 * @post The download state will be #DOWNLOAD_STATE_QUEUED or #DOWNLOAD_STATE_DOWNLOADING
700 * @see download_set_url()
701 * @see download_pause()
702 * @see download_cancel()
704 int download_start(int download_id);
708 * @brief Pauses the download, asynchronously.
710 * @remarks The paused download can be restarted with download_start() or canceled with download_cancel()
711 * @param [in] download The download id
712 * @return 0 on success, otherwise a negative error value.
713 * @retval #DOWNLOAD_ERROR_NONE Successful
714 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
715 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
716 * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
717 * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
718 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
719 * @pre The download state must be #DOWNLOAD_STATE_DOWNLOADING.
720 * @post The download state will be #DOWNLOAD_STATE_PAUSED.
721 * @see download_start()
722 * @see download_cancel()
724 int download_pause(int download_id);
728 * @brief Cancel the download, asynchronously.
730 * @details This function cancels the running download and its state will be #DOWNLOAD_STATE_READY
731 * @remarks The canceled download can be restarted with download_start().
732 * @param [in] download The download id
733 * @return 0 on success, otherwise a negative error value.
734 * @retval #DOWNLOAD_ERROR_NONE Successful
735 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
736 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
737 * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
738 * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
739 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
740 * @pre The download state must be #DOWNLOAD_STATE_QUEUED, #DOWNLOAD_STATE_DOWNLOADING, #DOWNLOAD_STATE_PAUSED.
741 * @post The download state will be #DOWNLOAD_STATE_CANCELED.
742 * @see download_start()
744 int download_cancel(int download_id);
748 * @brief Gets the download's current state.
750 * @param [in] download The download id
751 * @param [out] state The current state of the download
752 * @return 0 on success, otherwise a negative error value.
753 * @retval #DOWNLOAD_ERROR_NONE Successful
754 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
755 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
756 * @see #download_state_e
758 int download_get_state(int download_id, download_state_e *state);
762 * @brief Gets the full path of temporary file for downloading a content.
764 * @param [in] download The download id
765 * @param [out] temp_path The full path of temporary file
766 * @return 0 on success, otherwise a negative error value.
767 * @retval #DOWNLOAD_ERROR_NONE Successful
768 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
769 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
770 * @pre The download state must be one of state after #DOWNLOAD_STATE_DOWNLOADING.
771 * @see #download_set_state_changed_cb()
772 * @see #download_unset_state_changed_cb()
773 * @see download_start()
775 int download_get_temp_path(int download_id, char **temp_path);
779 * @brief Gets the content name for downloading a file.
781 * @details This can be defined with reference of HTTP response header data.
782 * The content name can be received when HTTP response header is received.
784 * @param [in] download The download id
785 * @param [out] content_name The content name for displaying to user
786 * @return 0 on success, otherwise a negative error value.
787 * @retval #DOWNLOAD_ERROR_NONE Successful
788 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
789 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
790 * @pre The download state must be one of state after #DOWNLOAD_STATE_DOWNLOADING.
791 * @see #download_set_state_changed_cb()
792 * @see #download_unset_state_changed_cb()
793 * @see download_start()
795 int download_get_content_name(int download_id, char **content_name);
799 * @brief Gets the total size for downloading a content.
801 * @details This data receive from content server. If the content sever don't send total size of the content, the value set as zero.
803 * @param [in] download The download id
804 * @param [out] content_size The content size for displaying to user
805 * @return 0 on success, otherwise a negative error value.
806 * @retval #DOWNLOAD_ERROR_NONE Successful
807 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
808 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
809 * @pre The download state must be one of state after #DOWNLOAD_STATE_DOWNLOADING.
810 * @see #download_set_state_changed_cb()
811 * @see #download_unset_state_changed_cb()
812 * @see download_start()
814 int download_get_content_size(int download_id, unsigned long long *content_size);
818 * @brief Gets the error value when the download is failed.
820 * @param [in] download The download id
821 * @param [out] error The error value
822 * @return 0 on success, otherwise a negative error value.
823 * @retval #DOWNLOAD_ERROR_NONE Successful
824 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
825 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
826 * @pre The download state must be #DOWNLOAD_STATE_FAILED.
827 * @pre The download state must be #DOWNLOAD_STATE_CANCELED.
828 * @see #download_set_state_changed_cb()
829 * @see #download_unset_state_changed_cb()
830 * @see download_start()
831 * @see download_error_e
833 int download_get_error(int download_id, download_error_e *error);
837 * @brief Gets the http status code when the download error is happened.
839 * @param [in] download The download id
840 * @param [out] http_status The http status code which is defined in RFC 2616
841 * @return 0 on success, otherwise a negative error value.
842 * @retval #DOWNLOAD_ERROR_NONE Successful
843 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
844 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
845 * @pre The download state must be #DOWNLOAD_STATE_FAILED.
846 * @see #download_set_download_status_cb()
847 * @see #download_unset_download_status_cb()
848 * @see download_start()
850 int download_get_http_status(int download_id, int *http_status);
853 * @brief Sets bundle data to register notification messages.
854 * @details The three types of notification message can be posted. Those are completion, failed and ongoing type.
856 * @remarks When the notification message is clicked, the action is decided by bundle data. \n
857 * If the bundle data is not set, the following default operation is executed when the notification message is clicked. \n
858 * 1) Download completed state : The viewer application is executed according to extension name of downloaded content. \n
859 * 2) Download failed state and ongoing state : The client application is executed. \n
860 * @remarks This function should be called before starting download.
861 * @remarks The bundle data MUST BE FREED by client when it is not used any more.
862 * @param[in] download The download id
863 * @param[in] type The enumeration type. See #download_notification_bundle_type_e.
864 * @param[in] bundle The bundle pointer value.
865 * @return 0 on success, otherwise a negative error value.
866 * @retval #DOWNLOAD_ERROR_NONE Successful
867 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
868 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
869 * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
870 * @see download_set_notification_type()
871 * @see download_get_notification_bundle()
873 int download_set_notification_bundle(int download_id, download_notification_bundle_type_e type, bundle *b);
876 * @brief Get the bundle data to register notification messages which is set in download_set_notification_bundle().
878 * @details When the notification message is clicked, the action is decided by bundle data. \n
879 * @param[in] download The download id
880 * @param[in] type The enumeration type. See #download_notification_bundle_type_e.
881 * @param[out] bundle The bundle pointer value.
882 * @remarks The bundle data MUST BE FREED by client when it is not used any more.
883 * @return 0 on success, otherwise a negative error value.
884 * @retval #DOWNLOAD_ERROR_NONE Successful
885 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
886 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
887 * @retval #DOWNLOAD_ERROR_NO_DATA the bundle have not been set
888 * @see download_set_notification_bundle()
890 int download_get_notification_bundle(int download_id, download_notification_bundle_type_e type, bundle **b);
893 * @brief Set the title of notification.
895 * @details When registering notification, the title is displayed at title area of notification message
897 * @param [in] download The download id
898 * @param [in] title The title for displaying to user
899 * @return 0 on success, otherwise a negative error value.
900 * @retval #DOWNLOAD_ERROR_NONE Successful
901 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
902 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
903 * @pre If the notification option is not enable, this title is not shown to user
904 * @see #download_set_notification_type()
905 * @see #download_get_notification_title()
907 int download_set_notification_title(int download_id, const char *title);
910 * @brief Gets the title of notification when set in #download_set_notification_title()
912 * @details When registering notification, the title is displayed at title area of notification message
914 * @param [in] download The download id
915 * @param [out] title The title for displaying to user
916 * @return 0 on success, otherwise a negative error value.
917 * @retval #DOWNLOAD_ERROR_NONE Successful
918 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
919 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
920 * @retval #DOWNLOAD_ERROR_NO_DATA the title have not been set
921 * @pre It can get the title value before calling this API.
922 * @see #download_set_notification_title()
924 int download_get_notification_title(int download_id, char **title);
927 * @brief Set the description of notification.
929 * @details When registering notification, the description is displayed at description area of notification message
931 * @param [in] download The download id
932 * @param [in] description The description for displaying to user
933 * @return 0 on success, otherwise a negative error value.
934 * @retval #DOWNLOAD_ERROR_NONE Successful
935 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
936 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
937 * @pre If the notification option is not enable, this description is not shown to user
938 * @see #download_set_notification_type()
939 * @see #download_get_notification_description()
941 int download_set_notification_description(int download_id, const char *description);
944 * @brief Gets the description of notification when set in #download_set_notification_description()
946 * @details When registering notification, the description is displayed at description area of notification message
948 * @param [in] download The download id
949 * @param [out] description The description for displaying to user
950 * @return 0 on success, otherwise a negative error value.
951 * @retval #DOWNLOAD_ERROR_NONE Successful
952 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
953 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
954 * @retval #DOWNLOAD_ERROR_NO_DATA the description have not been set
955 * @pre It can get the title value before calling this API.
956 * @see #download_set_notification_description()
958 int download_get_notification_description(int download_id, char **description);
961 * @brief Sets the option value to register notification messages.
962 * @details The three types of notification message can be posted. Those are completion, failed and ongoing type.
964 * @remarks When the notification message is clicked, the action is decided by bundle data from download_set_notification_bundle(). \n
965 * If the bundle data is not set, the following default operation is executed when the notification message is clicked. \n
966 * 1) Download completed state : The viewer application is executed according to extension name of downloaded content. \n
967 * 2) Download failed state and ongoing state : The client application is executed. \n
968 * @remarks The default type is #DOWNLOAD_NOTIFICATION_TYPE_NONE.
969 * @remarks This function should be called before starting download.
970 * @param[in] download The download id
971 * @param[in] type The enumeration type. See #download_notification_type_e.
972 * @return 0 on success, otherwise a negative error value.
973 * @retval #DOWNLOAD_ERROR_NONE Successful
974 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
975 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
976 * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
977 * @see download_set_notification_bundle()
978 * @see download_get_notification_type()
980 int download_set_notification_type(int download_id, download_notification_type_e type);
983 * @brief Get the option value to register notification messages which is set in download_set_notification_type().
985 * @remarks When the notification message is clicked, the action is decided by bundle data from download_set_notification_bundle(). \n
986 * @remarks The default type is #DOWNLOAD_NOTIFICATION_TYPE_NONE.
987 * @param[in] download The download id
988 * @param[out] type The enumeration type. See #download_notification_type_e.
989 * @return 0 on success, otherwise a negative error value.
990 * @retval #DOWNLOAD_ERROR_NONE Successful
991 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
992 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
993 * @see download_set_notification_type()
995 int download_get_notification_type(int download_id, download_notification_type_e *type);
1005 #endif /* __TIZEN_WEB_DOWNLOAD_H__ */