Need an API in download provider to set http proxy from app side.
There was no API defined in download provider interface for setting proxy.
Added new API dp_interface_{set,get}_proxy()
Change-Id: Ie79d34cebd4c27f372c7e50a42a0a809f88ca165
Signed-off-by: Sowmya B <sowmya.b1@samsung.com>
if (url)
req_info->url = strdup(url);
+ if (ext_data->proxy)
+ req_info->proxy = strdup(ext_data->proxy);
if (ext_data->install_path)
req_info->install_path = strdup(ext_data->install_path);
if (ext_data->file_name)
req_info->req_header = DA_NULL;
req_info->req_header_count = 0;
}
+ NULL_CHECK_AND_FREE(req_info->proxy);
NULL_CHECK_AND_FREE(req_info->install_path);
NULL_CHECK_AND_FREE(req_info->file_name);
NULL_CHECK_AND_FREE(req_info->etag);
return DA_ERR_INVALID_ARGUMENT;
}
http_info->http_method = HTTP_METHOD_GET;
- http_info->proxy_addr = get_proxy_address();
+ char* proxy_addr = da_info->req_info->proxy;
+ if (proxy_addr && strlen(proxy_addr) > 0) {
+ DA_LOGI("User proxy : %s", proxy_addr);
+ http_info->proxy_addr = strdup(proxy_addr);
+ } else {
+ http_info->proxy_addr = get_proxy_address();
+ }
ret = PI_http_start(da_info);
}
}
+ if (ext_data->proxy)
+ DA_SECURE_LOGI("proxy[%s]", ext_data->proxy);
if (ext_data->install_path)
DA_SECURE_LOGI("install path[%s]", ext_data->install_path);
if (ext_data->file_name)
typedef struct {
char *url;
+ char *proxy;
char **req_header;
int req_header_count;
char *install_path;
typedef struct {
const char **request_header;
int request_header_count;
+ const char *proxy;
const char *install_path;
const char *file_name;
const char *temp_file_path;
return __dp_ipc_get_string(id, DP_PROP_URL, url, __FUNCTION__);
}
+int dp_interface_set_proxy(const int id, const char *proxy)
+{
+ if (proxy == NULL)
+ return __dp_ipc_echo(id, DP_SEC_UNSET, DP_PROP_PROXY, __FUNCTION__);
+ if (proxy && strlen(proxy) == 0) {
+ char* invalid_proxy = "0.0.0.0";
+ return __dp_ipc_set_string(id, DP_SEC_SET, DP_PROP_PROXY, invalid_proxy, __FUNCTION__);
+ }
+ return __dp_ipc_set_string(id, DP_SEC_SET, DP_PROP_PROXY, proxy, __FUNCTION__);
+}
+
+int dp_interface_get_proxy(const int id, char **proxy)
+{
+ return __dp_ipc_get_string(id, DP_PROP_PROXY, proxy, __FUNCTION__);
+}
+
int dp_interface_set_destination(const int id, const char *path)
{
char set_filename[DOWNLOAD_FILENAME_MAX] = {0, };
EXPORT_API int dp_interface_cancel(const int id);
EXPORT_API int dp_interface_set_url(const int id, const char *url);
+EXPORT_API int dp_interface_set_proxy(const int id, const char *proxy);
EXPORT_API int dp_interface_set_destination(const int id, const char *path);
EXPORT_API int dp_interface_set_file_name(const int id, const char *file_name);
EXPORT_API int dp_interface_set_network_type(const int id, int net_type);
EXPORT_API int dp_interface_set_network_bonding(const int id, int enable);
EXPORT_API int dp_interface_set_auto_download(const int id, int enable);
EXPORT_API int dp_interface_get_url(const int id, char **url);
+EXPORT_API int dp_interface_get_proxy(const int id, char **proxy);
EXPORT_API int dp_interface_get_network_type(const int id, int *net_type);
EXPORT_API int dp_interface_get_network_bonding(const int id, int *enable);
EXPORT_API int dp_interface_get_destination(const int id, char **path);
return "DESTROY";
case DP_PROP_URL:
return "URL";
+ case DP_PROP_PROXY:
+ return "PROXY";
case DP_PROP_DESTINATION:
return "DESTINATION";
case DP_PROP_FILENAME:
free(string);
break;
}
+ case DP_PROP_PROXY:
+ {
+ char *string = NULL;
+ unsigned length = 0;
+ if (dp_db_get_property_string(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_PROXY, (unsigned char **)&string, &length, &errorcode) < 0) {
+ TRACE_ERROR("failed to get %s", dp_print_property(ipc_info->property));
+ errorcode = DP_ERROR_NO_DATA;
+ }
+ int result = __dp_request_feedback_string(client->channel, ipc_info, string, length, errorcode);
+ if (result == DP_ERROR_IO_ERROR) {
+ errorcode = DP_ERROR_IO_ERROR;
+ TRACE_ERROR("check ipc sock:%d", client->channel);
+ }
+ free(string);
+ break;
+ }
case DP_PROP_DESTINATION:
{
char *string = NULL;
}
break;
}
+ case DP_PROP_PROXY:
+ {
+ char *recv_str = NULL;
+ errorcode = __dp_request_read_string(client->channel, ipc_info, &recv_str);
+ if (errorcode == DP_ERROR_NONE) {
+ if (recv_str == NULL) {
+ errorcode = DP_ERROR_INVALID_PARAMETER;
+ } else {
+ // write to database here
+ if (dp_db_replace_property(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_PROXY, (void *)recv_str, ipc_info->size, 2, &errorcode) < 0) {
+ TRACE_ERROR("failed to set %s errorcode:%s", dp_print_property(ipc_info->property), dp_print_errorcode(errorcode));
+ }
+ free(recv_str);
+ }
+ }
+ break;
+ }
case DP_PROP_DESTINATION:
{
char *recv_str = NULL;
if (dp_db_unset_property_string(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_URL, &errorcode) < 0)
TRACE_ERROR("failed to unset %s", dp_print_property(ipc_info->property));
break;
+ case DP_PROP_PROXY:
+ if (dp_db_unset_property_string(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_PROXY, &errorcode) < 0) {
+ TRACE_ERROR("failed to unset %s errorcode:%s", dp_print_property(ipc_info->property), dp_print_errorcode(errorcode));
+ }
+ break;
case DP_PROP_DESTINATION:
// if downloading, change destination to da_agent
if (dp_db_unset_property_string(client->dbhandle, ipc_info->id, DP_TABLE_REQUEST, DP_DB_COL_DESTINATION, &errorcode) < 0)
int errorcode = DP_ERROR_NONE;
unsigned length = 0;
char *url = NULL;
+ char *proxy = NULL;
char *destination = NULL;
char *tmp_saved_path = NULL;
char *user_tmp_file_path = NULL;
return DP_ERROR_DISK_BUSY;
}
}
+ if (dp_db_get_property_string(base_slot->client.dbhandle, base_req->id, DP_TABLE_REQUEST, DP_DB_COL_PROXY, (unsigned char **)&proxy, &length, &errorcode) < 0 ||
+ proxy == NULL) {
+ TRACE_DEBUG("proxy id:%d NO_DATA", base_req->id);
+ req_data->proxy = NULL;
+ } else {
+ req_data->proxy = proxy;
+ }
if (dp_db_get_property_string(base_slot->client.dbhandle, base_req->id, DP_TABLE_REQUEST, DP_DB_COL_TEMP_FILE_PATH, (unsigned char **)&user_tmp_file_path, &length, &errorcode) < 0 ||
user_tmp_file_path == NULL) {
TRACE_DEBUG("user_tmp_file_path id:%d NO_DATA", base_req->id);
// request table
#define DP_DB_COL_URL "url"
+#define DP_DB_COL_PROXY "proxy"
#define DP_DB_COL_DESTINATION "destination"
#define DP_DB_COL_FILENAME "filename"
#define DP_DB_COL_STATE_EVENT "state_event"
filename TEXT DEFAULT NULL,\
destination TEXT DEFAULT NULL,\
url TEXT DEFAULT NULL,\
+proxy TEXT DEFAULT NULL,\
temp_file_path TEXT DEFAULT NULL,\
network_bonding BOOLEAN DEFAULT 0,\
FOREIGN KEY(id) REFERENCES logging(id) ON DELETE CASCADE\
DP_PROP_CANCEL,
DP_PROP_DESTROY,
DP_PROP_URL,
+ DP_PROP_PROXY,
DP_PROP_DESTINATION,
DP_PROP_FILENAME,
DP_PROP_STATE_CALLBACK,