--- /dev/null
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TIZEN_WEB_DOWNLOAD_H__
+#define __TIZEN_WEB_DOWNLOAD_H__
+
+#include <tizen.h>
+#include <bundle.h>
+
+#ifndef DEPRECATED
+ #define DEPRECATED __attribute__((deprecated))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ /**
+ * @addtogroup CAPI_WEB_DOWNLOAD_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumeration of error code for URL download
+ */
+typedef enum
+{
+ DOWNLOAD_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ DOWNLOAD_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ DOWNLOAD_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ DOWNLOAD_ERROR_NETWORK_UNREACHABLE = TIZEN_ERROR_NETWORK_UNREACHABLE, /**< Network is unreachable */
+ DOWNLOAD_ERROR_CONNECTION_TIMED_OUT = TIZEN_ERROR_CONNECTION_TIME_OUT, /**< Http session time-out */
+ DOWNLOAD_ERROR_NO_SPACE = TIZEN_ERROR_FILE_NO_SPACE_ON_DEVICE, /**< No space left on device */
+ DOWNLOAD_ERROR_FIELD_NOT_FOUND = TIZEN_ERROR_KEY_NOT_AVAILABLE, /**< Specified field not found */
+ DOWNLOAD_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+ DOWNLOAD_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
+ DOWNLOAD_ERROR_INVALID_STATE = TIZEN_ERROR_WEB_CLASS | 0x21, /**< Invalid state */
+ DOWNLOAD_ERROR_CONNECTION_FAILED = TIZEN_ERROR_WEB_CLASS | 0x22, /**< Connection failed */
+ DOWNLOAD_ERROR_INVALID_URL = TIZEN_ERROR_WEB_CLASS | 0x24, /**< Invalid URL */
+ DOWNLOAD_ERROR_INVALID_DESTINATION = TIZEN_ERROR_WEB_CLASS | 0x25, /**< Invalid destination */
+ DOWNLOAD_ERROR_TOO_MANY_DOWNLOADS = TIZEN_ERROR_WEB_CLASS | 0x26, /**< Full of available simultaneous downloads */
+ DOWNLOAD_ERROR_QUEUE_FULL = TIZEN_ERROR_WEB_CLASS | 0x27, /**< Full of available downloading items from server*/
+ DOWNLOAD_ERROR_ALREADY_COMPLETED = TIZEN_ERROR_WEB_CLASS | 0x28, /**< The download is already completed */
+ DOWNLOAD_ERROR_FILE_ALREADY_EXISTS = TIZEN_ERROR_WEB_CLASS | 0x29, /**< It is failed to rename the downloaded file */
+ DOWNLOAD_ERROR_CANNOT_RESUME = TIZEN_ERROR_WEB_CLASS | 0x2a, /**< It cannot resume */
+ DOWNLOAD_ERROR_TOO_MANY_REDIRECTS = TIZEN_ERROR_WEB_CLASS | 0x30, /**< In case of too may redirects from http response header*/
+ DOWNLOAD_ERROR_UNHANDLED_HTTP_CODE = TIZEN_ERROR_WEB_CLASS | 0x31, /**< The download cannot handle the http status value */
+ DOWNLOAD_ERROR_REQUEST_TIMEOUT = TIZEN_ERROR_WEB_CLASS | 0x32, /**< There are no action after client create a download id*/
+ DOWNLOAD_ERROR_RESPONSE_TIMEOUT = TIZEN_ERROR_WEB_CLASS | 0x33, /**< It does not call start API in some time although the download is created*/
+ DOWNLOAD_ERROR_SYSTEM_DOWN = TIZEN_ERROR_WEB_CLASS | 0x34, /**< There are no response from client after rebooting download daemon*/
+ DOWNLOAD_ERROR_ID_NOT_FOUND = TIZEN_ERROR_WEB_CLASS | 0x35, /**< The download id is not existed in download service module*/
+ DOWNLOAD_ERROR_INVALID_NETWORK_TYPE = TIZEN_ERROR_DOWNLOAD | 0x36, /**< Network bonding is set but network type is not set as DOWNLOAD_NETWORK_ALL*/
+ DOWNLOAD_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA, /**< No data because the set API is not called */
+ DOWNLOAD_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR , /**< Internal I/O error */
+} download_error_e;
+
+
+/**
+ * @brief Enumerations of state of download
+ */
+typedef enum
+{
+ DOWNLOAD_STATE_NONE, /**< It is ready to download */
+ DOWNLOAD_STATE_READY, /**< It is ready to download */
+ DOWNLOAD_STATE_QUEUED, /**< It is queued to start downloading */
+ DOWNLOAD_STATE_DOWNLOADING, /**< The download is currently running */
+ DOWNLOAD_STATE_PAUSED, /**< The download is waiting to resume */
+ DOWNLOAD_STATE_COMPLETED, /**< The download is completed. */
+ DOWNLOAD_STATE_FAILED, /**< The download failed. */
+ DOWNLOAD_STATE_CANCELED, /**< User cancel the download item. */
+} download_state_e;
+
+/**
+ * @brief Enumerations of network type for download
+ */
+typedef enum
+{
+ DOWNLOAD_NETWORK_DATA_NETWORK, /**< Download is available through data network */
+ DOWNLOAD_NETWORK_WIFI, /**< Download is available through WiFi */
+ DOWNLOAD_NETWORK_WIFI_DIRECT, /**< Download is available through WiFi-Direct */
+ DOWNLOAD_NETWORK_ALL /**< Download is available through either data network or WiFi */
+} download_network_type_e ;
+
+
+/**
+ * @brief Enumerations of notification type when client want to register
+ * @see #download_set_notification_type()
+ * @see #download_get_notification_type()
+ */
+typedef enum
+{
+ DOWNLOAD_NOTIFICATION_TYPE_NONE = 0, /**< Do not register notification */
+ DOWNLOAD_NOTIFICATION_TYPE_COMPLETE_ONLY, /**< For success state and failed state */
+ DOWNLOAD_NOTIFICATION_TYPE_ALL /**< For ongoing state, success state and failed state */
+} download_notification_type_e;
+
+
+/**
+ * @brief Enumerations of the type about notification bundle which client want to set when registering notification
+ * @see #download_set_notification_bundle()
+ * @see #download_get_notification_bundle()
+ */
+typedef enum
+{
+ DOWNLOAD_NOTIFICATION_BUNDLE_TYPE_ONGOING = 0, /**< For bundle for failed and ongoing notification */
+ DOWNLOAD_NOTIFICATION_BUNDLE_TYPE_COMPLETE, /**< For bundle for completed notification */
+ DOWNLOAD_NOTIFICATION_BUNDLE_TYPE_FAILED /**< For bundle for failed notification*/
+} download_notification_bundle_type_e;
+
+
+/**
+ * @brief Called when the download status is changed.
+ *
+ * @param [in] download The download id
+ * @param [in] state The state of download
+ * @param [in] user_data The user data passed from download_set_state_changed_cb()
+ * @pre download_start() will cause this callback if you register this callback using download_set_state_changed_cb()
+ * @see download_set_state_changed_cb()
+ * @see download_unset_state_changed_cb()
+ */
+typedef void (*download_state_changed_cb) (int download_id,
+ download_state_e state, void *user_data);
+
+/**
+ * @brief Called when the progress of download changes.
+ *
+ * @remarks This callback function is only invoked in the downloading state.
+ * @param [in] download The download id
+ * @param [in] received The size of the data received in bytes
+ * @param [in] user_data The user data passed from download_set_progress_cb()
+ * @pre This callback function is invoked if you register this callback using download_set_progress_cb().
+ * @see download_cancel()
+ * @see download_set_progress_cb()
+ * @see download_unset_progress_cb()
+ */
+typedef void (*download_progress_cb) (int download_id, unsigned long long received, void *user_data);
+
+/**
+ * @brief Creates a download id.
+ *
+ * @remarks The @a download is released with download_destroy() by client.\n
+ * @param [out] download A download id to be newly created on success
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
+ * @retval #DOWNLOAD_ERROR_QUEUE_FULL Full of queue from download server
+ * @post The download state will be #DOWNLOAD_STATE_READY
+ * @see download_destroy()
+ */
+int download_create(int *download_id);
+
+
+/**
+ * @brief Unload all data concerning a download id from memory.
+ *
+ * @detail After calling this API, a download ID is existed at DB in certain time.\n
+ * Within that time, it is able to use the other API with the download ID.
+ * @remark If #DOWNLOAD_ERROR_ID_NOT_FOUND is returned, it means that the download ID is completely removed from DB.
+ * @param [in] download The download id
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @see download_create()
+ */
+int download_destroy(int download_id);
+
+
+/**
+ * @brief Sets the URL to download.
+ *
+ * @remarks This function should be called before downloading (See download_start())
+ * @param [in] download The download id
+ * @param [in] url The URL to download \n
+ * If the @a url is NULL, it clears the previous value.
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
+ * @see download_get_url()
+ */
+int download_set_url(int download_id, const char *url);
+
+
+/**
+ * @brief Gets the URL to download.
+ *
+ * @remarks The @a url must be released with free() by you.
+ * @param [in] download The download id
+ * @param [out] url The URL to download
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @see download_set_url()
+ */
+int download_get_url(int download_id, char **url);
+
+
+/**
+ * @brief Sets the allowed network type for the downloaded file
+ *
+ * @details The file can be downloaded only under the allowed network.
+ *
+ * @remarks This function should be called before downloading (see download_start())
+ * @param [in] download The download id
+ * @param [in] net_type The network type which the client prefer
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
+ * @see download_get_network_type()
+ * @see #download_network_type_e
+ */
+int download_set_network_type(int download_id, download_network_type_e net_type);
+
+
+/**
+ * @brief Gets the network type for the downloaded file
+ *
+ * @param [in] download The download id
+ * @param [out] net_type The network type which is defined by client.
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @see download_set_network_type()
+ * @see #download_network_type_e
+ */
+int download_get_network_type(int download_id, download_network_type_e *net_type);
+
+
+/**
+ * @brief Sets the destination for the downloaded file.
+ *
+ * @details The file will be downloaded to the specified destination.
+ * The downloaded file is saved to an auto-generated file name in the destination.
+ * If the destination is not specified, the file will be downloaded to default storage. (See the @ref CAPI_STORAGE_MODULE API)
+ *
+ * @remarks This function should be called before downloading (see download_start())
+ * @param [in] download The download id
+ * @param [in] path The absolute path to the downloaded file
+ * If the @a path is NULL, it clears the previous value.
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
+ * @see download_get_destination()
+ */
+int download_set_destination(int download_id, const char *path);
+
+
+/**
+ * @brief Gets the destination for the downloaded file.
+ *
+ * @remarks The @a path must be released with free() by you.
+ * @param [in] download The download id
+ * @param [out] path The absolute path to the downloaded file
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @see download_set_destination()
+ */
+int download_get_destination(int download_id, char **path);
+
+
+/**
+ * @brief Sets the name for the downloaded file.
+ *
+ * @details The file will be downloaded to the specified destination as the given file name.
+ * If the file name is not specified, the downloaded file is saved to an auto-generated file name in the destination.
+ *
+ * @remarks This function should be called before downloading (see download_start())
+ * @param [in] download The download id
+ * @param [in] file_name The file name for the downloaded file
+ * If the @a name is NULL, it clears the previous value.
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
+ * @see download_get_file_name()
+ */
+int download_set_file_name(int download_id, const char *file_name);
+
+
+/**
+ * @brief Gets the name which is set by user.
+ *
+ * @details If user do not set any name, it returns NULL.
+ *
+ * @remarks The @a file_name must be released with free() by you.
+ * @param [in] download The download id
+ * @param [out] file_name The file name which is set by user.
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @see download_set_file_name()
+ */
+int download_get_file_name(int download_id, char **file_name);
+
+
+/**
+ * @brief Sets the option value to register notification messages by download service module.
+ * @details The three types of notification message can be posted. Those are completion, failed and ongoing type.
+ * When the notification message of failed and ongoing types from the notification tray, \n
+ * the client application which call this API will be launched. \n
+ *
+ * @remarks The extra param should be set together (See download_set_notification_extra_param()). \n
+ * The downloading and failed notification can be registered only if the extra param for notification message is set. \n
+ * If it is not, the client application can not know who request to launch itself. \n
+ * It should be necessary to understand the action operation of notification click event.
+ * @remarks If the competition notification message is selected from the notification tray,\n
+ * the proper player application is launched automatically.
+ * @remarks The default value is false. So if the client don't enable it, any notification messages are not registered.
+ * @remarks This function should be called before downloading (See download_start())
+ * @param[in] download The download id
+ * @param[in] enable The boolean type. The true or false value is available.
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
+ * @see download_get_notification()
+ * @see service_get_operation()
+ * @deprecated This API can be replaced with download_set_notification_type()
+ @code
+ int ret = 0;
+ //ret = download_set_notification(id, true);
+ ret = download_set_notification_type(id, DOWNLOAD_NOTIFICATION_TYPE_ALL);
+ //ret = download_set_notification(id, false);
+ ret = download_set_notification_type(id, DOWNLOAD_NOTIFICATION_TYPE_NONE);
+ @endcode
+ */
+DEPRECATED int download_set_notification(int download_id, bool enable);
+
+/**
+ * @brief Gets the option value to register notification messages by download service module.
+ * @param[in] download The download id
+ * @param[out] enable The boolean type. The true or false value is returned
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @see download_set_notification()
+ * @deprecated This API can be replaced with download_get_notification_type()
+ @code
+ int ret = 0;
+ bool val = 0;
+ download_notification_type_e type;
+ //ret = download_get_notification(id, &val);
+ ret = download_get_notification_type(id, &type);
+ @endcode
+ */
+DEPRECATED int download_get_notification(int download_id, bool *enable);
+
+/**
+ * @brief Sets the extra param data which pass by application service data when notification message is clicked
+ * @details When client set the extra param data for ongoing notification action, \n
+ * it can get the data through service_get_extra_data() when client application is launched by notification action.
+ *
+ * @remarks This function should be called before downloading (See download_start())
+ *
+ * @param[in] download The download id
+ * @param[in] key The character pointer type. The extra param has a pair of key and value
+ * @param[in] values The character pointer array type. The extra param has a pair of key and value array
+ * @param[in] length The length of value array
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @see download_get_notification_extra_param()
+ * @see download_remove_notification_extra_param()
+ * @deprecated This API can be replaced with download_set_notification_bundle()
+ @code
+ #include <bundle.h>
+ int ret = 0;
+ // char *value[1] = ("12345",};
+ //ret = download_add_notification_extra_param(id, "specific_id", value[0], 1);
+ bundle *b = bundle_create();
+ char buff[MAX_BUF_LEN] = {0,};
+ appsvc_set_pkgname(b, "com.samsung.test-app");
+ appsvc_add_data(b, "specific_id", "12345");
+ ret = download_set_notification_bundle(id, DOWNLOAD_NOTIFICATION_BUNDLE_TYPE_ALL, b);
+ bundle_free(b);
+ @endcode
+ */
+DEPRECATED int download_add_notification_extra_param(int download_id, const char *key, const char **values, const unsigned int length);
+
+/**
+ * @brief Remove the extra param data which pass by application service data when notification message is clicked
+ *
+ * @remarks This function should be called before downloading (See download_start())
+ *
+ * @param[in] download The download id
+ * @param[in] key The character pointer type. The extra param has a pair of key and value
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @see download_add_notification_extra_param()
+ * @see download_get_notification_extra_param()
+ */
+DEPRECATED int download_remove_notification_extra_param(int download_id, const char *key);
+
+/**
+ * @brief Gets the extra param value to set by download_set_notification_extra_param
+ * @param[in] download The download id
+ * @param[out] key The character pointer type. The extra param has a pair of key and value
+ * @param[out] values param The character pointer array type. The extra param has a pair of key and value array
+ * @param[out] length The length of value array
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @see download_set_notification_extra_param()
+ */
+DEPRECATED int download_get_notification_extra_param(int download_id, const char *key, char ***values, unsigned int *length);
+
+/**
+ * @brief Gets the absolute path to save the downloaded file
+ *
+ * @remarks This function returns #DOWNLOAD_ERROR_INVALID_STATE if the download is not completed. \n
+ * The @a path must be released with free() by you.
+ * @param [in] download The download id
+ * @param [out] path The absolute path to the downloaded file
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @pre The download state must be #DOWNLOAD_STATE_COMPLETED.
+ * @see download_set_file_name()
+ * @see download_set_destination()
+ */
+int download_get_downloaded_file_path(int download_id, char **path);
+
+
+/**
+ * @brief Gets the mime type for downloading a content.
+ *
+ * @remarks This function returns #DOWNLOAD_ERROR_INVALID_STATE if the download has not been started. \n
+ * The @a mime_type must be released with free() by you.
+ * @param [in] download The download id
+ * @param [out] mime_type The MIME type of the downloaded file
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @see download_set_file_name()
+ * @see download_set_destination()
+ * @see download_get_downloaded_file_path()
+ */
+int download_get_mime_type(int download_id, char **mime_type);
+
+
+/**
+ * @brief Sets the option for auto download.
+ * @details If this option is enabled, \n
+ * the previous downloading item is restarted automatically as soon as the download daemon is restarted. \n
+ * And the download progress keep going after the client process is terminated. \n
+ * @remarks The client should call download_set_notification() and download_set_notification_extra_param() after call this API. \n
+ * If it is not, user do not receive the download result in case the client process is not alive.
+ * @remarks The default value is false.
+ * @param[in] download The download id
+ * @param[in] enable The boolean value for auto download which is defined by client.
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
+ * @see download_get_auto_download()
+ * @see download_set_notification()
+ * @see download_set_notification_extra_param()
+ *
+ */
+int download_set_auto_download(int download_id, bool enable);
+
+
+/**
+ * @brief Gets the value of option for auto download.
+ *
+ * @param [in] download The download id
+ * @param [out] enable The boolean value for auto download which is defined by client.
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @see download_set_auto_download()
+ */
+int download_get_auto_download(int download_id, bool *enable);
+
+
+/**
+ * @brief Adds an HTTP header field to the download request
+ *
+ * @details The given HTTP header field will be included with the HTTP request of the download request. \n
+ * Refer to the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2">HTTP/1.1: HTTP Message Headers</a>
+ * @remarks This function should be called before downloading (see download_start()) \n
+ * This function replaces any existing value for the given key. \n
+ * This function returns #DOWNLOAD_ERROR_INVALID_PARAMETER if field or value is zero-length string.
+ * @param [in] download The download id
+ * @param [in] field The name of the HTTP header field
+ * @param [in] value The value associated with given field
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
+ * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
+ * @see download_get_http_header_field()
+ * @see download_remove_http_header_field()
+ */
+int download_add_http_header_field(int download_id, const char *field, const char *value);
+
+
+/**
+ * @brief Gets the value associated with given HTTP header field from the download
+ *
+ * @remarks This function returns #DOWNLOAD_ERROR_INVALID_PARAMETER if field is zero-length string. \n
+ * The @a value must be released with free() by you.
+ * @param [in] download The download id
+ * @param [in] field The name of the HTTP header field
+ * @param [out] value The value associated with given field
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
+ * @retval #DOWNLOAD_ERROR_FIELD_NOT_FOUND Specified field not found
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @see download_add_http_header_field()
+ * @see download_remove_http_header_field()
+ */
+int download_get_http_header_field(int download_id, const char *field, char **value);
+
+/**
+ * @brief Gets all of the field added to the download request
+ *
+ * @remarks The @a value must be released with free() by you.
+ * @param [in] download The download id
+ * @param [out] the array of the HTTP header fields
+ * @param [out] the number of the HTTP header fields
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @see download_add_http_header_field()
+ * @see download_remove_http_header_field()
+ */
+int download_get_http_header_field_list(int download_id, char ***fields, int *length);
+
+/**
+ * @brief Removes the given HTTP header field from the download
+ *
+ * @remarks This function should be called before downloading (see download_start()) \n
+ * This function returns #DOWNLOAD_ERROR_INVALID_PARAMETER if field is zero-length string.
+ * @param [in] download The download id
+ * @param [in] field The name of the HTTP header field
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
+ * @retval #DOWNLOAD_ERROR_FIELD_NOT_FOUND Specified field not found
+ * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
+ * @see download_add_http_header_field()
+ * @see download_get_http_header_field()
+ */
+int download_remove_http_header_field(int download_id, const char *field);
+
+
+/**
+ * @brief Registers a callback function to be invoked when the download state is changed.
+ *
+ * @remarks This function should be called before downloading (see download_start())
+ * @param [in] download The download id
+ * @param [in] callback The callback function to register
+ * @param [in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @post download_state_changed_cb() will be invoked.
+ * @see download_unset_state_changed_cb()
+ * @see download_state_changed_cb()
+*/
+int download_set_state_changed_cb(int download_id, download_state_changed_cb callback, void* user_data);
+
+
+/**
+ * @brief Unregisters the callback function.
+ *
+ * @remarks This function should be called before downloading (see download_start())
+ * @param [in] download The download id
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @see download_set_state_changed_cb()
+ * @see download_state_changed_cb()
+*/
+int download_unset_state_changed_cb(int download_id);
+
+
+/**
+ * @brief Registers a callback function to be invoked when progress of the download changes
+ *
+ * @remarks This function should be called before downloading (see download_start())
+ * @param [in] download The download id
+ * @param [in] callback The callback function to register
+ * @param [in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @post download_progress_cb() will be invoked.
+ * @see download_unset_progress_cb()
+ * @see download_progress_cb()
+*/
+int download_set_progress_cb(int download_id, download_progress_cb callback, void *user_data);
+
+
+/**
+ * @brief Unregisters the callback function.
+ *
+ * @remarks This function should be called before downloading (see download_start())
+ * @param [in] download The download id
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @see download_set_progress_cb()
+ * @see download_progress_cb()
+*/
+int download_unset_progress_cb(int download_id);
+
+
+/**
+ * @brief Starts or resumes the download, asynchronously.
+ *
+ * @details This function starts to download the current URL, or resumes the download if paused.
+ *
+ * @remarks The URL is the mandatory information to start the download.
+ * @remarks It should call download_set_progress_cb() and download_set_state_changed_cb() again \n
+ * after the client process is restarted or download_destry() is called
+ * @param [in] download The download id
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
+ * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
+ * @retval #DOWNLOAD_ERROR_URL Invalid URL
+ * @retval #DOWNLOAD_ERROR_DESTINATION Invalid destination
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @retval #DOWNLOAD_ERROR_QUEUE_FULL Full of queue from download server
+ * @pre The download state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_PAUSED, #DOWNLOAD_STATE_CANCELED, #DOWNLOAD_STATE_FAILED.
+ * @post The download state will be #DOWNLOAD_STATE_QUEUED or #DOWNLOAD_STATE_DOWNLOADING
+ * @see download_set_url()
+ * @see download_pause()
+ * @see download_cancel()
+ */
+int download_start(int download_id);
+
+
+/**
+ * @brief Pauses the download, asynchronously.
+ *
+ * @remarks The paused download can be restarted with download_start() or canceled with download_cancel()
+ * @param [in] download The download id
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
+ * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @pre The download state must be #DOWNLOAD_STATE_DOWNLOADING.
+ * @post The download state will be #DOWNLOAD_STATE_PAUSED.
+ * @see download_start()
+ * @see download_cancel()
+ */
+int download_pause(int download_id);
+
+
+/**
+ * @brief Cancel the download, asynchronously.
+ *
+ * @details This function cancels the running download and its state will be #DOWNLOAD_STATE_READY
+ * @remarks The canceled download can be restarted with download_start().
+ * @param [in] download The download id
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #DOWNLOAD_ERROR_INVALID_STATE Invalid state
+ * @retval #DOWNLOAD_ERROR_IO_ERROR Internal I/O error
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @pre The download state must be #DOWNLOAD_STATE_QUEUED, #DOWNLOAD_STATE_DOWNLOADING, #DOWNLOAD_STATE_PAUSED.
+ * @post The download state will be #DOWNLOAD_STATE_CANCELED.
+ * @see download_start()
+ */
+int download_cancel(int download_id);
+
+
+/**
+ * @brief Gets the download's current state.
+ *
+ * @param [in] download The download id
+ * @param [out] state The current state of the download
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @see #download_state_e
+ */
+int download_get_state(int download_id, download_state_e *state);
+
+
+/**
+ * @brief Gets the full path of temporary file for downloading a content.
+ *
+ * @param [in] download The download id
+ * @param [out] temp_path The full path of temporary file
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @pre The download state must be one of state after #DOWNLOAD_STATE_DOWNLOADING.
+ * @see #download_set_state_changed_cb()
+ * @see #download_unset_state_changed_cb()
+ * @see download_start()
+ */
+int download_get_temp_path(int download_id, char **temp_path);
+
+
+/**
+ * @brief Gets the content name for downloading a file.
+ *
+ * @details This can be defined with reference of HTTP response header data.
+ * The content name can be received when HTTP response header is received.
+ *
+ * @param [in] download The download id
+ * @param [out] content_name The content name for displaying to user
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @pre The download state must be one of state after #DOWNLOAD_STATE_DOWNLOADING.
+ * @see #download_set_state_changed_cb()
+ * @see #download_unset_state_changed_cb()
+ * @see download_start()
+ */
+int download_get_content_name(int download_id, char **content_name);
+
+
+/**
+ * @brief Gets the total size for downloading a content.
+ *
+ * @details This data receive from content server. If the content sever don't send total size of the content, the value set as zero.
+ *
+ * @param [in] download The download id
+ * @param [out] content_size The content size for displaying to user
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @pre The download state must be one of state after #DOWNLOAD_STATE_DOWNLOADING.
+ * @see #download_set_state_changed_cb()
+ * @see #download_unset_state_changed_cb()
+ * @see download_start()
+ */
+int download_get_content_size(int download_id, unsigned long long *content_size);
+
+
+/**
+ * @brief Gets the error value when the download is failed.
+ *
+ * @param [in] download The download id
+ * @param [out] error The error value
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @pre The download state must be #DOWNLOAD_STATE_FAILED.
+ * @pre The download state must be #DOWNLOAD_STATE_CANCELED.
+ * @see #download_set_state_changed_cb()
+ * @see #download_unset_state_changed_cb()
+ * @see download_start()
+ * @see download_error_e
+ */
+int download_get_error(int download_id, download_error_e *error);
+
+
+/**
+ * @brief Gets the http status code when the download error is happened.
+ *
+ * @param [in] download The download id
+ * @param [out] http_status The http status code which is defined in RFC 2616
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @pre The download state must be #DOWNLOAD_STATE_FAILED.
+ * @see #download_set_download_status_cb()
+ * @see #download_unset_download_status_cb()
+ * @see download_start()
+ */
+int download_get_http_status(int download_id, int *http_status);
+
+/**
+ * @brief Sets bundle data to register notification messages.
+ * @details The three types of notification message can be posted. Those are completion, failed and ongoing type.
+ *
+ * @remarks When the notification message is clicked, the action is decided by bundle data. \n
+ * If the bundle data is not set, the following default operation is executed when the notification message is clicked. \n
+ * 1) Download completed state : The viewer application is executed according to extension name of downloaded content. \n
+ * 2) Download failed state and ongoing state : The client application is executed. \n
+ * @remarks This function should be called before starting download.
+ * @remarks The bundle data MUST BE FREED by client when it is not used any more.
+ * @param[in] download The download id
+ * @param[in] type The enumeration type. See #download_notification_bundle_type_e.
+ * @param[in] bundle The bundle pointer value.
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
+ * @see download_set_notification_type()
+ * @see download_get_notification_bundle()
+ */
+int download_set_notification_bundle(int download_id, download_notification_bundle_type_e type, bundle *b);
+
+/**
+ * @brief Get the bundle data to register notification messages which is set in download_set_notification_bundle().
+ *
+ * @details When the notification message is clicked, the action is decided by bundle data. \n
+ * @param[in] download The download id
+ * @param[in] type The enumeration type. See #download_notification_bundle_type_e.
+ * @param[out] bundle The bundle pointer value.
+ * @remarks The bundle data MUST BE FREED by client when it is not used any more.
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @retval #DOWNLOAD_ERROR_NO_DATA the bundle have not been set
+ * @see download_set_notification_bundle()
+ */
+int download_get_notification_bundle(int download_id, download_notification_bundle_type_e type, bundle **b);
+
+/**
+ * @brief Set the title of notification.
+ *
+ * @details When registering notification, the title is displayed at title area of notification message
+ *
+ * @param [in] download The download id
+ * @param [in] title The title for displaying to user
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @pre If the notification option is not enable, this title is not shown to user
+ * @see #download_set_notification_type()
+ * @see #download_get_notification_title()
+ */
+int download_set_notification_title(int download_id, const char *title);
+
+/**
+ * @brief Gets the title of notification when set in #download_set_notification_title()
+ *
+ * @details When registering notification, the title is displayed at title area of notification message
+ *
+ * @param [in] download The download id
+ * @param [out] title The title for displaying to user
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @retval #DOWNLOAD_ERROR_NO_DATA the title have not been set
+ * @pre It can get the title value before calling this API.
+ * @see #download_set_notification_title()
+ */
+int download_get_notification_title(int download_id, char **title);
+
+/**
+ * @brief Set the description of notification.
+ *
+ * @details When registering notification, the description is displayed at description area of notification message
+ *
+ * @param [in] download The download id
+ * @param [in] description The description for displaying to user
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @pre If the notification option is not enable, this description is not shown to user
+ * @see #download_set_notification_type()
+ * @see #download_get_notification_description()
+ */
+int download_set_notification_description(int download_id, const char *description);
+
+/**
+ * @brief Gets the description of notification when set in #download_set_notification_description()
+ *
+ * @details When registering notification, the description is displayed at description area of notification message
+ *
+ * @param [in] download The download id
+ * @param [out] description The description for displaying to user
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @retval #DOWNLOAD_ERROR_NO_DATA the description have not been set
+ * @pre It can get the title value before calling this API.
+ * @see #download_set_notification_description()
+ */
+int download_get_notification_description(int download_id, char **description);
+
+/**
+ * @brief Sets the option value to register notification messages.
+ * @details The three types of notification message can be posted. Those are completion, failed and ongoing type.
+ *
+ * @remarks When the notification message is clicked, the action is decided by bundle data from download_set_notification_bundle(). \n
+ * If the bundle data is not set, the following default operation is executed when the notification message is clicked. \n
+ * 1) Download completed state : The viewer application is executed according to extension name of downloaded content. \n
+ * 2) Download failed state and ongoing state : The client application is executed. \n
+ * @remarks The default type is #DOWNLOAD_NOTIFICATION_TYPE_NONE.
+ * @remarks This function should be called before starting download.
+ * @param[in] download The download id
+ * @param[in] type The enumeration type. See #download_notification_type_e.
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @pre The state must be #DOWNLOAD_STATE_READY, #DOWNLOAD_STATE_FAILED, #DOWNLOAD_STATE_CANCELED
+ * @see download_set_notification_bundle()
+ * @see download_get_notification_type()
+ */
+int download_set_notification_type(int download_id, download_notification_type_e type);
+
+/**
+ * @brief Get the option value to register notification messages which is set in download_set_notification_type().
+ *
+ * @remarks When the notification message is clicked, the action is decided by bundle data from download_set_notification_bundle(). \n
+ * @remarks The default type is #DOWNLOAD_NOTIFICATION_TYPE_NONE.
+ * @param[in] download The download id
+ * @param[out] type The enumeration type. See #download_notification_type_e.
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #DOWNLOAD_ERROR_NONE Successful
+ * @retval #DOWNLOAD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DOWNLOAD_ERROR_ID_NOT_FOUND No Download ID
+ * @see download_set_notification_type()
+ */
+int download_get_notification_type(int download_id, download_notification_type_e *type);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_WEB_DOWNLOAD_H__ */
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include <dlog.h>
+#include <download.h>
+#include <download-provider-interface.h>
+
+#define DEBUG_MSG
+#ifdef DEBUG_MSG
+#include <dlog.h>
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "TIZEN_N_URL_DOWNLOAD"
+#define TRACE_ERROR(format, ARG...) \
+{ \
+LOGE(format, ##ARG); \
+}
+#define TRACE_STRERROR(format, ARG...) \
+{ \
+LOGE(format" [%s]", ##ARG, strerror(errno)); \
+}
+#define TRACE_INFO(format, ARG...) \
+{ \
+LOGI(format, ##ARG); \
+}
+#else
+#define TRACE_DEBUG_MSG(format, ARG...) ;
+#endif
+
+/////////////////////// APIs /////////////////////////////////
+
+int download_create(int *download_id)
+{
+ TRACE_INFO("");
+ return dp_interface_create(download_id);
+}
+
+int download_destroy(int download_id)
+{
+ TRACE_INFO("");
+ return dp_interface_destroy(download_id);
+}
+
+int download_start(int download_id)
+{
+ TRACE_INFO("");
+ return dp_interface_start(download_id);
+}
+
+int download_pause(int download_id)
+{
+ TRACE_INFO("");
+ return dp_interface_pause(download_id);
+}
+
+int download_cancel(int download_id)
+{
+ TRACE_INFO("");
+ return dp_interface_cancel(download_id);
+}
+
+
+int download_set_url(int download_id, const char *url)
+{
+ TRACE_INFO("");
+ return dp_interface_set_url(download_id, url);
+}
+
+
+int download_get_url(int download_id, char **url)
+{
+ TRACE_INFO("");
+ return dp_interface_get_url(download_id, url);
+}
+
+int download_set_network_type(int download_id,
+ download_network_type_e net_type)
+{
+ TRACE_INFO("");
+ return dp_interface_set_network_type(download_id, (int)net_type);
+}
+
+int download_get_network_type(int download_id,
+ download_network_type_e *net_type)
+{
+ TRACE_INFO("");
+
+ if (net_type == NULL) {
+ TRACE_ERROR("Parameter NULL Check");
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ }
+ int network_type = DOWNLOAD_ADAPTOR_NETWORK_ALL;
+ int ret = dp_interface_get_network_type(download_id, &network_type);
+ if (ret == DOWNLOAD_ADAPTOR_ERROR_NONE)
+ *net_type = network_type;
+ return ret;
+}
+
+int download_set_destination(int download_id, const char *path)
+{
+ TRACE_INFO("");
+ return dp_interface_set_destination(download_id, path);
+}
+
+
+int download_get_destination(int download_id, char **path)
+{
+ TRACE_INFO("");
+ return dp_interface_get_destination(download_id, path);
+}
+
+int download_set_file_name(int download_id, const char *file_name)
+{
+ TRACE_INFO("");
+ return dp_interface_set_file_name(download_id, file_name);
+}
+
+int download_get_file_name(int download_id, char **file_name)
+{
+ TRACE_INFO("");
+ return dp_interface_get_file_name(download_id, file_name);
+}
+
+int download_set_notification(int download_id, bool enable)
+{
+ TRACE_INFO("");
+ return dp_interface_set_notification(download_id, (int)enable);
+}
+
+int download_get_notification(int download_id, bool *enable)
+{
+ int is_set = 0;
+ TRACE_INFO("");
+ if (enable == NULL) {
+ TRACE_ERROR("Parameter NULL Check");
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ }
+ int ret = dp_interface_get_notification(download_id, &is_set);
+ if (ret == DOWNLOAD_ADAPTOR_ERROR_NONE)
+ *enable = (bool)is_set;
+ return ret;
+}
+
+int download_get_downloaded_file_path(int download_id, char **path)
+{
+ TRACE_INFO("");
+ return dp_interface_get_downloaded_file_path(download_id, path);
+}
+
+int download_add_notification_extra_param(
+ int download_id, const char *key,
+ const char **value, const unsigned int length)
+{
+ TRACE_INFO("");
+ return dp_interface_add_noti_extra(download_id, key, value, length);
+}
+
+int download_remove_notification_extra_param(int download_id, const char *key)
+{
+ TRACE_INFO("");
+ return dp_interface_remove_noti_extra_key(download_id, key);
+}
+
+int download_get_notification_extra_param(
+ int download_id, const char *key,
+ char ***values, unsigned int *length)
+{
+ TRACE_INFO("");
+ return dp_interface_get_noti_extra_values(download_id, key, values, length);
+}
+
+int download_add_http_header_field(int download_id, const char *field,
+ const char *value)
+{
+ TRACE_INFO("");
+ return
+ dp_interface_add_http_header_field(download_id, field, value);
+}
+
+int download_get_http_header_field(int download_id,
+ const char *field, char **value)
+{
+ TRACE_INFO("");
+ return
+ dp_interface_get_http_header_field(download_id, field, value);
+}
+
+int download_get_http_header_field_list(int download_id, char ***fields,
+ int *length)
+{
+ TRACE_INFO("");
+ return dp_interface_get_http_header_field_list(download_id, fields,
+ length);
+}
+
+int download_remove_http_header_field(int download_id,
+ const char *field)
+{
+ TRACE_INFO("");
+ return dp_interface_remove_http_header_field(download_id, field);
+}
+
+// download_state_changed_cb is different with dp_interface_state_changed_cb.
+int download_set_state_changed_cb(int download_id,
+ download_state_changed_cb callback, void* user_data)
+{
+ TRACE_INFO("");
+ return dp_interface_set_state_changed_cb(download_id,
+ (dp_interface_state_changed_cb)callback, user_data);
+}
+
+int download_unset_state_changed_cb(int download_id)
+{
+ TRACE_INFO("");
+ return dp_interface_unset_state_changed_cb(download_id);
+}
+
+// download_progress_cb is same with dp_interface_progress_cb.
+int download_set_progress_cb(int download_id,
+ download_progress_cb callback, void *user_data)
+{
+ TRACE_INFO("");
+ return dp_interface_set_progress_cb(download_id,
+ (dp_interface_progress_cb)callback, user_data);
+}
+
+int download_unset_progress_cb(int download_id)
+{
+ TRACE_INFO("");
+ return dp_interface_unset_progress_cb(download_id);
+}
+
+int download_get_state(int download_id, download_state_e *state)
+{
+ int statecode = 0;
+ TRACE_INFO("");
+ if (state == NULL) {
+ TRACE_ERROR("Parameter NULL Check");
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ }
+ int ret = dp_interface_get_state(download_id, &statecode);
+ if (ret == DOWNLOAD_ADAPTOR_ERROR_NONE)
+ *state = statecode;
+ return ret;
+}
+
+int download_get_temp_path(int download_id, char **temp_path)
+{
+ TRACE_INFO("");
+ return dp_interface_get_temp_path(download_id, temp_path);
+}
+
+int download_get_content_name(int download_id, char **content_name)
+{
+ TRACE_INFO("");
+ return dp_interface_get_content_name(download_id, content_name);
+}
+
+int download_get_content_size(int download_id,
+ unsigned long long *content_size)
+{
+ TRACE_INFO("");
+ return dp_interface_get_content_size(download_id, content_size);
+}
+
+int download_get_mime_type(int download_id, char **mime_type)
+{
+ TRACE_INFO("");
+ return dp_interface_get_mime_type(download_id, mime_type);
+}
+
+int download_set_auto_download(int download_id, bool enable)
+{
+ TRACE_INFO("");
+ return dp_interface_set_auto_download(download_id, (int)enable);
+}
+
+int download_get_auto_download(int download_id, bool *enable)
+{
+ int is_set = 0;
+ TRACE_INFO("");
+ if (enable == NULL) {
+ TRACE_ERROR("Parameter NULL Check");
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ }
+ int ret = dp_interface_get_auto_download(download_id, &is_set);
+ if (ret == DOWNLOAD_ADAPTOR_ERROR_NONE)
+ *enable = (bool)is_set;
+ return ret;
+}
+
+int download_get_error(int download_id, download_error_e *error)
+{
+ int errorcode = 0;
+ TRACE_INFO("");
+ if (error == NULL) {
+ TRACE_ERROR("Parameter NULL Check");
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ }
+ int ret = dp_interface_get_error(download_id, &errorcode);
+ if (ret == DOWNLOAD_ADAPTOR_ERROR_NONE)
+ *error = errorcode;
+ return ret;
+}
+
+int download_get_http_status(int download_id, int *http_status)
+{
+ TRACE_INFO("");
+ return dp_interface_get_http_status(download_id, http_status);
+}
+
+int download_set_notification_bundle(int download_id, download_notification_bundle_type_e type, bundle *b)
+{
+ TRACE_INFO("");
+ return dp_interface_set_notification_bundle(download_id, (int)type, b);
+}
+
+int download_get_notification_bundle(int download_id, download_notification_bundle_type_e type, bundle **b)
+{
+ TRACE_INFO("");
+ return dp_interface_get_notification_bundle(download_id, (int)type, b);
+}
+
+int download_set_notification_title(int download_id, const char *title)
+{
+ TRACE_INFO("");
+ return dp_interface_set_notification_title(download_id, title);
+}
+
+int download_get_notification_title(int download_id, char **title)
+{
+ TRACE_INFO("");
+ return dp_interface_get_notification_title(download_id, title);
+}
+
+int download_set_notification_description(int download_id, const char *description)
+{
+ TRACE_INFO("");
+ return dp_interface_set_notification_description(download_id, description);
+}
+
+int download_get_notification_description(int download_id, char **description)
+{
+ TRACE_INFO("");
+ return dp_interface_get_notification_description(download_id, description);
+}
+
+int download_set_notification_type(int download_id, download_notification_type_e type)
+{
+ TRACE_INFO("");
+ return dp_interface_set_notification_type(download_id, (int)type);
+}
+
+int download_get_notification_type(int download_id, download_notification_type_e *type)
+{
+ int noti_type = 0;
+ TRACE_INFO("");
+ if (type == NULL) {
+ TRACE_ERROR("Parameter NULL Check");
+ return DOWNLOAD_ERROR_INVALID_PARAMETER;
+ }
+ int ret = dp_interface_get_notification_type(download_id, ¬i_type);
+ if (ret == DOWNLOAD_ADAPTOR_ERROR_NONE)
+ *type = (download_notification_type_e)noti_type;
+ return ret;
+}
+