From 961cc11dda0208f8240c8e513259eabc7c0aa56b Mon Sep 17 00:00:00 2001 From: Valentin Radu Date: Tue, 7 Jun 2022 19:35:41 +0300 Subject: [PATCH] Weather: Fixed a bug that prevented the widget from working when WebView2 Runtime >= 102.0.1245.33 --- ep_weather_host/ep_weather_host.c | 81 +++++++++++++++++++++++++++++-- ep_weather_host/ep_weather_host.h | 25 ++++++---- 2 files changed, 94 insertions(+), 12 deletions(-) diff --git a/ep_weather_host/ep_weather_host.c b/ep_weather_host/ep_weather_host.c index c8c6405..a3007e5 100644 --- a/ep_weather_host/ep_weather_host.c +++ b/ep_weather_host/ep_weather_host.c @@ -100,10 +100,85 @@ ULONG STDMETHODCALLTYPE epw_Weather_static_AddRefRelease(void* _this) return 1; } -HRESULT STDMETHODCALLTYPE epw_Weather_static_QueryInterface(void* _this, REFIID riid, void** ppv) +HRESULT STDMETHODCALLTYPE ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_QueryInterface(void* _this, REFIID riid, void** ppv) { - *ppv = _this; - return S_OK; + if (IsEqualIID(riid, &IID_ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler) || IsEqualIID(riid, &IID_IUnknown)) + { + *ppv = _this; + return S_OK; + } + return E_NOINTERFACE; + +} + +HRESULT STDMETHODCALLTYPE ICoreWebView2CreateCoreWebView2ControllerCompletedHandler_QueryInterface(void* _this, REFIID riid, void** ppv) +{ + if (IsEqualIID(riid, &IID_ICoreWebView2CreateCoreWebView2ControllerCompletedHandler) || IsEqualIID(riid, &IID_IUnknown)) + { + *ppv = _this; + return S_OK; + } + return E_NOINTERFACE; +} + +HRESULT STDMETHODCALLTYPE ICoreWebView2NavigationStartingEventHandler_QueryInterface(void* _this, REFIID riid, void** ppv) +{ + if (IsEqualIID(riid, &IID_ICoreWebView2NavigationStartingEventHandler) || IsEqualIID(riid, &IID_IUnknown)) + { + *ppv = _this; + return S_OK; + } + return E_NOINTERFACE; +} + +HRESULT STDMETHODCALLTYPE ICoreWebView2NavigationCompletedEventHandler_QueryInterface(void* _this, REFIID riid, void** ppv) +{ + if (IsEqualIID(riid, &IID_ICoreWebView2NavigationCompletedEventHandler) || IsEqualIID(riid, &IID_IUnknown)) + { + *ppv = _this; + return S_OK; + } + return E_NOINTERFACE; +} + +HRESULT STDMETHODCALLTYPE ICoreWebView2ExecuteScriptCompletedHandler_QueryInterface(void* _this, REFIID riid, void** ppv) +{ + if (IsEqualIID(riid, &IID_ICoreWebView2ExecuteScriptCompletedHandler) || IsEqualIID(riid, &IID_IUnknown)) + { + *ppv = _this; + return S_OK; + } + return E_NOINTERFACE; +} + +HRESULT STDMETHODCALLTYPE ICoreWebView2EnvironmentOptions_QueryInterface(void* _this, REFIID riid, void** ppv) +{ + if (IsEqualIID(riid, &IID_ICoreWebView2EnvironmentOptions) || IsEqualIID(riid, &IID_IUnknown)) + { + *ppv = _this; + return S_OK; + } + return E_NOINTERFACE; +} + +HRESULT STDMETHODCALLTYPE ICoreWebView2CallDevToolsProtocolMethodCompletedHandler_QueryInterface(void* _this, REFIID riid, void** ppv) +{ + if (IsEqualIID(riid, &IID_ICoreWebView2CallDevToolsProtocolMethodCompletedHandler) || IsEqualIID(riid, &IID_IUnknown)) + { + *ppv = _this; + return S_OK; + } + return E_NOINTERFACE; +} + +HRESULT STDMETHODCALLTYPE ICoreWebView2PermissionRequestedEventHandler_QueryInterface(void* _this, REFIID riid, void** ppv) +{ + if (IsEqualIID(riid, &IID_ICoreWebView2PermissionRequestedEventHandler) || IsEqualIID(riid, &IID_IUnknown)) + { + *ppv = _this; + return S_OK; + } + return E_NOINTERFACE; } HRESULT STDMETHODCALLTYPE ICoreWebView2_get_AdditionalBrowserArguments(ICoreWebView2EnvironmentOptions* _this, LPWSTR* value) diff --git a/ep_weather_host/ep_weather_host.h b/ep_weather_host/ep_weather_host.h index fbe1036..b542ea7 100644 --- a/ep_weather_host/ep_weather_host.h +++ b/ep_weather_host/ep_weather_host.h @@ -165,7 +165,6 @@ static void epw_Weather_SetTextScaleFactorFromRegistry(EPWeather* _this, HKEY hK HRESULT STDMETHODCALLTYPE epw_Weather_static_Stub(void* _this); ULONG STDMETHODCALLTYPE epw_Weather_static_AddRefRelease(EPWeather* _this); -HRESULT STDMETHODCALLTYPE epw_Weather_static_QueryInterface(EPWeather* _this, REFIID riid, void** ppv); HRESULT STDMETHODCALLTYPE ICoreWebView2_CreateCoreWebView2EnvironmentCompleted(ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler* _this, HRESULT errorCode, ICoreWebView2Environment* pCoreWebView2Environment); HRESULT STDMETHODCALLTYPE ICoreWebView2_CreateCoreWebView2ControllerCompleted(ICoreWebView2CreateCoreWebView2ControllerCompletedHandler* _this, HRESULT hr, ICoreWebView2Controller* pCoreWebView2Controller); @@ -181,8 +180,9 @@ HRESULT STDMETHODCALLTYPE ICoreWebView2_CallDevToolsProtocolMethodCompleted(ICor HRESULT STDMETHODCALLTYPE ICoreWebView2_PermissionRequested(ICoreWebView2PermissionRequestedEventHandler* _this2, ICoreWebView2* pCoreWebView2, ICoreWebView2PermissionRequestedEventArgs* pCoreWebView2PermissionRequestedEventArgs); +HRESULT STDMETHODCALLTYPE ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_QueryInterface(void* _this, REFIID riid, void** ppv); static const ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerVtbl EPWeather_ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerVtbl = { - .QueryInterface = epw_Weather_static_QueryInterface, + .QueryInterface = ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler_QueryInterface, .AddRef = epw_Weather_static_AddRefRelease, .Release = epw_Weather_static_AddRefRelease, .Invoke = ICoreWebView2_CreateCoreWebView2EnvironmentCompleted, @@ -192,8 +192,9 @@ static const ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler EPWeathe .lpVtbl = &EPWeather_ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandlerVtbl }; +HRESULT STDMETHODCALLTYPE ICoreWebView2CreateCoreWebView2ControllerCompletedHandler_QueryInterface(void* _this, REFIID riid, void** ppv); static const ICoreWebView2CreateCoreWebView2ControllerCompletedHandlerVtbl EPWeather_ICoreWebView2CreateCoreWebView2ControllerCompletedHandlerVtbl = { - .QueryInterface = epw_Weather_static_QueryInterface, + .QueryInterface = ICoreWebView2CreateCoreWebView2ControllerCompletedHandler_QueryInterface, .AddRef = epw_Weather_static_AddRefRelease, .Release = epw_Weather_static_AddRefRelease, .Invoke = ICoreWebView2_CreateCoreWebView2ControllerCompleted, @@ -203,8 +204,9 @@ static const ICoreWebView2CreateCoreWebView2ControllerCompletedHandler EPWeather .lpVtbl = &EPWeather_ICoreWebView2CreateCoreWebView2ControllerCompletedHandlerVtbl }; +HRESULT STDMETHODCALLTYPE ICoreWebView2NavigationStartingEventHandler_QueryInterface(void* _this, REFIID riid, void** ppv); static const ICoreWebView2NavigationStartingEventHandlerVtbl EPWeather_ICoreWebView2NavigationStartingEventHandlerVtbl = { - .QueryInterface = epw_Weather_static_QueryInterface, + .QueryInterface = ICoreWebView2NavigationStartingEventHandler_QueryInterface, .AddRef = epw_Weather_static_AddRefRelease, .Release = epw_Weather_static_AddRefRelease, .Invoke = ICoreWebView2_NavigationStarting, @@ -214,8 +216,9 @@ static const ICoreWebView2NavigationStartingEventHandler EPWeather_ICoreWebView2 .lpVtbl = &EPWeather_ICoreWebView2NavigationStartingEventHandlerVtbl }; +HRESULT STDMETHODCALLTYPE ICoreWebView2NavigationCompletedEventHandler_QueryInterface(void* _this, REFIID riid, void** ppv); static const ICoreWebView2NavigationCompletedEventHandlerVtbl EPWeather_ICoreWebView2NavigationCompletedEventHandlerVtbl = { - .QueryInterface = epw_Weather_static_QueryInterface, + .QueryInterface = ICoreWebView2NavigationCompletedEventHandler_QueryInterface, .AddRef = epw_Weather_static_AddRefRelease, .Release = epw_Weather_static_AddRefRelease, .Invoke = ICoreWebView2_NavigationCompleted, @@ -225,8 +228,9 @@ static const ICoreWebView2NavigationCompletedEventHandler EPWeather_ICoreWebView .lpVtbl = &EPWeather_ICoreWebView2NavigationCompletedEventHandlerVtbl }; +HRESULT STDMETHODCALLTYPE ICoreWebView2ExecuteScriptCompletedHandler_QueryInterface(void* _this, REFIID riid, void** ppv); static const ICoreWebView2ExecuteScriptCompletedHandlerVtbl EPWeather_ICoreWebView2ExecuteScriptCompletedHandlerVtbl = { - .QueryInterface = epw_Weather_static_QueryInterface, + .QueryInterface = ICoreWebView2ExecuteScriptCompletedHandler_QueryInterface, .AddRef = epw_Weather_static_AddRefRelease, .Release = epw_Weather_static_AddRefRelease, .Invoke = ICoreWebView2_ExecuteScriptCompleted, @@ -236,8 +240,9 @@ static const ICoreWebView2ExecuteScriptCompletedHandler EPWeather_ICoreWebView2E .lpVtbl = &EPWeather_ICoreWebView2ExecuteScriptCompletedHandlerVtbl }; +HRESULT STDMETHODCALLTYPE ICoreWebView2EnvironmentOptions_QueryInterface(void* _this, REFIID riid, void** ppv); static const ICoreWebView2EnvironmentOptionsVtbl EPWeather_ICoreWebView2EnvironmentOptionsVtbl = { - .QueryInterface = epw_Weather_static_QueryInterface, + .QueryInterface = ICoreWebView2EnvironmentOptions_QueryInterface, .AddRef = epw_Weather_static_AddRefRelease, .Release = epw_Weather_static_AddRefRelease, .get_AdditionalBrowserArguments = ICoreWebView2_get_AdditionalBrowserArguments, @@ -254,8 +259,9 @@ static const ICoreWebView2EnvironmentOptions EPWeather_ICoreWebView2EnvironmentO .lpVtbl = &EPWeather_ICoreWebView2EnvironmentOptionsVtbl }; +HRESULT STDMETHODCALLTYPE ICoreWebView2CallDevToolsProtocolMethodCompletedHandler_QueryInterface(void* _this, REFIID riid, void** ppv); static ICoreWebView2CallDevToolsProtocolMethodCompletedHandlerVtbl EPWeather_ICoreWebView2CallDevToolsProtocolMethodCompletedHandlerVtbl = { - .QueryInterface = epw_Weather_static_QueryInterface, + .QueryInterface = ICoreWebView2CallDevToolsProtocolMethodCompletedHandler_QueryInterface, .AddRef = epw_Weather_static_AddRefRelease, .Release = epw_Weather_static_AddRefRelease, .Invoke = ICoreWebView2_CallDevToolsProtocolMethodCompleted @@ -265,8 +271,9 @@ static const ICoreWebView2CallDevToolsProtocolMethodCompletedHandler EPWeather_I .lpVtbl = &EPWeather_ICoreWebView2CallDevToolsProtocolMethodCompletedHandlerVtbl }; +HRESULT STDMETHODCALLTYPE ICoreWebView2PermissionRequestedEventHandler_QueryInterface(void* _this, REFIID riid, void** ppv); static const ICoreWebView2PermissionRequestedEventHandlerVtbl EPWeather_ICoreWebView2PermissionRequestedEventHandlerVtbl = { - .QueryInterface = epw_Weather_static_QueryInterface, + .QueryInterface = ICoreWebView2PermissionRequestedEventHandler_QueryInterface, .AddRef = epw_Weather_static_AddRefRelease, .Release = epw_Weather_static_AddRefRelease, .Invoke = ICoreWebView2_PermissionRequested,