X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f80eabe5a2a9922c2c73d44b4037a2de8fffdf87..e736b21a8c9295b42a528d76863559a4265dab02:/src/common/url.cpp diff --git a/src/common/url.cpp b/src/common/url.cpp index c2e863f0b4..6c0da6ee29 100644 --- a/src/common/url.cpp +++ b/src/common/url.cpp @@ -6,10 +6,10 @@ // Created: 20/07/1997 // RCS-ID: $Id$ // Copyright: (c) 1997, 1998 Guilhem Lavaux -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "url.h" #endif @@ -20,8 +20,7 @@ #pragma hdrstop #endif -#include -#include +#if wxUSE_URL #include "wx/string.h" #include "wx/list.h" @@ -29,6 +28,9 @@ #include "wx/module.h" #include "wx/url.h" +#include +#include + IMPLEMENT_CLASS(wxProtoInfo, wxObject) IMPLEMENT_CLASS(wxURL, wxObject) @@ -59,11 +61,14 @@ wxURL::wxURL(const wxString& url) m_protocol = NULL; m_error = wxURL_NOERR; m_url = url; +#if wxUSE_URL_NATIVE + m_nativeImp = CreateNativeImpObject(); +#endif #if wxUSE_SOCKETS if ( ms_useDefaultProxy && !ms_proxyDefault ) { - SetDefaultProxy(getenv("HTTP_PROXY")); + SetDefaultProxy( wxGetenv(wxT("HTTP_PROXY")) ); if ( !ms_proxyDefault ) { @@ -155,10 +160,13 @@ void wxURL::CleanData() wxURL::~wxURL() { - CleanData(); + CleanData(); #if wxUSE_SOCKETS - if (m_proxy && m_proxy != ms_proxyDefault) - delete m_proxy; + if (m_proxy && m_proxy != ms_proxyDefault) + delete m_proxy; +#endif +#if wxUSE_URL_NATIVE + delete m_nativeImp; #endif } @@ -270,8 +278,6 @@ bool wxURL::FetchProtocol() wxInputStream *wxURL::GetInputStream() { - wxInputStream *the_i_stream = NULL; - if (!m_protocol) { m_error = wxURL_NOPROTO; @@ -285,6 +291,19 @@ wxInputStream *wxURL::GetInputStream() m_protocol->SetPassword(m_password); } +#if wxUSE_URL_NATIVE + // give the native implementation to return a better stream + // such as the native WinINet functionality under MS-Windows + if (m_nativeImp) + { + wxInputStream *rc; + rc = m_nativeImp->GetInputStream(this); + if (rc != 0) + return rc; + } + // else use the standard behaviour +#endif // wxUSE_URL_NATIVE + #if wxUSE_SOCKETS wxIPV4address addr; @@ -308,10 +327,9 @@ wxInputStream *wxURL::GetInputStream() #endif // When we use a proxy, we have to pass the whole URL to it. - if (m_useProxy) - the_i_stream = m_protocol->GetInputStream(m_url); - else - the_i_stream = m_protocol->GetInputStream(m_path); + wxInputStream *the_i_stream = + (m_useProxy) ? m_protocol->GetInputStream(m_url) : + m_protocol->GetInputStream(m_path); if (!the_i_stream) { @@ -385,7 +403,7 @@ void wxURL::SetProxy(const wxString& url_proxy) return; hostname = tmp_str(0, pos); - port = tmp_str(pos, tmp_str.Length()-pos); + port = tmp_str(pos+1, tmp_str.Length()-pos); addr.Hostname(hostname); addr.Service(port); @@ -462,12 +480,16 @@ wxString wxURL::ConvertFromURI(const wxString& uri) i++; if (uri[i] >= wxT('A') && uri[i] <= wxT('F')) code = (uri[i] - wxT('A') + 10) * 16; + else if (uri[i] >= wxT('a') && uri[i] <= wxT('f')) + code = (uri[i] - wxT('a') + 10) * 16; else code = (uri[i] - wxT('0')) * 16; i++; if (uri[i] >= wxT('A') && uri[i] <= wxT('F')) code += (uri[i] - wxT('A')) + 10; + else if (uri[i] >= wxT('a') && uri[i] <= wxT('f')) + code += (uri[i] - wxT('a')) + 10; else code += (uri[i] - wxT('0')); @@ -521,3 +543,6 @@ void wxURLModule::OnExit() } #endif // wxUSE_SOCKETS + +#endif // wxUSE_URL +