\n\
+🖱
\n\
+Unable to load weather information
\n\
+Check to make sure that the location you have entered is correct.
\n\
+Verify that you are connected to the Internet.
\n\
+\n\
+";
+#endif
diff --git a/ep_weather_host/ep_weather_host.c b/ep_weather_host/ep_weather_host.c
index e408f1a..66a354f 100644
--- a/ep_weather_host/ep_weather_host.c
+++ b/ep_weather_host/ep_weather_host.c
@@ -1,6 +1,7 @@
#include "ep_weather_host.h"
#include "ep_weather_provider_google_html.h"
#include "ep_weather_provider_google_script.h"
+#include "ep_weather_error_html.h"
LPCWSTR EP_Weather_Script_Provider_Google = L"\n";
@@ -102,6 +103,12 @@ HRESULT STDMETHODCALLTYPE ICoreWebView2_CreateCoreWebView2EnvironmentCompleted(I
return S_OK;
}
+HRESULT STDMETHODCALLTYPE _epw_Weather_NavigateToError(EPWeather* _this)
+{
+ InterlockedExchange64(&_this->bIsNavigatingToError, TRUE);
+ return _this->pCoreWebView2->lpVtbl->NavigateToString(_this->pCoreWebView2, ep_weather_error_html);
+}
+
HRESULT STDMETHODCALLTYPE _epw_Weather_NavigateToProvider(EPWeather* _this)
{
HRESULT hr = S_OK;
@@ -230,11 +237,20 @@ HRESULT STDMETHODCALLTYPE ICoreWebView2_NavigationCompleted(ICoreWebView2Navigat
pCoreWebView2NavigationCompletedEventArgs->lpVtbl->get_IsSuccess(pCoreWebView2NavigationCompletedEventArgs, &bIsSuccess);
if (bIsSuccess)
{
- _epw_Weather_ExecuteDataScript(_this);
+ BOOL bIsNavigatingToError = InterlockedAdd64(&_this->bIsNavigatingToError, 0);
+ if (bIsNavigatingToError)
+ {
+ InterlockedExchange64(&_this->bIsNavigatingToError, FALSE);
+ InterlockedExchange64(&_this->bBrowserBusy, FALSE);
+ }
+ else
+ {
+ _epw_Weather_ExecuteDataScript(_this);
+ }
}
else
{
- InterlockedExchange64(&_this->bBrowserBusy, FALSE);
+ _epw_Weather_NavigateToError(_this);
}
_this->pCoreWebView2Controller->lpVtbl->put_IsVisible(_this->pCoreWebView2Controller, FALSE);
_this->pCoreWebView2Controller->lpVtbl->put_IsVisible(_this->pCoreWebView2Controller, TRUE);
@@ -246,11 +262,7 @@ HRESULT STDMETHODCALLTYPE ICoreWebView2_ExecuteScriptCompleted(ICoreWebView2Exec
EPWeather* _this = GetWindowLongPtrW(FindWindowW(_T(EPW_WEATHER_CLASSNAME), NULL), GWLP_USERDATA);
if (_this)
{
- //if (_this->dwType != EP_WEATHER_FETCH_RECOMPUTE)
- {
- epw_Weather_LockData(_this);
- }
-
+ BOOL bOk = FALSE;
LONG64 dwProvider = InterlockedAdd64(&_this->dwProvider, 0);
if (dwProvider == EP_WEATHER_PROVIDER_GOOGLE)
{
@@ -260,6 +272,7 @@ HRESULT STDMETHODCALLTYPE ICoreWebView2_ExecuteScriptCompleted(ICoreWebView2Exec
//printf("running part 2\n");
_this->pCoreWebView2->lpVtbl->ExecuteScript(_this->pCoreWebView2, ep_weather_provider_google_script2, &EPWeather_ICoreWebView2ExecuteScriptCompletedHandler);
+ bOk = TRUE;
}
else
{
@@ -268,6 +281,8 @@ HRESULT STDMETHODCALLTYPE ICoreWebView2_ExecuteScriptCompleted(ICoreWebView2Exec
//wprintf(L"%s\n", pResultObjectAsJson);
+ epw_Weather_LockData(_this);
+
WCHAR* wszTemperature = pResultObjectAsJson + 1;
if (wszTemperature)
{
@@ -340,6 +355,8 @@ HRESULT STDMETHODCALLTYPE ICoreWebView2_ExecuteScriptCompleted(ICoreWebView2Exec
tmp[2] = 0;
_this->pImage[i / 2] = wcstol(tmp, NULL, 16);
}
+
+ bOk = TRUE;
}
}
}
@@ -347,17 +364,19 @@ HRESULT STDMETHODCALLTYPE ICoreWebView2_ExecuteScriptCompleted(ICoreWebView2Exec
}
}
}
+
+ epw_Weather_UnlockData(_this);
}
}
- //DWORD dwType = _this->dwType;
- //_this->dwType = EP_WEATHER_FETCH_NONE;
-
- epw_Weather_UnlockData(_this);
- InterlockedExchange64(&_this->bBrowserBusy, FALSE);
-
- //if (dwType == EP_WEATHER_FETCH_ALL_ASYNC)
+ if (!bOk)
{
+ printf("[General] Navigating to error page.\n");
+ _epw_Weather_NavigateToError(_this);
+ }
+ else
+ {
+ InterlockedExchange64(&_this->bBrowserBusy, FALSE);
printf("[General] Fetched data, requesting redraw.\n");
SetTimer(_this->hWnd, EP_WEATHER_TIMER_REQUEST_REPAINT, EP_WEATHER_TIMER_REQUEST_REPAINT_DELAY, NULL);
}
diff --git a/ep_weather_host/ep_weather_host.h b/ep_weather_host/ep_weather_host.h
index cb54abb..ed3744e 100644
--- a/ep_weather_host/ep_weather_host.h
+++ b/ep_weather_host/ep_weather_host.h
@@ -43,6 +43,7 @@ typedef interface EPWeather
LONG64 cbx; // interlocked
LONG64 cby; // interlocked
LONG64 dwProvider; // interlocked
+ LONG64 bIsNavigatingToError; // interlocked
double dpi;
diff --git a/ep_weather_host/ep_weather_host.vcxproj b/ep_weather_host/ep_weather_host.vcxproj
index cf3b567..8bc1ea3 100644
--- a/ep_weather_host/ep_weather_host.vcxproj
+++ b/ep_weather_host/ep_weather_host.vcxproj
@@ -154,6 +154,7 @@