e9d3d59b97a555fb7e050392e54ccfb9ccf98a8e
[platform/framework/web/download-provider.git] / provider-interface / include / download-provider-interface.h
1 /*
2  * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __DOWNLOAD_PROVIDER_INTERFACE_H__
18 #define __DOWNLOAD_PROVIDER_INTERFACE_H__
19
20 #ifndef EXPORT_API
21 #define EXPORT_API __attribute__((visibility("default")))
22 #endif
23
24 #include <tizen.h>
25
26 #ifdef __cplusplus
27 extern "C"
28 {
29 #endif
30
31 // sync with url-download
32 typedef enum
33 {
34         DOWNLOAD_ADPATOR_STATE_NONE,
35         DOWNLOAD_ADPATOR_STATE_READY,
36         DOWNLOAD_ADPATOR_STATE_QUEUED,
37         DOWNLOAD_ADPATOR_STATE_DOWNLOADING,
38         DOWNLOAD_ADPATOR_STATE_PAUSED,
39         DOWNLOAD_ADPATOR_STATE_COMPLETED,
40         DOWNLOAD_ADPATOR_STATE_FAILED,
41         DOWNLOAD_ADPATOR_STATE_CANCELED,
42 } download_adaptor_state_e;
43
44 typedef enum
45 {
46         DOWNLOAD_ADAPTOR_NETWORK_DATA_NETWORK,
47         DOWNLOAD_ADAPTOR_NETWORK_WIFI,
48         DOWNLOAD_ADAPTOR_NETWORK_WIFI_DIRECT,
49         DOWNLOAD_ADAPTOR_NETWORK_ALL
50 } download_adaptor_network_type_e ;
51
52 typedef enum
53 {
54         DOWNLOAD_ADAPTOR_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
55         DOWNLOAD_ADAPTOR_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
56         DOWNLOAD_ADAPTOR_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
57         DOWNLOAD_ADAPTOR_ERROR_NETWORK_UNREACHABLE = TIZEN_ERROR_NETWORK_UNREACHABLE, /**< Network is unreachable */
58         DOWNLOAD_ADAPTOR_ERROR_CONNECTION_TIMED_OUT = TIZEN_ERROR_CONNECTION_TIME_OUT, /**< Http session time-out */
59         DOWNLOAD_ADAPTOR_ERROR_NO_SPACE = TIZEN_ERROR_FILE_NO_SPACE_ON_DEVICE, /**< No space left on device */
60         DOWNLOAD_ADAPTOR_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
61     DOWNLOAD_ADAPTOR_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED,               /**< Not supported */
62         DOWNLOAD_ADAPTOR_ERROR_INVALID_STATE = TIZEN_ERROR_DOWNLOAD | 0x21, /**< Invalid state */
63         DOWNLOAD_ADAPTOR_ERROR_CONNECTION_FAILED = TIZEN_ERROR_DOWNLOAD | 0x22, /**< Connection failed */
64         DOWNLOAD_ADAPTOR_ERROR_INVALID_URL = TIZEN_ERROR_DOWNLOAD | 0x24, /**< Invalid URL */
65         DOWNLOAD_ADAPTOR_ERROR_INVALID_DESTINATION = TIZEN_ERROR_DOWNLOAD | 0x25, /**< Invalid destination */
66         DOWNLOAD_ADAPTOR_ERROR_TOO_MANY_DOWNLOADS = TIZEN_ERROR_DOWNLOAD | 0x26, /**< Full of available simultaneous downloads */
67         DOWNLOAD_ADAPTOR_ERROR_QUEUE_FULL = TIZEN_ERROR_DOWNLOAD | 0x27, /**< Full of available downloading items from server*/
68         DOWNLOAD_ADAPTOR_ERROR_ALREADY_COMPLETED = TIZEN_ERROR_DOWNLOAD | 0x28, /**< The download is already completed */
69         DOWNLOAD_ADAPTOR_ERROR_FILE_ALREADY_EXISTS = TIZEN_ERROR_DOWNLOAD | 0x29, /**< It is failed to rename the downloaded file */
70         DOWNLOAD_ADAPTOR_ERROR_CANNOT_RESUME = TIZEN_ERROR_DOWNLOAD | 0x2a, /**< It cannot resume */
71     DOWNLOAD_ADAPTOR_ERROR_FIELD_NOT_FOUND = TIZEN_ERROR_DOWNLOAD | 0x2b,           /**< Specified field not found */
72         DOWNLOAD_ADAPTOR_ERROR_TOO_MANY_REDIRECTS = TIZEN_ERROR_DOWNLOAD | 0x30, /**< In case of too may redirects from http response header*/
73         DOWNLOAD_ADAPTOR_ERROR_UNHANDLED_HTTP_CODE = TIZEN_ERROR_DOWNLOAD | 0x31,  /**< The download cannot handle the http status value */
74         DOWNLOAD_ADAPTOR_ERROR_REQUEST_TIMEOUT = TIZEN_ERROR_DOWNLOAD | 0x32, /**< There are no action after client create a download id*/
75         DOWNLOAD_ADAPTOR_ERROR_RESPONSE_TIMEOUT = TIZEN_ERROR_DOWNLOAD | 0x33, /**< It does not call start API in some time although the download is created*/
76         DOWNLOAD_ADAPTOR_ERROR_SYSTEM_DOWN = TIZEN_ERROR_DOWNLOAD | 0x34, /**< There are no response from client after rebooting download daemon*/
77         DOWNLOAD_ADAPTOR_ERROR_ID_NOT_FOUND = TIZEN_ERROR_DOWNLOAD | 0x35, /**< The download id is not existed in download service module*/
78         DOWNLOAD_ADAPTOR_ERROR_INVALID_NETWORK_TYPE = TIZEN_ERROR_DOWNLOAD | 0x36, /**< error when setting network bonding and network all is not set */
79         DOWNLOAD_ADAPTOR_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA, /**< No data because the set API is not called */
80         DOWNLOAD_ADAPTOR_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR /**< Internal I/O error */
81 } download_adaptor_error_e;
82
83 // sync types with url-download..
84 typedef void (*dp_interface_state_changed_cb) (int id, int state, void *user_data);
85 typedef void (*dp_interface_progress_cb) (int id, unsigned long long received, void *user_data);
86
87 EXPORT_API int dp_interface_set_state_changed_cb
88         (const int id, dp_interface_state_changed_cb callback, void *user_data);
89 EXPORT_API int dp_interface_unset_state_changed_cb(int id);
90 EXPORT_API int dp_interface_set_progress_cb
91         (const int id, dp_interface_progress_cb callback, void *user_data);
92 EXPORT_API int dp_interface_unset_progress_cb(const int id);
93
94 EXPORT_API int dp_interface_create(int *id);
95 EXPORT_API int dp_interface_destroy(const int id);
96
97 EXPORT_API int dp_interface_start(const int id);
98 EXPORT_API int dp_interface_pause(const int id);
99 EXPORT_API int dp_interface_cancel(const int id);
100
101 EXPORT_API int dp_interface_set_url(const int id, const char *url);
102 EXPORT_API int dp_interface_set_destination(const int id, const char *path);
103 EXPORT_API int dp_interface_set_file_name(const int id, const char *file_name);
104 EXPORT_API int dp_interface_set_network_type(const int id, int net_type);
105 EXPORT_API int dp_interface_set_network_bonding(const int id, int enable);
106 EXPORT_API int dp_interface_set_auto_download(const int id, int enable);
107 EXPORT_API int dp_interface_get_url(const int id, char **url);
108 EXPORT_API int dp_interface_get_network_type(const int id, int *net_type);
109 EXPORT_API int dp_interface_get_network_bonding(const int id, int *enable);
110 EXPORT_API int dp_interface_get_destination(const int id, char **path);
111 EXPORT_API int dp_interface_get_file_name(const int id, char **file_name);
112 EXPORT_API int dp_interface_get_downloaded_file_path(const int id, char **path);
113 EXPORT_API int dp_interface_get_mime_type(const int id, char **mime_type);
114 EXPORT_API int dp_interface_get_auto_download(const int id, int *enable);
115 EXPORT_API int dp_interface_get_state(const int id, int *state);
116 EXPORT_API int dp_interface_get_temp_path(const int id, char **temp_path);
117 EXPORT_API int dp_interface_get_content_name(const int id, char **content_name);
118 EXPORT_API int dp_interface_get_content_size(const int id, unsigned long long *content_size);
119 EXPORT_API int dp_interface_get_error(const int id, int *error);
120 EXPORT_API int dp_interface_get_http_status(const int id, int *http_status);
121 EXPORT_API int dp_interface_get_etag(const int id, char **etag);
122 EXPORT_API int dp_interface_set_temp_file_path(const int id, const char *path);
123
124 EXPORT_API int dp_interface_add_http_header_field(const int id, const char *field, const char *value);
125 EXPORT_API int dp_interface_get_http_header_field(const int id, const char *field, char **value);
126 EXPORT_API int dp_interface_get_http_header_field_list(const int id, char ***fields, int *length);
127 EXPORT_API int dp_interface_remove_http_header_field(const int id, const char *field);
128
129 EXPORT_API int dp_interface_set_notification_bundle(const int id, const int type, void *bundle_param);
130 EXPORT_API int dp_interface_get_notification_bundle(const int id, const int type, void **bundle_param);
131 EXPORT_API int dp_interface_set_notification_service_handle(const int id, const int type, void *handle);
132 EXPORT_API int dp_interface_get_notification_service_handle(const int id, const int type, void **handle);
133 EXPORT_API int dp_interface_set_notification_title(const int id, const char *title);
134 EXPORT_API int dp_interface_get_notification_title(const int id, char **title);
135 EXPORT_API int dp_interface_set_notification_description(const int id, const char *description);
136 EXPORT_API int dp_interface_get_notification_description(const int id, char **description);
137 EXPORT_API int dp_interface_set_notification_type(const int id, int type);
138 EXPORT_API int dp_interface_get_notification_type(const int id, int *type);
139 #ifdef __cplusplus
140 }
141 #endif
142
143 #endif /* __DOWNLOAD_PROVIDER_INTERFACE_H__ */