5 #include <sys/socket.h>
13 #include <download-provider-interface.h>
21 #define LOG_TAG "TIZEN_N_URL_DOWNLOAD"
22 #define TRACE_ERROR(format, ARG...) \
24 LOGE(format, ##ARG); \
26 #define TRACE_STRERROR(format, ARG...) \
28 LOGE(format" [%s]", ##ARG, strerror(errno)); \
30 #define TRACE_INFO(format, ARG...) \
32 LOGI(format, ##ARG); \
35 #define TRACE_DEBUG_MSG(format, ARG...) ;
38 /////////////////////// APIs /////////////////////////////////
40 int download_create(int *download_id)
43 return dp_interface_create(download_id);
46 int download_destroy(int download_id)
49 return dp_interface_destroy(download_id);
52 int download_start(int download_id)
55 return dp_interface_start(download_id);
58 int download_pause(int download_id)
61 return dp_interface_pause(download_id);
64 int download_cancel(int download_id)
67 return dp_interface_cancel(download_id);
71 int download_set_url(int download_id, const char *url)
74 return dp_interface_set_url(download_id, url);
78 int download_get_url(int download_id, char **url)
81 return dp_interface_get_url(download_id, url);
84 int download_set_network_type(int download_id,
85 download_network_type_e net_type)
88 return dp_interface_set_network_type(download_id, (int)net_type);
91 int download_get_network_type(int download_id,
92 download_network_type_e *net_type)
96 int network_type = DOWNLOAD_ADAPTOR_NETWORK_ALL;
97 int ret = dp_interface_get_network_type(download_id, &network_type);
98 if (ret == DOWNLOAD_ADAPTOR_ERROR_NONE)
99 *net_type = network_type;
103 int download_set_destination(int download_id, const char *path)
106 return dp_interface_set_destination(download_id, path);
110 int download_get_destination(int download_id, char **path)
113 return dp_interface_get_destination(download_id, path);
116 int download_set_file_name(int download_id, const char *file_name)
119 return dp_interface_set_file_name(download_id, file_name);
122 int download_get_file_name(int download_id, char **file_name)
125 return dp_interface_get_file_name(download_id, file_name);
128 int download_set_ongoing_notification(int download_id, bool enable)
130 return download_set_notification(download_id, enable);
133 int download_set_notification(int download_id, bool enable)
136 return dp_interface_set_notification(download_id, (int)enable);
139 int download_get_ongoing_notification(int download_id, bool *enable)
141 return download_get_notification(download_id, enable);
144 int download_get_notification(int download_id, bool *enable)
149 int ret = dp_interface_get_notification(download_id, &is_set);
150 if (ret == DOWNLOAD_ADAPTOR_ERROR_NONE)
151 *enable = (bool)is_set;
155 int download_get_downloaded_file_path(int download_id, char **path)
158 return dp_interface_get_downloaded_file_path(download_id, path);
161 int download_add_notification_extra_param(
162 int download_id, const char *key,
163 const char **value, const unsigned int length)
166 return dp_interface_add_noti_extra(download_id, key, value, length);
169 int download_remove_notification_extra_param(int download_id, const char *key)
172 return dp_interface_remove_noti_extra_key(download_id, key);
175 int download_get_notification_extra_param(
176 int download_id, const char *key,
177 char ***values, unsigned int *length)
180 return dp_interface_get_noti_extra_values(download_id, key, values, length);
183 int download_add_http_header_field(int download_id, const char *field,
188 dp_interface_add_http_header_field(download_id, field, value);
191 int download_get_http_header_field(int download_id,
192 const char *field, char **value)
196 dp_interface_get_http_header_field(download_id, field, value);
199 int download_remove_http_header_field(int download_id,
203 return dp_interface_remove_http_header_field(download_id, field);
206 // download_state_changed_cb is different with dp_interface_state_changed_cb.
207 int download_set_state_changed_cb(int download_id,
208 download_state_changed_cb callback, void* user_data)
211 return dp_interface_set_state_changed_cb(download_id,
212 (dp_interface_state_changed_cb)callback, user_data);
215 int download_unset_state_changed_cb(int download_id)
218 return dp_interface_unset_state_changed_cb(download_id);
221 // download_progress_cb is same with dp_interface_progress_cb.
222 int download_set_progress_cb(int download_id,
223 download_progress_cb callback, void *user_data)
226 return dp_interface_set_progress_cb(download_id,
227 (dp_interface_progress_cb)callback, user_data);
230 int download_unset_progress_cb(int download_id)
233 return dp_interface_unset_progress_cb(download_id);
236 int download_get_state(int download_id, download_state_e *state)
241 int ret = dp_interface_get_state(download_id, &statecode);
242 if (ret == DOWNLOAD_ADAPTOR_ERROR_NONE)
247 int download_get_temp_path(int download_id, char **temp_path)
250 return dp_interface_get_temp_path(download_id, temp_path);
253 int download_get_content_name(int download_id, char **content_name)
256 return dp_interface_get_content_name(download_id, content_name);
259 int download_get_content_size(int download_id,
260 unsigned long long *content_size)
263 return dp_interface_get_content_size(download_id, content_size);
266 int download_get_mime_type(int download_id, char **mime_type)
269 return dp_interface_get_mime_type(download_id, mime_type);
272 int download_set_auto_download(int download_id, bool enable)
275 return dp_interface_set_auto_download(download_id, (int)enable);
278 int download_get_auto_download(int download_id, bool *enable)
283 int ret = dp_interface_get_auto_download(download_id, &is_set);
284 if (ret == DOWNLOAD_ADAPTOR_ERROR_NONE)
285 *enable = (bool)is_set;
289 int download_get_error(int download_id, download_error_e *error)
294 int ret = dp_interface_get_error(download_id, &errorcode);
295 if (ret == DOWNLOAD_ADAPTOR_ERROR_NONE)
300 int download_get_http_status(int download_id, int *http_status)
303 return dp_interface_get_http_status(download_id, http_status);