X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/30984deafc05d7c6f88db736336fe73d23a08e19..43c42c18d36c703a88b1b7b697bac27fe5608eca:/src/msw/urlmsw.cpp?ds=sidebyside diff --git a/src/msw/urlmsw.cpp b/src/msw/urlmsw.cpp index 5b16115615..d081fc1956 100644 --- a/src/msw/urlmsw.cpp +++ b/src/msw/urlmsw.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: msw/urlmsw.cpp +// Name: src/msw/urlmsw.cpp // Purpose: MS-Windows native URL support based on WinINet // Author: Hajo Kirchhoff // Modified by: @@ -18,8 +18,16 @@ #if wxUSE_URL_NATIVE +#ifndef WX_PRECOMP + #include "wx/list.h" + #include "wx/string.h" + #include "wx/utils.h" + #include "wx/module.h" + #include "wx/log.h" +#endif + #if !wxUSE_PROTOCOL_HTTP -#include +#include "wx/protocol/protocol.h" // empty http protocol replacement (for now) // so that wxUSE_URL_NATIVE can be used with @@ -48,7 +56,7 @@ protected: // the only "reason for being" for this class is to tell // wxURL that there is someone dealing with the http protocol IMPLEMENT_DYNAMIC_CLASS(wxHTTPDummyProto, wxProtocol) -IMPLEMENT_PROTOCOL(wxHTTPDummyProto, wxT("http"), NULL, FALSE) +IMPLEMENT_PROTOCOL(wxHTTPDummyProto, wxT("http"), NULL, false) USE_PROTOCOL(wxHTTPDummyProto) #endif // !wxUSE_PROTOCOL_HTTP @@ -59,10 +67,6 @@ USE_PROTOCOL(wxHTTPDummyProto) #pragma comment(lib, "wininet.lib") #endif -#include "wx/string.h" -#include "wx/list.h" -#include "wx/utils.h" -#include "wx/module.h" #include "wx/url.h" #include @@ -118,7 +122,7 @@ class /*WXDLLIMPEXP_NET */ wxWinINetInputStream : public wxInputStream { public: wxWinINetInputStream(HINTERNET hFile=0); - ~wxWinINetInputStream(); + virtual ~wxWinINetInputStream(); void Attach(HINTERNET hFile); @@ -126,15 +130,28 @@ public: { return -1; } wxFileOffset TellI() const { return -1; } + size_t GetSize() const; protected: void SetError(wxStreamError err) { m_lasterror=err; } HINTERNET m_hFile; size_t OnSysRead(void *buffer, size_t bufsize); - DECLARE_NO_COPY_CLASS(wxWinINetInputStream) + wxDECLARE_NO_COPY_CLASS(wxWinINetInputStream); }; +size_t wxWinINetInputStream::GetSize() const +{ + DWORD contentLength = 0; + DWORD dwSize = sizeof(contentLength); + DWORD index = 0; + + if ( HttpQueryInfo( m_hFile, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER, &contentLength, &dwSize, &index) ) + return contentLength; + else + return 0; +} + size_t wxWinINetInputStream::OnSysRead(void *buffer, size_t bufsize) { DWORD bytesread = 0; @@ -199,11 +216,11 @@ wxURLNativeImp *wxURL::CreateNativeImpObject() wxInputStream *wxWinINetURL::GetInputStream(wxURL *owner) { DWORD service; - if ( owner->GetProtocolName() == wxT("http") ) + if ( owner->GetScheme() == wxT("http") ) { service = INTERNET_SERVICE_HTTP; } - else if ( owner->GetProtocolName() == wxT("ftp") ) + else if ( owner->GetScheme() == wxT("ftp") ) { service = INTERNET_SERVICE_FTP; } @@ -230,4 +247,3 @@ wxInputStream *wxWinINetURL::GetInputStream(wxURL *owner) } #endif // wxUSE_URL_NATIVE -