2 * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <glib-object.h>
23 #include <vconf-keys.h>
24 #include <net_connection.h>
25 #endif /* _EFL_PLATFORM */
27 #include "download-agent-plugin-conf.h"
28 #include "download-agent-debug.h"
29 #include "download-agent-file.h"
31 #define DEFAULT_UA_STR "Mozilla/5.0 (Linux; U; Tizen 1.0; en-us) AppleWebKit/534.46 (KHTML, like Gecko) Mobile Tizen Browser/1.0"
33 da_result_t __get_conf_string(const char *key, char **out_string);
35 da_result_t __get_conf_string(const char *key, char **out_string)
38 if (!key || !out_string) {
39 DA_LOG_ERR(Default,"Invalid Argument");
40 return DA_ERR_INVALID_ARGUMENT;
43 *out_string = vconf_get_str(key);
53 da_result_t get_storage_type(da_storage_type_t *type)
55 da_result_t ret = DA_RESULT_OK;
61 DA_LOG_ERR(Default,"DA_ERR_CONF_FAIL");
62 ret = DA_ERR_INVALID_ARGUMENT;
67 if (0 != vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_WAP_INT, &value)) {
68 DA_LOG_ERR(Default,"DA_ERR_CONF_FAIL");
69 ret = DA_ERR_FAIL_TO_GET_CONF_VALUE;
74 case SETTING_DEF_MEMORY_PHONE:
75 DA_LOG(Default,"Storage set - DA_STORAGE_PHONE");
76 *type = DA_STORAGE_PHONE;
78 case SETTING_DEF_MEMORY_MMC:
79 *type = DA_STORAGE_MMC;
80 DA_LOG(Default,"Storage set - DA_STORAGE_MMC");
82 case SETTING_DEF_MEMORY_MAX:
83 *type = DA_STORAGE_SYSTEM;
84 DA_LOG(Default,"Storage set - DA_STORAGE_SYSTEM");
87 DA_LOG_ERR(Default,"DA_ERR_CONF_FAIL");
88 ret = DA_ERR_FAIL_TO_GET_CONF_VALUE;
98 da_result_t get_user_agent_string(char **uagent_str)
100 da_result_t ret = DA_RESULT_OK;
105 DA_LOG_FUNC_START(Default);
108 DA_LOG_ERR(Default,"Invalid Argument");
109 return DA_ERR_INVALID_ARGUMENT;
113 key = VCONFKEY_BROWSER_USER_AGENT;
114 ret = __get_conf_string(key, uagent_str);
115 if(ret == DA_RESULT_OK) {
117 DA_LOG(Default,"getting uagent_str = \n%s", *uagent_str);
121 DA_LOG_ERR(Default,"No UA information from vconf !!");
122 *uagent_str = strdup(DEFAULT_UA_STR);
123 DA_LOG(Default,"Set default UA");
125 *uagent_str = strdup(DEFAULT_UA_STR);
130 char *get_proxy_address(void)
134 char *proxyRet = NULL;
135 connection_h handle = NULL;
136 connection_address_family_e family = CONNECTION_ADDRESS_FAMILY_IPV4;
138 DA_LOG_FUNC_START(Default);
139 if (connection_create(&handle) < 0) {
140 DA_LOG_ERR(Default,"Fail to create connection handle");
144 if (connection_get_proxy(handle, family, &proxyRet) < 0) {
145 DA_LOG_ERR(Default,"Fail to get proxy address");
146 connection_destroy(handle);
151 DA_LOG(Default,"===== Proxy address[%s] =====", proxyRet);
152 proxy = strdup(proxyRet);
155 connection_destroy(handle);
159 if (connection_destroy(handle) < 0) {
160 DA_LOG_ERR(Default,"Fail to desctory connection handle");