diff options
Diffstat (limited to 'agent/download-agent-interface.c')
-rwxr-xr-x | agent/download-agent-interface.c | 224 |
1 files changed, 71 insertions, 153 deletions
diff --git a/agent/download-agent-interface.c b/agent/download-agent-interface.c index 7d994e6..0b19813 100755 --- a/agent/download-agent-interface.c +++ b/agent/download-agent-interface.c @@ -15,214 +15,131 @@ */ #include "download-agent-interface.h" -#include "download-agent-debug.h" -#include "download-agent-utils.h" -#include "download-agent-http-mgr.h" -#include "download-agent-http-misc.h" -#include "download-agent-client-mgr.h" #include "download-agent-dl-mgr.h" -#include "download-agent-basic.h" -#include "download-agent-file.h" -int da_init( - da_client_cb_t *da_client_callback) +int da_init() { - da_result_t ret = DA_RESULT_OK; - - DA_LOG_FUNC_LOGD(Default); - - if (!da_client_callback) { - ret = DA_ERR_INVALID_ARGUMENT; - return ret; - } - - ret = init_log_mgr(); - if (ret != DA_RESULT_OK) - goto ERR; - - ret = init_client_app_mgr(); - if (ret != DA_RESULT_OK) - goto ERR; - - ret = reg_client_app(da_client_callback); - if (ret != DA_RESULT_OK) - goto ERR; - - ret = init_http_mgr(); - if (ret != DA_RESULT_OK) - goto ERR; - - ret = init_download_mgr(); - if (ret != DA_RESULT_OK) - goto ERR; - -ERR: - if (DA_RESULT_OK != ret) - da_deinit(); - - DA_LOG_CRITICAL(Default, "Return ret = %d", ret); - + DA_LOGV(""); + da_ret_t ret = DA_RESULT_OK; + DA_LOGI("Return ret = %d", ret); return ret; } -/* TODO:: deinit should clean up all the clients... */ int da_deinit() { - da_result_t ret = DA_RESULT_OK; - - DA_LOG_FUNC_LOGV(Default); - - deinit_http_mgr(); - deinit_download_mgr(); - /* Do not clean temporary download path - * The client can resume or restart download with temporary file in case of failed download. - */ - dereg_client_app(); - DA_LOG(Default, "====== da_deinit EXIT ====="); + da_ret_t ret = DA_RESULT_OK; + DA_LOGV(""); + destroy_da_info_list(); + DA_LOGI("====== da_deint EXIT ====="); return ret; } -int da_start_download( - const char *url, - int *download_id) +int da_start_download(const char *url, req_data_t *ext_data, + da_cb_t *da_cb_data, int *download_id) { - da_result_t ret = DA_RESULT_OK; - - DA_LOG_FUNC_LOGD(Default); - - *download_id = DA_INVALID_ID; - - if (DA_FALSE == is_valid_url(url, &ret)) - goto ERR; - - DA_SECURE_LOGI("url = %s", url); - - ret = start_download(url, download_id); - if (ret != DA_RESULT_OK) - goto ERR; - -ERR: - DA_LOG_CRITICAL(Default, "Return: Dl req id = %d, ret = %d", *download_id, ret); - return ret; -} - -int da_start_download_with_extension( - const char *url, - extension_data_t *extension_data, - int *download_id -) -{ - da_result_t ret = DA_RESULT_OK; + da_ret_t ret = DA_RESULT_OK; int req_header_count = 0; int i = 0; - - DA_LOG_FUNC_LOGV(Default); + int da_id = DA_INVALID_ID; + da_info_t *da_info = DA_NULL; *download_id = DA_INVALID_ID; - if (DA_FALSE == is_valid_url(url, &ret)) - goto ERR; - - DA_SECURE_LOGI("url = %s", url); - - if (ret != DA_RESULT_OK) - goto ERR; - if (!extension_data) { - ret = DA_ERR_INVALID_ARGUMENT; - goto ERR; - } - - if (extension_data->request_header_count > 0) { - DA_LOG_VERBOSE(Default, "input request_header_count = [%d]", - extension_data->request_header_count); - for (i = 0; i < extension_data->request_header_count; i++) { - if (extension_data->request_header[i]) { + if (ext_data->request_header_count > 0) { + DA_LOGI("request_header_count[%d]", ext_data->request_header_count); + for (i = 0; i < ext_data->request_header_count; i++) { + if (ext_data->request_header[i]) { req_header_count++; - DA_SECURE_LOGI("request_header = [%s]", - extension_data->request_header[i]); + DA_SECURE_LOGI("request_header[%s]", ext_data->request_header[i]); } } - DA_LOG_VERBOSE(Default, "actual request_header_count = [%d]", req_header_count); - if (extension_data->request_header_count != req_header_count) { - DA_LOG_ERR(Default, "Request header count is not matched with number of request header array"); - extension_data->request_header = NULL; - extension_data->request_header_count = 0; + DA_LOGI("actual request_header_count[%d]", req_header_count); + if (ext_data->request_header_count != req_header_count) { + DA_LOGE("Request header count is not matched with number of request header array"); ret = DA_ERR_INVALID_ARGUMENT; goto ERR; } } - if (extension_data->install_path) { - if (!is_dir_exist(extension_data->install_path)) - return DA_ERR_INVALID_INSTALL_PATH; - DA_SECURE_LOGI("install_path = [%s]", extension_data->install_path); - } - - if (extension_data->file_name) - DA_SECURE_LOGI("file_name = [%s]", extension_data->file_name); - if (extension_data->temp_file_path) - DA_SECURE_LOGI("temp_file_path = [%s]", extension_data->temp_file_path); - if (extension_data->etag) - DA_SECURE_LOGI("etag = [%s]", extension_data->etag); - if (extension_data->pkg_name) - DA_SECURE_LOGI("pkg_name = [%s]", extension_data->pkg_name); - if (extension_data->user_data) - DA_LOG_VERBOSE(Default, "user_data = [%p]", extension_data->user_data); + if (ext_data->install_path) + DA_SECURE_LOGI("install path[%s]", ext_data->install_path); + if (ext_data->file_name) + DA_SECURE_LOGI("file_name[%s]", ext_data->file_name); + if (ext_data->temp_file_path) + DA_SECURE_LOGI("temp_file_path[%s]", ext_data->temp_file_path); + if (ext_data->etag) + DA_SECURE_LOGI("etag[%s]", ext_data->etag); + if (ext_data->pkg_name) + DA_SECURE_LOGI("pkg_name[%s]", ext_data->pkg_name); + if (ext_data->network_bonding) + DA_LOGD("network bonding option[%d]", ext_data->network_bonding); + if (ext_data->user_req_data) + DA_LOGI("user_req_data[%p]", ext_data->user_req_data); + if (ext_data->user_client_data) + DA_LOGI("user_client_data[%p]", ext_data->user_client_data); + + ret = get_available_da_id(&da_id); + if (ret != DA_RESULT_OK) + goto ERR; - ret = start_download_with_extension(url, download_id, extension_data); + da_info = da_info_list[da_id]; + da_info->da_id = da_id; + ret = copy_user_input_data(da_info, url, ext_data, da_cb_data); + if (ret != DA_RESULT_OK) + goto ERR; + *download_id = da_id; + ret = start_download(da_info); ERR: - DA_LOG_CRITICAL(Default, "Return: Dl req id = %d, ret = %d", *download_id, ret); + DA_LOGI("Return:id[%d],ret[%d]", *download_id, ret); return ret; } int da_cancel_download(int download_id) { - da_result_t ret = DA_RESULT_OK; - - DA_LOG_VERBOSE(Default, "Cancel for dl_id = %d", download_id); + da_ret_t ret = DA_RESULT_OK; - ret = cancel_download(download_id); + DA_LOGV("download_id[%d]", download_id); + ret = cancel_download(download_id, DA_TRUE); + DA_LOGI("Return:id[%d],ret[%d]", download_id, ret); + return ret; +} - DA_LOG_CRITICAL(Default, "Return: Cancel id = %d, ret = %d", download_id, ret); +int da_cancel_download_without_update(int download_id) +{ + da_ret_t ret = DA_RESULT_OK; + DA_LOGV("download_id[%d]", download_id); + ret = cancel_download(download_id, DA_FALSE); + DA_LOGI("Return:id[%d],ret[%d]", download_id, ret); return ret; } int da_suspend_download(int download_id) { - da_result_t ret = DA_RESULT_OK; - - DA_LOG_VERBOSE(Default, "Suspend for dl_id = %d", download_id); - + da_ret_t ret = DA_RESULT_OK; + DA_LOGV("download_id[%d]", download_id); ret = suspend_download(download_id, DA_TRUE); - - DA_LOG_CRITICAL(Default, "Return: Suspend id = %d, ret = %d", download_id, ret); + DA_LOGI("Return:id[%d],ret[%d]", download_id, ret); return ret; } int da_suspend_download_without_update(int download_id) { - da_result_t ret = DA_RESULT_OK; - - DA_LOG_VERBOSE(Default, "Suspend for dl_id = %d", download_id); - + da_ret_t ret = DA_RESULT_OK; + DA_LOGV("download_id[%d]", download_id); ret = suspend_download(download_id, DA_FALSE); - - DA_LOG_CRITICAL(Default, "Return: Suspend id = %d, ret = %d", download_id, ret); + DA_LOGI("Return:id[%d],ret[%d]", download_id, ret); return ret; } int da_resume_download(int download_id) { - da_result_t ret = DA_RESULT_OK; - - DA_LOG_VERBOSE(Default, "Resume for dl_id = %d", download_id); - + da_ret_t ret = DA_RESULT_OK; + DA_LOGV("download_id[%d]", download_id); ret = resume_download(download_id); - - DA_LOG_CRITICAL(Default, "Return: Resume id = %d, ret = %d", download_id, ret); + DA_LOGI("Return:id[%d],ret[%d]", download_id, ret); return ret; } @@ -230,5 +147,6 @@ int da_is_valid_download_id(int download_id) { da_bool_t ret = DA_FALSE; ret = is_valid_download_id(download_id); + DA_LOGI("Return:id[%d],ret[%d]", download_id, ret); return ret; } |