4 * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jungki Kwak <jungki.kwak@samsung.com>, Keunsoon Lee <keunsoon.lee@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
20 * @file download-agent-plugin-conf.c
21 * @brief Platform dependent functions for get configuration data from target
22 * @author Keunsoon Lee(keunsoon.lee@samsung.com)
23 * @author Jungki Kwak(jungki.kwak@samsung.com)
28 #include <glib-object.h>
32 #include <vconf-keys.h>
33 #include <net_connection.h>
34 #endif /* _EFL_PLATFORM */
36 #include "download-agent-plugin-conf.h"
37 #include "download-agent-debug.h"
38 #include "download-agent-file.h"
40 #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"
42 da_result_t __get_conf_string(const char *key, char **out_string);
44 da_result_t __get_conf_string(const char *key, char **out_string)
47 if (!key || !out_string) {
48 DA_LOG_ERR(Default,"Invalid Argument");
49 return DA_ERR_INVALID_ARGUMENT;
52 *out_string = vconf_get_str(key);
62 da_result_t get_storage_type(da_storage_type_t *type)
64 da_result_t ret = DA_RESULT_OK;
70 DA_LOG_ERR(Default,"DA_ERR_CONF_FAIL");
71 ret = DA_ERR_INVALID_ARGUMENT;
76 if (0 != vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_WAP_INT, &value)) {
77 DA_LOG_ERR(Default,"DA_ERR_CONF_FAIL");
78 ret = DA_ERR_FAIL_TO_GET_CONF_VALUE;
83 case SETTING_DEF_MEMORY_PHONE:
84 DA_LOG(Default,"Storage set - DA_STORAGE_PHONE");
85 *type = DA_STORAGE_PHONE;
87 case SETTING_DEF_MEMORY_MMC:
88 *type = DA_STORAGE_MMC;
89 DA_LOG(Default,"Storage set - DA_STORAGE_MMC");
91 case SETTING_DEF_MEMORY_MAX:
92 *type = DA_STORAGE_SYSTEM;
93 DA_LOG(Default,"Storage set - DA_STORAGE_SYSTEM");
96 DA_LOG_ERR(Default,"DA_ERR_CONF_FAIL");
97 ret = DA_ERR_FAIL_TO_GET_CONF_VALUE;
107 da_result_t get_user_agent_string(char **uagent_str)
109 da_result_t ret = DA_RESULT_OK;
114 DA_LOG_FUNC_START(Default);
117 DA_LOG_ERR(Default,"Invalid Argument");
118 return DA_ERR_INVALID_ARGUMENT;
122 key = VCONFKEY_ADMIN_UAGENT;
123 ret = __get_conf_string(key, uagent_str);
124 if(ret == DA_RESULT_OK) {
126 DA_LOG(Default,"getting uagent_str = \n%s", *uagent_str);
130 DA_LOG_ERR(Default,"No UA information from vconf !!");
131 *uagent_str = strdup(DEFAULT_UA_STR);
132 DA_LOG(Default,"Set default UA");
134 *uagent_str = strdup(DEFAULT_UA_STR);
139 char *get_proxy_address(void)
143 char *proxyRet = NULL;
144 connection_h handle = NULL;
145 connection_address_family_e family = CONNECTION_ADDRESS_FAMILY_IPV4;
147 DA_LOG_FUNC_START(Default);
148 if (connection_create(&handle) < 0) {
149 DA_LOG_ERR(Default,"Fail to create connection handle");
153 if (connection_get_proxy(handle, family, &proxyRet) < 0) {
154 DA_LOG_ERR(Default,"Fail to get proxy address");
155 connection_destroy(handle);
160 DA_LOG(Default,"===== Proxy address[%s] =====", proxyRet);
161 proxy = strdup(proxyRet);
164 connection_destroy(handle);
168 if (connection_destroy(handle) < 0) {
169 DA_LOG_ERR(Default,"Fail to desctory connection handle");