1/* 2 Copyright (C) 2011 Samsung Electronics 3 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Library General Public 6 License as published by the Free Software Foundation; either 7 version 2 of the License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Library General Public License for more details. 13 14 You should have received a copy of the GNU Library General Public License 15 along with this library; see the file COPYING.LIB. If not, write to 16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 Boston, MA 02110-1301, USA. 18*/ 19 20#include "config.h" 21#include "ewk_network.h" 22 23#include "NetworkStateNotifier.h" 24#include "ProxyResolverSoup.h" 25#include "ResourceHandle.h" 26#include "ewk_private.h" 27#include <Eina.h> 28#include <libsoup/soup.h> 29#include <wtf/text/CString.h> 30 31void ewk_network_proxy_uri_set(const char* proxy) 32{ 33 SoupSession* session = WebCore::ResourceHandle::defaultSession(); 34 35 if (!proxy) { 36 ERR("no proxy uri. remove proxy feature in soup."); 37 soup_session_remove_feature_by_type(session, SOUP_TYPE_PROXY_URI_RESOLVER); 38 return; 39 } 40 41 SoupProxyURIResolver* resolverEfl = soupProxyResolverWkNew(proxy, 0); 42 soup_session_add_feature(session, SOUP_SESSION_FEATURE(resolverEfl)); 43 g_object_unref(resolverEfl); 44} 45 46const char* ewk_network_proxy_uri_get(void) 47{ 48 SoupURI* uri; 49 SoupSession* session = WebCore::ResourceHandle::defaultSession(); 50 SoupProxyURIResolver* resolver = SOUP_PROXY_URI_RESOLVER(soup_session_get_feature(session, SOUP_TYPE_PROXY_URI_RESOLVER)); 51 if (!resolver) 52 return 0; 53 54 g_object_get(resolver, SOUP_PROXY_RESOLVER_WK_PROXY_URI, &uri, NULL); 55 56 if (!uri) { 57 ERR("no proxy uri"); 58 return 0; 59 } 60 61 WTF::String proxy = soup_uri_to_string(uri, false); 62 return eina_stringshare_add(proxy.utf8().data()); 63} 64 65Eina_Bool ewk_network_tls_certificate_check_get() 66{ 67 bool checkCertificates = false; 68 69 SoupSession* defaultSession = WebCore::ResourceHandle::defaultSession(); 70 g_object_get(defaultSession, "ssl-strict", &checkCertificates, NULL); 71 72 return checkCertificates; 73} 74 75void ewk_network_tls_certificate_check_set(Eina_Bool checkCertificates) 76{ 77 SoupSession* defaultSession = WebCore::ResourceHandle::defaultSession(); 78 g_object_set(defaultSession, "ssl-strict", checkCertificates, NULL); 79} 80 81const char* ewk_network_tls_ca_certificates_path_get() 82{ 83 const char* bundlePath = 0; 84 85 SoupSession* defaultSession = WebCore::ResourceHandle::defaultSession(); 86 g_object_get(defaultSession, "ssl-ca-file", &bundlePath, NULL); 87 88 return bundlePath; 89} 90 91void ewk_network_tls_ca_certificates_path_set(const char* bundlePath) 92{ 93 SoupSession* defaultSession = WebCore::ResourceHandle::defaultSession(); 94 g_object_set(defaultSession, "ssl-ca-file", bundlePath, NULL); 95} 96 97SoupSession* ewk_network_default_soup_session_get() 98{ 99 return WebCore::ResourceHandle::defaultSession(); 100} 101