#include "wx/webview.h"
#include "wx/msw/ole/automtn.h"
#include "wx/msw/ole/activex.h"
+#include "wx/msw/ole/oleutils.h"
#include "wx/msw/wrapwin.h"
#include "wx/msw/missing.h"
#include "wx/sharedptr.h"
class VirtualProtocol : public wxIInternetProtocol
{
protected:
- ULONG m_refCount;
wxIInternetProtocolSink* m_protocolSink;
wxString m_html;
VOID * fileP;
public:
VirtualProtocol(wxSharedPtr<wxWebViewHandler> handler);
- ~VirtualProtocol();
+ ~VirtualProtocol() {};
//IUnknown
- ULONG STDMETHODCALLTYPE AddRef();
- HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject);
- ULONG STDMETHODCALLTYPE Release();
+ DECLARE_IUNKNOWN_METHODS;
//IInternetProtocolRoot
HRESULT STDMETHODCALLTYPE Abort(HRESULT WXUNUSED(hrReason),
class ClassFactory : public IClassFactory
{
public:
- ClassFactory(wxSharedPtr<wxWebViewHandler> handler) : m_refCount(0), m_handler(handler) {}
- //IUnknown
- ULONG STDMETHODCALLTYPE AddRef();
- HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject);
- ULONG STDMETHODCALLTYPE Release();
+ ClassFactory(wxSharedPtr<wxWebViewHandler> handler) : m_handler(handler) {}
//IClassFactory
HRESULT STDMETHODCALLTYPE CreateInstance(IUnknown* pUnkOuter,
REFIID riid, void** ppvObject);
HRESULT STDMETHODCALLTYPE LockServer(BOOL fLock);
+
+ //IUnknown
+ DECLARE_IUNKNOWN_METHODS;
+
private:
- ULONG m_refCount;
wxSharedPtr<wxWebViewHandler> m_handler;
};
VirtualProtocol::VirtualProtocol(wxSharedPtr<wxWebViewHandler> handler)
{
- m_refCount = 0;
m_file = NULL;
m_handler = handler;
}
-VirtualProtocol::~VirtualProtocol()
-{
-}
+BEGIN_IID_TABLE(VirtualProtocol)
+ ADD_IID(Unknown)
+ ADD_RAW_IID(wxIID_IInternetProtocolRoot)
+ ADD_RAW_IID(wxIID_IInternetProtocol)
+END_IID_TABLE;
-ULONG VirtualProtocol::AddRef()
-{
- m_refCount++;
- return m_refCount;
-}
-
-HRESULT VirtualProtocol::QueryInterface(REFIID riid, void **ppvObject)
-{
- if(riid == IID_IUnknown || riid == wxIID_IInternetProtocolRoot ||
- riid == wxIID_IInternetProtocol)
- {
- *ppvObject = (wxIInternetProtocol*)this;
- AddRef();
- return S_OK;
- }
- else
- {
- *ppvObject = NULL;
- return E_POINTER;
- }
-}
-
-ULONG VirtualProtocol::Release()
-{
- m_refCount--;
- if (m_refCount > 0)
- {
- return m_refCount;
- }
- else
- {
- delete this;
- return 0;
- }
-}
+IMPLEMENT_IUNKNOWN_METHODS(VirtualProtocol)
HRESULT VirtualProtocol::Start(LPCWSTR szUrl, wxIInternetProtocolSink *pOIProtSink,
wxIInternetBindInfo *pOIBindInfo, DWORD grfPI,
}
}
+BEGIN_IID_TABLE(ClassFactory)
+ ADD_IID(Unknown)
+ ADD_IID(ClassFactory)
+END_IID_TABLE;
+
+IMPLEMENT_IUNKNOWN_METHODS(ClassFactory)
+
HRESULT ClassFactory::CreateInstance(IUnknown* pUnkOuter, REFIID riid,
void ** ppvObject)
{
return S_OK;
}
-ULONG ClassFactory::AddRef(void)
-{
- m_refCount++;
- return m_refCount;
-}
-
-HRESULT ClassFactory::QueryInterface(REFIID riid, void **ppvObject)
-{
- if ((riid == IID_IUnknown) || (riid == IID_IClassFactory))
- {
- *ppvObject = this;
- AddRef();
- return S_OK;
- }
- else
- {
- *ppvObject = NULL;
- return E_POINTER;
- }
-
-}
-
-ULONG ClassFactory::Release(void)
-{
- m_refCount--;
- if (m_refCount > 0)
- {
- return m_refCount;
- }
- else
- {
- delete this;
- return 0;
- }
-
-}
-
#endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE