]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix compilation of wxWebView under mingw by adding missing definitions and dynamicall...
authorSteve Lamerton <steve.lamerton@gmail.com>
Wed, 28 Sep 2011 14:54:56 +0000 (14:54 +0000)
committerSteve Lamerton <steve.lamerton@gmail.com>
Wed, 28 Sep 2011 14:54:56 +0000 (14:54 +0000)
Fixes #13509

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69209 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/missing.h
include/wx/msw/webview_ie.h
src/msw/webview_ie.cpp

index 392d05679dcb65e908ea9be34d0bed4933e6ceb7..2b6280b28772f3ec330c9a930a394716834d99a7 100644 (file)
@@ -577,6 +577,119 @@ typedef enum CommandStateChangeConstants {
 
 #ifndef DISPID_NEWWINDOW3
 #define DISPID_NEWWINDOW3 273
+#endif
+
+//As MinGW is missing urlmon we replicate the definitions here for wxWebView
+#ifdef __MINGW32__
+
+EXTERN_C const IID CLSID_FileProtocol;    
+EXTERN_C const IID IID_IInternetProtocolRoot; 
+EXTERN_C const IID IID_IInternetProtocol; 
+
+DEFINE_GUID(IID_IInternetProtocolRoot,0x79eac9e3,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
+DEFINE_GUID(IID_IInternetProtocol,0x79eac9e4,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
+
+typedef enum __MIDL_IBindStatusCallback_0006 
+{   
+    BSCF_FIRSTDATANOTIFICATION      = 0x1, 
+    BSCF_INTERMEDIATEDATANOTIFICATION       = 0x2, 
+     BSCF_LASTDATANOTIFICATION       = 0x4, 
+     BSCF_DATAFULLYAVAILABLE = 0x8, 
+     BSCF_AVAILABLEDATASIZEUNKNOWN   = 0x10 
+}   BSCF; 
+
+typedef struct _tagPROTOCOLDATA 
+{ 
+    DWORD grfFlags; 
+    DWORD dwState; 
+    LPVOID pData; 
+    ULONG cbData; 
+}   PROTOCOLDATA; 
+
+typedef struct _tagBINDINFO
+{ 
+    ULONG cbSize; 
+    LPWSTR szExtraInfo; 
+    STGMEDIUM stgmedData; 
+    DWORD grfBindInfoF; 
+    DWORD dwBindVerb; 
+    LPWSTR szCustomVerb; 
+    DWORD cbstgmedData; 
+    DWORD dwOptions; 
+    DWORD dwOptionsFlags; 
+    DWORD dwCodePage; 
+    SECURITY_ATTRIBUTES securityAttributes; 
+    IID iid; 
+    IUnknown *pUnk; 
+    DWORD dwReserved; 
+}   BINDINFO; 
+
+class IInternetProtocolSink : public IUnknown 
+{ 
+public: 
+    virtual HRESULT STDMETHODCALLTYPE Switch(PROTOCOLDATA*) = 0; 
+    virtual HRESULT STDMETHODCALLTYPE ReportProgress(ULONG, LPCWSTR) = 0; 
+    virtual HRESULT STDMETHODCALLTYPE ReportData(DWORD, ULONG, ULONG) = 0; 
+    virtual HRESULT STDMETHODCALLTYPE ReportResult(HRESULT, DWORD, LPCWSTR) = 0; 
+}; 
+
+class IInternetBindInfo : public IUnknown 
+{ 
+public: 
+    virtual HRESULT STDMETHODCALLTYPE GetBindInfo(DWORD*, BINDINFO*) = 0;        
+    virtual HRESULT STDMETHODCALLTYPE GetBindString(ULONG, LPOLESTR*, ULONG,
+                                                    ULONG*) = 0; 
+}; 
+
+class IInternetProtocolRoot : public IUnknown 
+{ 
+public: 
+    virtual HRESULT STDMETHODCALLTYPE Start(LPCWSTR, IInternetProtocolSink*,
+                                            IInternetBindInfo*, DWORD, 
+                                            HANDLE_PTR) = 0; 
+    virtual HRESULT STDMETHODCALLTYPE Continue(PROTOCOLDATA*) = 0; 
+    virtual HRESULT STDMETHODCALLTYPE Abort(HRESULT, DWORD) = 0; 
+    virtual HRESULT STDMETHODCALLTYPE Terminate(DWORD) = 0; 
+    virtual HRESULT STDMETHODCALLTYPE Suspend() = 0; 
+    virtual HRESULT STDMETHODCALLTYPE Resume() = 0; 
+}; 
+class IInternetProtocol : public IInternetProtocolRoot 
+{ 
+public: 
+    virtual HRESULT STDMETHODCALLTYPE Read(void*, ULONG, ULONG*) = 0; 
+    virtual HRESULT STDMETHODCALLTYPE Seek(LARGE_INTEGER, DWORD, 
+                                           ULARGE_INTEGER*) = 0; 
+    virtual HRESULT STDMETHODCALLTYPE LockRequest(DWORD) = 0; 
+    virtual HRESULT STDMETHODCALLTYPE UnlockRequest() = 0; 
+}; 
+
+class IInternetSession : public IUnknown 
+{ 
+public: 
+    virtual HRESULT STDMETHODCALLTYPE RegisterNameSpace(IClassFactory*, 
+                                                        REFCLSID, LPCWSTR, 
+                                                        ULONG, const LPCWSTR*,
+                                                        DWORD) = 0; 
+    virtual HRESULT STDMETHODCALLTYPE UnregisterNameSpace(IClassFactory*, 
+                                                          LPCWSTR) = 0; 
+    virtual HRESULT STDMETHODCALLTYPE RegisterMimeFilter(IClassFactory*, 
+                                                         REFCLSID, 
+                                                         LPCWSTR) = 0; 
+    virtual HRESULT STDMETHODCALLTYPE UnregisterMimeFilter(IClassFactory*, 
+                                                           LPCWSTR) = 0; 
+    virtual HRESULT STDMETHODCALLTYPE CreateBinding(LPBC, LPCWSTR, IUnknown*,
+                                                    IUnknown**, 
+                                                    IInternetProtocol**, 
+                                                    DWORD) = 0;   
+    virtual HRESULT STDMETHODCALLTYPE SetSessionOption(DWORD, LPVOID, DWORD, 
+                                                       DWORD) = 0;          
+    virtual HRESULT STDMETHODCALLTYPE GetSessionOption(DWORD, LPVOID, DWORD*,
+                                                       DWORD) = 0; 
+}; 
+
+STDAPI CoInternetGetSession(DWORD, IInternetSession**, DWORD);   
+
 #endif
 
  /*
index cd63f0a8f5fa71daf1b8ddd5bbf7dec9a35d5da5..f6e7688c46e884763c81212517e40e5a091f676a 100644 (file)
@@ -18,6 +18,7 @@
 #include "wx/webview.h"
 #include "wx/msw/ole/automtn.h"
 #include "wx/msw/ole/activex.h"
+#include "wx/msw/missing.h"
 #include "wx/sharedptr.h"
 #include "wx/vector.h"
 
index 824c71de29e4bde1c574a65b0a91256b05787684..8374dc87b87588e4b9d4d8629f4185350b548ee6 100644 (file)
 #include "wx/msw/registry.h"
 #include "wx/msw/missing.h"
 #include "wx/filesys.h"
+#include "wx/dynlib.h"
 
 wxIMPLEMENT_DYNAMIC_CLASS(wxWebViewIE, wxWebView);
 
-//We link to urlmon as it is required for CoInternetGetSession
-#pragma comment(lib, "urlmon")
-
 BEGIN_EVENT_TABLE(wxWebViewIE, wxControl)
     EVT_ACTIVEX(wxID_ANY, wxWebViewIE::onActiveXEvent)
     EVT_ERASE_BACKGROUND(wxWebViewIE::onEraseBg)
@@ -82,7 +80,7 @@ bool wxWebViewIE::Create(wxWindow* parent,
 
 void wxWebViewIE::LoadURL(const wxString& url)
 {
-    m_ie.CallMethod("Navigate", (BSTR) url.wc_str(), NULL, NULL, NULL, NULL);
+    m_ie.CallMethod("Navigate", (BSTR) url.wc_str());
 }
 
 void wxWebViewIE::SetPage(const wxString& html, const wxString& baseUrl)
@@ -667,17 +665,29 @@ void wxWebViewIE::RunScript(const wxString& javascript)
 
 void wxWebViewIE::RegisterHandler(wxSharedPtr<wxWebViewHandler> handler)
 {
-    ClassFactory* cf = new ClassFactory(handler);
-    IInternetSession* session;
-    if(FAILED(CoInternetGetSession(0, &session, 0)))
+    wxDynamicLibrary urlMon(wxT("urlmon.dll"));
+    if(urlMon.HasSymbol(wxT("CoInternetGetSession")))
     {
-        wxFAIL_MSG("Could not retrive internet session");
-    }
+        typedef HRESULT (WINAPI *CoInternetGetSession_t)(DWORD, IInternetSession**, DWORD);
+        wxDYNLIB_FUNCTION(CoInternetGetSession_t, CoInternetGetSession, urlMon);
+
+        ClassFactory* cf = new ClassFactory(handler);
+        IInternetSession* session;
+        HRESULT res = (*pfnCoInternetGetSession)(0, &session, 0);
+        if(FAILED(res))
+        {
+            wxFAIL_MSG("Could not retrive internet session");
+        }
 
-    HRESULT hr = session->RegisterNameSpace(cf, CLSID_FileProtocol, handler->GetName(), 0, NULL, 0);
-    if(FAILED(hr))
+        HRESULT hr = session->RegisterNameSpace(cf, CLSID_FileProtocol, handler->GetName(), 0, NULL, 0);
+        if(FAILED(hr))
+        {
+            wxFAIL_MSG("Could not register protocol");
+        }
+    }
+    else
     {
-        wxFAIL_MSG("Could not register protocol");
+        wxFAIL_MSG("urlmon does not contain CoInternetGetSession");
     }
 }