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_INVALID_STATE = TIZEN_ERROR_WEB_CLASS | 0x21, /**< Invalid state */
51 DOWNLOAD_ERROR_CONNECTION_FAILED = TIZEN_ERROR_WEB_CLASS | 0x22, /**< Connection failed */
52 DOWNLOAD_ERROR_INVALID_URL = TIZEN_ERROR_WEB_CLASS | 0x24, /**< Invalid URL */
53 DOWNLOAD_ERROR_INVALID_DESTINATION = TIZEN_ERROR_WEB_CLASS | 0x25, /**< Invalid destination */
54 DOWNLOAD_ERROR_TOO_MANY_DOWNLOADS = TIZEN_ERROR_WEB_CLASS | 0x26, /**< Full of available simultaneous downloads */
55 DOWNLOAD_ERROR_QUEUE_FULL = TIZEN_ERROR_WEB_CLASS | 0x27, /**< Full of available downloading items from server*/
56 DOWNLOAD_ERROR_ALREADY_COMPLETED = TIZEN_ERROR_WEB_CLASS | 0x28, /**< The download is already completed */
57 DOWNLOAD_ERROR_FILE_ALREADY_EXISTS = TIZEN_ERROR_WEB_CLASS | 0x29, /**< It is failed to rename the downloaded file */
58 DOWNLOAD_ERROR_CANNOT_RESUME = TIZEN_ERROR_WEB_CLASS | 0x2a, /**< It cannot resume */
59 DOWNLOAD_ERROR_TOO_MANY_REDIRECTS = TIZEN_ERROR_WEB_CLASS | 0x30, /**< In case of too may redirects from http response header*/
60 DOWNLOAD_ERROR_UNHANDLED_HTTP_CODE = TIZEN_ERROR_WEB_CLASS | 0x31, /**< The download cannot handle the http status value */
61 DOWNLOAD_ERROR_REQUEST_TIMEOUT = TIZEN_ERROR_WEB_CLASS | 0x32, /**< There are no action after client create a download id*/
62 DOWNLOAD_ERROR_RESPONSE_TIMEOUT = TIZEN_ERROR_WEB_CLASS | 0x33, /**< It does not call start API in some time although the download is created*/
63 DOWNLOAD_ERROR_SYSTEM_DOWN = TIZEN_ERROR_WEB_CLASS | 0x34, /**< There are no response from client after rebooting download daemon*/
64 DOWNLOAD_ERROR_ID_NOT_FOUND = TIZEN_ERROR_WEB_CLASS | 0x35, /**< The download id is not existed in download service module*/
65 DOWNLOAD_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA, /**< No data because the set API is not called */
66 DOWNLOAD_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR , /**< Internal I/O error */
71 * @brief Enumerations of state of download
75 DOWNLOAD_STATE_NONE, /**< It is ready to download */
76 DOWNLOAD_STATE_READY, /**< It is ready to download */
77 DOWNLOAD_STATE_QUEUED, /**< It is queued to start downloading */
78 DOWNLOAD_STATE_DOWNLOADING, /**< The download is currently running */
79 DOWNLOAD_STATE_PAUSED, /**< The download is waiting to resume */
80 DOWNLOAD_STATE_COMPLETED, /**< The download is completed. */
81 DOWNLOAD_STATE_FAILED, /**< The download failed. */
82 DOWNLOAD_STATE_CANCELED, /**< User cancel the download item. */
86 * @brief Enumerations of network type for download
90 DOWNLOAD_NETWORK_DATA_NETWORK, /**< Download is available through data network */
91 DOWNLOAD_NETWORK_WIFI, /**< Download is available through WiFi */
92 DOWNLOAD_NETWORK_WIFI_DIRECT, /**< Download is available through WiFi-Direct */
93 DOWNLOAD_NETWORK_ALL /**< Download is available through either data network or WiFi */
94 } download_network_type_e ;
98 * @brief Enumerations of notification type when client want to register
99 * @see #download_set_notification_type()
100 * @see #download_get_notification_type()
104 DOWNLOAD_NOTIFICATION_TYPE_NONE = 0, /**< Do not register notification */
105 DOWNLOAD_NOTIFICATION_TYPE_COMPLETE_ONLY, /**< For success state and failed state */
106 DOWNLOAD_NOTIFICATION_TYPE_ALL /**< For ongoing state, success state and failed state */
107 } download_notification_type_e;
111 * @brief Enumerations of the type about notification bundle which client want to set when registering notification
112 * @see #download_set_notification_bundle()
113 * @see #download_get_notification_bundle()
117 DOWNLOAD_NOTIFICATION_BUNDLE_TYPE_ONGOING = 0, /**< For bundle for failed and ongoing notification */
118 DOWNLOAD_NOTIFICATION_BUNDLE_TYPE_COMPLETE, /**< For bundle for completed notification */
119 DOWNLOAD_NOTIFICATION_BUNDLE_TYPE_FAILED /**< For bundle for failed notification*/
120 } download_notification_bundle_type_e;
124 * @brief Called when the download status is changed.
126 * @param [in] download The download id
127 * @param [in] state The state of download
128 * @param [in] user_data The user data passed from download_set_state_changed_cb()
129 * @pre download_start() will cause this callback if you register this callback using download_set_state_changed_cb()
130 * @see download_set_state_changed_cb()
131 * @see download_unset_state_changed_cb()
133 typedef void (*download_state_changed_cb) (int download_id,
134 download_state_e state, void *user_data);
137 * @brief Called when the progress of download changes.
139 * @remarks This callback function is only invoked in the downloading state.
140 * @param [in] download The download id
141 * @param [in] received The size of the data received in bytes
142 * @param [in] user_data The user data passed from download_set_progress_cb()
143 * @pre This callback function is invoked if you register this callback using download_set_progress_cb().
144 * @see download_cancel()
145 * @see download_set_progress_cb()
146 * @see download_unset_progress_cb()
148 typedef void (*download_progress_cb) (int download_id, unsigned long long received, void *user_data);
151 * @brief Creates a download id.
153 * @remarks The @a download is released with download_destroy() by client.\n
154 * @param [out] download A download id to be newly created on success
155 * @return 0 on success, otherwise a negative error value.
156 * @retval #DOWNLOAD_ERROR_NONE Successful
157 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
158 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
159 * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
160 * @retval #DOWNLOAD_ERROR_QUEUE_FULL Full of queue from download server
161 * @post The download state will be #DOWNLOAD_STATE_READY
162 * @see download_destroy()
164 int download_create(int *download_id);
168 * @brief Unload all data concerning a download id from memory.
170 * @detail After calling this API, a download ID is existed at DB in certain time.\n
171 * Within that time, it is able to use the other API with the download ID.
172 * @remark If #DOWNLOAD_ERROR_ID_NOT_FOUND is returned, it means that the download ID is completely removed from DB.
173 * @param [in] download The download id
174 * @return 0 on success, otherwise a negative error value.
175 * @retval #DOWNLOAD_ERROR_NONE Successful
176 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
177 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
178 * @see download_create()
180 int download_destroy(int download_id);
184 * @brief Sets the URL to download.
186 * @remarks This function should be called before downloading (See download_start())
187 * @param [in] download The download id
188 * @param [in] url The URL to download \n
189 * If the @a url is NULL, it clears the previous value.
190 * @return 0 on success, otherwise a negative error value.
191 * @retval #DOWNLOAD_ERROR_NONE Successful
192 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
193 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
194 * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
195 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
196 * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
197 * @see download_get_url()
199 int download_set_url(int download_id, const char *url);
203 * @brief Gets the URL to download.
205 * @remarks The @a url must be released with free() by you.
206 * @param [in] download The download id
207 * @param [out] url The URL to download
208 * @return 0 on success, otherwise a negative error value.
209 * @retval #DOWNLOAD_ERROR_NONE Successful
210 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
211 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
212 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
213 * @see download_set_url()
215 int download_get_url(int download_id, char **url);
219 * @brief Sets the allowed network type for the downloaded file
221 * @details The file can be downloaded only under the allowed network.
223 * @remarks This function should be called before downloading (see download_start())
224 * @param [in] download The download id
225 * @param [in] net_type The network type which the client prefer
226 * @return 0 on success, otherwise a negative error value.
227 * @retval #DOWNLOAD_ERROR_NONE Successful
228 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
229 * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
230 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
231 * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
232 * @see download_get_network_type()
233 * @see #download_network_type_e
235 int download_set_network_type(int download_id, download_network_type_e net_type);
239 * @brief Gets the network type for the downloaded file
241 * @param [in] download The download id
242 * @param [out] net_type The network type which is defined by client.
243 * @return 0 on success, otherwise a negative error value.
244 * @retval #DOWNLOAD_ERROR_NONE Successful
245 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
246 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
247 * @see download_set_network_type()
248 * @see #download_network_type_e
250 int download_get_network_type(int download_id, download_network_type_e *net_type);
254 * @brief Sets the destination for the downloaded file.
256 * @details The file will be downloaded to the specified destination.
257 * The downloaded file is saved to an auto-generated file name in the destination.
258 * If the destination is not specified, the file will be downloaded to default storage. (See the @ref CAPI_STORAGE_MODULE API)
260 * @remarks This function should be called before downloading (see download_start())
261 * @param [in] download The download id
262 * @param [in] path The absolute path to the downloaded file
263 * If the @a path is NULL, it clears the previous value.
264 * @return 0 on success, otherwise a negative error value.
265 * @retval #DOWNLOAD_ERROR_NONE Successful
266 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
267 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
268 * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
269 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
270 * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
271 * @see download_get_destination()
273 int download_set_destination(int download_id, const char *path);
277 * @brief Gets the destination for the downloaded file.
279 * @remarks The @a path must be released with free() by you.
280 * @param [in] download The download id
281 * @param [out] path The absolute path to the downloaded file
282 * @return 0 on success, otherwise a negative error value.
283 * @retval #DOWNLOAD_ERROR_NONE Successful
284 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
285 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
286 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
287 * @see download_set_destination()
289 int download_get_destination(int download_id, char **path);
293 * @brief Sets the name for the downloaded file.
295 * @details The file will be downloaded to the specified destination as the given file name.
296 * If the file name is not specified, the downloaded file is saved to an auto-generated file name in the destination.
298 * @remarks This function should be called before downloading (see download_start())
299 * @param [in] download The download id
300 * @param [in] file_name The file name for the downloaded file
301 * If the @a name is NULL, it clears the previous value.
302 * @return 0 on success, otherwise a negative error value.
303 * @retval #DOWNLOAD_ERROR_NONE Successful
304 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
305 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
306 * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
307 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
308 * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
309 * @see download_get_file_name()
311 int download_set_file_name(int download_id, const char *file_name);
315 * @brief Gets the name which is set by user.
317 * @details If user do not set any name, it returns NULL.
319 * @remarks The @a file_name must be released with free() by you.
320 * @param [in] download The download id
321 * @param [out] file_name The file name which is set by user.
322 * @return 0 on success, otherwise a negative error value.
323 * @retval #DOWNLOAD_ERROR_NONE Successful
324 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
325 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
326 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
327 * @see download_set_file_name()
329 int download_get_file_name(int download_id, char **file_name);
333 * @brief Sets the option value to register notification messages by download service module.
334 * @details The three types of notification message can be posted. Those are completion, failed and ongoing type.
335 * When the notification message of failed and ongoing types from the notification tray, \n
336 * the client application which call this API will be launched. \n
338 * @remarks The extra param should be set together (See download_set_notification_extra_param()). \n
339 * The downloading and failed notification can be registered only if the extra param for notification message is set. \n
340 * If it is not, the client application can not know who request to launch itself. \n
341 * It should be necessary to understand the action operation of notification click event.
342 * @remarks If the competition notification message is selected from the notification tray,\n
343 * the proper player application is launched automatically.
344 * @remarks The default value is false. So if the client don't enable it, any notification messages are not registered.
345 * @remarks This function should be called before downloading (See download_start())
346 * @param[in] download The download id
347 * @param[in] enable The boolean type. The true or false value is available.
348 * @return 0 on success, otherwise a negative error value.
349 * @retval #DOWNLOAD_ERROR_NONE Successful
350 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
351 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
352 * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
353 * @see download_get_notification()
354 * @see service_get_operation()
355 * @deprecated This API can be replaced with download_set_notification_type()
358 //ret = download_set_notification(id, true);
359 ret = download_set_notificationo_type(id, DOWNLOAD_NOTIFICATION_TYPE_ALL);
360 //ret = download_set_notification(id, false);
361 ret = download_set_notificationo_type(id, DOWNLOAD_NOTIFICATION_TYPE_NONE);
364 DEPRECATED int download_set_notification(int download_id, bool enable);
367 * @brief Gets the option value to register notification messages by download service module.
368 * @param[in] download The download id
369 * @param[out] enable The boolean type. The true or false value is returned
370 * @return 0 on success, otherwise a negative error value.
371 * @retval #DOWNLOAD_ERROR_NONE Successful
372 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
373 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
374 * @see download_set_notification()
375 * @deprecated This API can be replaced with download_get_notification_type()
379 download_notification_type_e type;
380 //ret = download_get_notification(id, &val);
381 ret = download_get_notification_type(id, &type);
384 DEPRECATED int download_get_notification(int download_id, bool *enable);
387 * @brief Sets the extra param data which pass by application service data when notification message is clicked
388 * @details When client set the extra param data for ongoing notification action, \n
389 * it can get the data through service_get_extra_data() when client application is launched by notification action.
391 * @remarks This function should be called before downloading (See download_start())
393 * @param[in] download The download id
394 * @param[in] key The character pointer type. The extra param has a pair of key and value
395 * @param[in] values The character pointer array type. The extra param has a pair of key and value array
396 * @param[in] length The length of value array
397 * @return 0 on success, otherwise a negative error value.
398 * @retval #DOWNLOAD_ERROR_NONE Successful
399 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
400 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
401 * @see download_get_notification_extra_param()
402 * @see download_remove_notification_extra_param()
403 * @deprecated This API can be replaced with download_set_notification_bundle()
407 // char *value[1] = ("12345",};
408 //ret = download_add_notification_extra_param(id, "specific_id", value[0], 1);
409 bundle *b = bundle_create();
410 char buff[MAX_BUF_LEN] = {0,};
411 appsvc_set_pkgname(b, "com.samsung.test-app");
412 appsvc_add_data(b, "specific_id", "12345");
413 ret = download_set_notification_bundle(id, DOWNLOAD_NOTIFICATION_BUNDLE_TYPE_ALL, b);
417 DEPRECATED int download_add_notification_extra_param(int download_id, const char *key, const char **values, const unsigned int length);
420 * @brief Remove the extra param data which pass by application service data when notification message is clicked
422 * @remarks This function should be called before downloading (See download_start())
424 * @param[in] download The download id
425 * @param[in] key The character pointer type. The extra param has a pair of key and value
426 * @return 0 on success, otherwise a negative error value.
427 * @retval #DOWNLOAD_ERROR_NONE Successful
428 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
429 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
430 * @see download_add_notification_extra_param()
431 * @see download_get_notification_extra_param()
433 DEPRECATED int download_remove_notification_extra_param(int download_id, const char *key);
436 * @brief Gets the extra param value to set by download_set_notification_extra_param
437 * @param[in] download The download id
438 * @param[out] key The character pointer type. The extra param has a pair of key and value
439 * @param[out] values param The character pointer array type. The extra param has a pair of key and value array
440 * @param[out] length The length of value array
441 * @return 0 on success, otherwise a negative error value.
442 * @retval #DOWNLOAD_ERROR_NONE Successful
443 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
444 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
445 * @see download_set_notification_extra_param()
447 DEPRECATED int download_get_notification_extra_param(int download_id, const char *key, char ***values, unsigned int *length);
450 * @brief Gets the absolute path to save the downloaded file
452 * @remarks This function returns #DOWNLOAD_ERROR_INVALID_STATE if the download is not completed. \n
453 * The @a path must be released with free() by you.
454 * @param [in] download The download id
455 * @param [out] path The absolute path to the downloaded file
456 * @return 0 on success, otherwise a negative error value.
457 * @retval #DOWNLOAD_ERROR_NONE Successful
458 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
459 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
460 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
461 * @pre The download state must be #DOWNLOAD_STATE_COMPLETED.
462 * @see download_set_file_name()
463 * @see download_set_destination()
465 int download_get_downloaded_file_path(int download_id, char **path);
469 * @brief Gets the mime type for downloading a content.
471 * @remarks This function returns #DOWNLOAD_ERROR_INVALID_STATE if the download has not been started. \n
472 * The @a mime_type must be released with free() by you.
473 * @param [in] download The download id
474 * @param [out] mime_type The MIME type of the downloaded file
475 * @return 0 on success, otherwise a negative error value.
476 * @retval #DOWNLOAD_ERROR_NONE Successful
477 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
478 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
479 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
480 * @see download_set_file_name()
481 * @see download_set_destination()
482 * @see download_get_downloaded_file_path()
484 int download_get_mime_type(int download_id, char **mime_type);
488 * @brief Sets the option for auto download.
489 * @details If this option is enabled, \n
490 * the previous downloading item is restarted automatically as soon as the download daemon is restarted. \n
491 * And the download progress keep going after the client process is terminated. \n
492 * @remarks The client should call download_set_notification() and download_set_notification_extra_param() after call this API. \n
493 * If it is not, user do not receive the download result in case the client process is not alive.
494 * @remarks The default value is false.
495 * @param[in] download The download id
496 * @param[in] enable The boolean value for auto download which is defined by client.
497 * @return 0 on success, otherwise a negative error value.
498 * @retval #DOWNLOAD_ERROR_NONE Successful
499 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
500 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
501 * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
502 * @see download_get_auto_download()
503 * @see download_set_notification()
504 * @see download_set_notification_extra_param()
507 int download_set_auto_download(int download_id, bool enable);
511 * @brief Gets the value of option for auto download.
513 * @param [in] download The download id
514 * @param [out] enable The boolean value for auto download which is defined by client.
515 * @return 0 on success, otherwise a negative error value.
516 * @retval #DOWNLOAD_ERROR_NONE Successful
517 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
518 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
519 * @see download_set_auto_download()
521 int download_get_auto_download(int download_id, bool *enable);
525 * @brief Adds an HTTP header field to the download request
527 * @details The given HTTP header field will be included with the HTTP request of the download request. \n
528 * Refer to the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2">HTTP/1.1: HTTP Message Headers</a>
529 * @remarks This function should be called before downloading (see download_start()) \n
530 * This function replaces any existing value for the given key. \n
531 * This function returns #DOWNLOAD_ERROR_INVALID_PARAMETER if field or value is zero-length string.
532 * @param [in] download The download id
533 * @param [in] field The name of the HTTP header field
534 * @param [in] value The value associated with given field
535 * @return 0 on success, otherwise a negative error value.
536 * @retval #DOWNLOAD_ERROR_NONE Successful
537 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
538 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
539 * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
540 * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
541 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
542 * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
543 * @see download_get_http_header_field()
544 * @see download_remove_http_header_field()
546 int download_add_http_header_field(int download_id, const char *field, const char *value);
550 * @brief Gets the value associated with given HTTP header field from the download
552 * @remarks This function returns #DOWNLOAD_ERROR_INVALID_PARAMETER if field is zero-length string. \n
553 * The @a value must be released with free() by you.
554 * @param [in] download The download id
555 * @param [in] field The name of the HTTP header field
556 * @param [out] value The value associated with given field
557 * @return 0 on success, otherwise a negative error value.
558 * @retval #DOWNLOAD_ERROR_NONE Successful
559 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
560 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
561 * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
562 * @retval #DOWNLOAD_ERROR_FIELD_NOT_FOUND Specified field not found
563 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
564 * @see download_add_http_header_field()
565 * @see download_remove_http_header_field()
567 int download_get_http_header_field(int download_id, const char *field, char **value);
570 * @brief Gets all of the field added to the download request
572 * @remarks The @a value must be released with free() by you.
573 * @param [in] download The download id
574 * @param [out] the array of the HTTP header fields
575 * @param [out] the number of the HTTP header fields
576 * @return 0 on success, otherwise a negative error value.
577 * @retval #DOWNLOAD_ERROR_NONE Successful
578 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
579 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
580 * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
581 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
582 * @see download_add_http_header_field()
583 * @see download_remove_http_header_field()
585 int download_get_http_header_field_list(int download_id, char ***fields, int *length);
588 * @brief Removes the given HTTP header field from the download
590 * @remarks This function should be called before downloading (see download_start()) \n
591 * This function returns #DOWNLOAD_ERROR_INVALID_PARAMETER if field is zero-length string.
592 * @param [in] download The download id
593 * @param [in] field The name of the HTTP header field
594 * @return 0 on success, otherwise a negative error value.
595 * @retval #DOWNLOAD_ERROR_NONE Successful
596 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
597 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
598 * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
599 * @retval #DOWNLOAD_ERROR_FIELD_NOT_FOUND Specified field not found
600 * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
601 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
602 * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
603 * @see download_add_http_header_field()
604 * @see download_get_http_header_field()
606 int download_remove_http_header_field(int download_id, const char *field);
610 * @brief Registers a callback function to be invoked when the download state is changed.
612 * @remarks This function should be called before downloading (see download_start())
613 * @param [in] download The download id
614 * @param [in] callback The callback function to register
615 * @param [in] user_data The user data to be passed to the callback function
616 * @return 0 on success, otherwise a negative error value.
617 * @retval #DOWNLOAD_ERROR_NONE Successful
618 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
619 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
620 * @post download_state_changed_cb() will be invoked.
621 * @see download_unset_state_changed_cb()
622 * @see download_state_changed_cb()
624 int download_set_state_changed_cb(int download_id, download_state_changed_cb callback, void* user_data);
628 * @brief Unregisters the callback function.
630 * @remarks This function should be called before downloading (see download_start())
631 * @param [in] download The download id
632 * @return 0 on success, otherwise a negative error value.
633 * @retval #DOWNLOAD_ERROR_NONE Successful
634 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
635 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
636 * @see download_set_state_changed_cb()
637 * @see download_state_changed_cb()
639 int download_unset_state_changed_cb(int download_id);
643 * @brief Registers a callback function to be invoked when progress of the download changes
645 * @remarks This function should be called before downloading (see download_start())
646 * @param [in] download The download id
647 * @param [in] callback The callback function to register
648 * @param [in] user_data The user data to be passed to the callback function
649 * @return 0 on success, otherwise a negative error value.
650 * @retval #DOWNLOAD_ERROR_NONE Successful
651 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
652 * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
653 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
654 * @post download_progress_cb() will be invoked.
655 * @see download_unset_progress_cb()
656 * @see download_progress_cb()
658 int download_set_progress_cb(int download_id, download_progress_cb callback, void *user_data);
662 * @brief Unregisters the callback function.
664 * @remarks This function should be called before downloading (see download_start())
665 * @param [in] download The download id
666 * @return 0 on success, otherwise a negative error value.
667 * @retval #DOWNLOAD_ERROR_NONE Successful
668 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
669 * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
670 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
671 * @see download_set_progress_cb()
672 * @see download_progress_cb()
674 int download_unset_progress_cb(int download_id);
678 * @brief Starts or resumes the download, asynchronously.
680 * @details This function starts to download the current URL, or resumes the download if paused.
682 * @remarks The URL is the mandatory information to start the download.
683 * @remarks It should call download_set_progress_cb() and download_set_state_changed_cb() again \n
684 * after the client process is restarted or download_destry() is called
685 * @param [in] download The download id
686 * @return 0 on success, otherwise a negative error value.
687 * @retval #DOWNLOAD_ERROR_NONE Successful
688 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
689 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
690 * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
691 * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
692 * @retval #DOWNLOAD_ERROR_URL Invalid URL
693 * @retval #DOWNLOAD_ERROR_DESTINATION Invalid destination
694 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
695 * @retval #DOWNLOAD_ERROR_QUEUE_FULL Full of queue from download server
696 * @pre The download state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_PAUSED, #DOWNLOAD_STATE_CANCELED, #DOWNLOAD_STATE_FAILED.
697 * @post The download state will be #DOWNLOAD_STATE_QUEUED or #DOWNLOAD_STATE_DOWNLOADING
698 * @see download_set_url()
699 * @see download_pause()
700 * @see download_cancel()
702 int download_start(int download_id);
706 * @brief Pauses the download, asynchronously.
708 * @remarks The paused download can be restarted with download_start() or canceled with download_cancel()
709 * @param [in] download The download id
710 * @return 0 on success, otherwise a negative error value.
711 * @retval #DOWNLOAD_ERROR_NONE Successful
712 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
713 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
714 * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
715 * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
716 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
717 * @pre The download state must be #DOWNLOAD_STATE_DOWNLOADING.
718 * @post The download state will be #DOWNLOAD_STATE_PAUSED.
719 * @see download_start()
720 * @see download_cancel()
722 int download_pause(int download_id);
726 * @brief Cancel the download, asynchronously.
728 * @details This function cancels the running download and its state will be #DOWNLOAD_STATE_READY
729 * @remarks The canceled download can be restarted with download_start().
730 * @param [in] download The download id
731 * @return 0 on success, otherwise a negative error value.
732 * @retval #DOWNLOAD_ERROR_NONE Successful
733 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
734 * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
735 * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
736 * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
737 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
738 * @pre The download state must be #DOWNLOAD_STATE_QUEUED, #DOWNLOAD_STATE_DOWNLOADING, #DOWNLOAD_STATE_PAUSED.
739 * @post The download state will be #DOWNLOAD_STATE_CANCELED.
740 * @see download_start()
742 int download_cancel(int download_id);
746 * @brief Gets the download's current state.
748 * @param [in] download The download id
749 * @param [out] state The current state of the download
750 * @return 0 on success, otherwise a negative error value.
751 * @retval #DOWNLOAD_ERROR_NONE Successful
752 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
753 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
754 * @see #download_state_e
756 int download_get_state(int download_id, download_state_e *state);
760 * @brief Gets the full path of temporary file for downloading a content.
762 * @param [in] download The download id
763 * @param [out] temp_path The full path of temporary file
764 * @return 0 on success, otherwise a negative error value.
765 * @retval #DOWNLOAD_ERROR_NONE Successful
766 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
767 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
768 * @pre The download state must be one of state after #DOWNLOAD_STATE_DOWNLOADING.
769 * @see #download_set_state_changed_cb()
770 * @see #download_unset_state_changed_cb()
771 * @see download_start()
773 int download_get_temp_path(int download_id, char **temp_path);
777 * @brief Gets the content name for downloading a file.
779 * @details This can be defined with reference of HTTP response header data.
780 * The content name can be received when HTTP response header is received.
782 * @param [in] download The download id
783 * @param [out] content_name The content name for displaying to user
784 * @return 0 on success, otherwise a negative error value.
785 * @retval #DOWNLOAD_ERROR_NONE Successful
786 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
787 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
788 * @pre The download state must be one of state after #DOWNLOAD_STATE_DOWNLOADING.
789 * @see #download_set_state_changed_cb()
790 * @see #download_unset_state_changed_cb()
791 * @see download_start()
793 int download_get_content_name(int download_id, char **content_name);
797 * @brief Gets the total size for downloading a content.
799 * @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 * @param [in] download The download id
802 * @param [out] content_size The content size for displaying to user
803 * @return 0 on success, otherwise a negative error value.
804 * @retval #DOWNLOAD_ERROR_NONE Successful
805 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
806 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
807 * @pre The download state must be one of state after #DOWNLOAD_STATE_DOWNLOADING.
808 * @see #download_set_state_changed_cb()
809 * @see #download_unset_state_changed_cb()
810 * @see download_start()
812 int download_get_content_size(int download_id, unsigned long long *content_size);
816 * @brief Gets the error value when the download is failed.
818 * @param [in] download The download id
819 * @param [out] error The error value
820 * @return 0 on success, otherwise a negative error value.
821 * @retval #DOWNLOAD_ERROR_NONE Successful
822 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
823 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
824 * @pre The download state must be #DOWNLOAD_STATE_FAILED.
825 * @pre The download state must be #DOWNLOAD_STATE_CANCELED.
826 * @see #download_set_state_changed_cb()
827 * @see #download_unset_state_changed_cb()
828 * @see download_start()
829 * @see download_error_e
831 int download_get_error(int download_id, download_error_e *error);
835 * @brief Gets the http status code when the download error is happened.
837 * @param [in] download The download id
838 * @param [out] http_status The http status code which is defined in RFC 2616
839 * @return 0 on success, otherwise a negative error value.
840 * @retval #DOWNLOAD_ERROR_NONE Successful
841 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
842 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
843 * @pre The download state must be #DOWNLOAD_STATE_FAILED.
844 * @see #download_set_download_status_cb()
845 * @see #download_unset_download_status_cb()
846 * @see download_start()
848 int download_get_http_status(int download_id, int *http_status);
851 * @brief Sets bundle data to register notification messages.
852 * @details The three types of notification message can be posted. Those are completion, failed and ongoing type.
854 * @remarks When the notification message is clicked, the action is decided by bundle data. \n
855 * If the bundle data is not set, the following default operation is executed when the notification message is clicked. \n
856 * 1) Download completed state : The viewer application is executed according to extension name of downloaded content. \n
857 * 2) Download failed state and ongoing state : The client application is executed. \n
858 * @remarks This function should be called before starting download.
859 * @remarks The bundle data MUST BE FREED by client when it is not used any more.
860 * @param[in] download The download id
861 * @param[in] type The enumeration type. See #download_notification_bundle_type_e.
862 * @param[in] bundle The bundle pointer value.
863 * @return 0 on success, otherwise a negative error value.
864 * @retval #DOWNLOAD_ERROR_NONE Successful
865 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
866 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
867 * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
868 * @see download_set_notification_type()
869 * @see download_get_notification_bundle()
871 int download_set_notification_bundle(int download_id, download_notification_bundle_type_e type, bundle *b);
874 * @brief Get the bundle data to register notification messages which is set in download_set_notification_bundle().
876 * @details When the notification message is clicked, the action is decided by bundle data. \n
877 * @param[in] download The download id
878 * @param[in] type The enumeration type. See #download_notification_bundle_type_e.
879 * @param[out] bundle The bundle pointer value.
880 * @remarks The bundle data MUST BE FREED by client when it is not used any more.
881 * @return 0 on success, otherwise a negative error value.
882 * @retval #DOWNLOAD_ERROR_NONE Successful
883 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
884 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
885 * @retval #DOWNLOAD_ERROR_NO_DATA the bundle have not been set
886 * @see download_set_notification_bundle()
888 int download_get_notification_bundle(int download_id, download_notification_bundle_type_e type, bundle **b);
891 * @brief Set the title of notification.
893 * @details When registering notification, the title is displayed at title area of notification message
895 * @param [in] download The download id
896 * @param [in] title The title for displaying to user
897 * @return 0 on success, otherwise a negative error value.
898 * @retval #DOWNLOAD_ERROR_NONE Successful
899 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
900 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
901 * @pre If the notification option is not enable, this title is not shown to user
902 * @see #download_set_notification_type()
903 * @see #download_get_notification_title()
905 int download_set_notification_title(int download_id, const char *title);
908 * @brief Gets the title of notification when set in #download_set_notification_title()
910 * @details When registering notification, the title is displayed at title area of notification message
912 * @param [in] download The download id
913 * @param [out] title The title for displaying to user
914 * @return 0 on success, otherwise a negative error value.
915 * @retval #DOWNLOAD_ERROR_NONE Successful
916 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
917 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
918 * @retval #DOWNLOAD_ERROR_NO_DATA the title have not been set
919 * @pre It can get the title value before calling this API.
920 * @see #download_set_notification_title()
922 int download_get_notification_title(int download_id, char **title);
925 * @brief Set the description of notification.
927 * @details When registering notification, the description is displayed at description area of notification message
929 * @param [in] download The download id
930 * @param [in] description The description for displaying to user
931 * @return 0 on success, otherwise a negative error value.
932 * @retval #DOWNLOAD_ERROR_NONE Successful
933 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
934 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
935 * @pre If the notification option is not enable, this description is not shown to user
936 * @see #download_set_notification_type()
937 * @see #download_get_notification_description()
939 int download_set_notification_description(int download_id, const char *description);
942 * @brief Gets the description of notification when set in #download_set_notification_description()
944 * @details When registering notification, the description is displayed at description area of notification message
946 * @param [in] download The download id
947 * @param [out] description The description for displaying to user
948 * @return 0 on success, otherwise a negative error value.
949 * @retval #DOWNLOAD_ERROR_NONE Successful
950 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
951 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
952 * @retval #DOWNLOAD_ERROR_NO_DATA the description have not been set
953 * @pre It can get the title value before calling this API.
954 * @see #download_set_notification_description()
956 int download_get_notification_description(int download_id, char **description);
959 * @brief Sets the option value to register notification messages.
960 * @details The three types of notification message can be posted. Those are completion, failed and ongoing type.
962 * @remarks When the notification message is clicked, the action is decided by bundle data from download_set_notification_bundle(). \n
963 * If the bundle data is not set, the following default operation is executed when the notification message is clicked. \n
964 * 1) Download completed state : The viewer application is executed according to extension name of downloaded content. \n
965 * 2) Download failed state and ongoing state : The client application is executed. \n
966 * @remarks The default type is #DOWNLOAD_NOTIFICATION_TYPE_NONE.
967 * @remarks This function should be called before starting download.
968 * @param[in] download The download id
969 * @param[in] type The enumeration type. See #download_notification_type_e.
970 * @return 0 on success, otherwise a negative error value.
971 * @retval #DOWNLOAD_ERROR_NONE Successful
972 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
973 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
974 * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
975 * @see download_set_notification_bundle()
976 * @see download_get_notification_type()
978 int download_set_notification_type(int download_id, download_notification_type_e type);
981 * @brief Get the option value to register notification messages which is set in download_set_notification_type().
983 * @remarks When the notification message is clicked, the action is decided by bundle data from download_set_notification_bundle(). \n
984 * @remarks The default type is #DOWNLOAD_NOTIFICATION_TYPE_NONE.
985 * @param[in] download The download id
986 * @param[out] type The enumeration type. See #download_notification_type_e.
987 * @return 0 on success, otherwise a negative error value.
988 * @retval #DOWNLOAD_ERROR_NONE Successful
989 * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
990 * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
991 * @see download_set_notification_type()
993 int download_get_notification_type(int download_id, download_notification_type_e *type);
1003 #endif /* __TIZEN_WEB_DOWNLOAD_H__ */