SendSystemInfo: Reworked internet connection check,
now we only do the check on Windows, see the comments in the code for details.
This commit is contained in:
parent
3124892fae
commit
0b6fc0817f
@ -35,6 +35,8 @@
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <netlistmgr.h>
|
||||||
|
#include <atlbase.h>
|
||||||
#include <Iphlpapi.h>
|
#include <Iphlpapi.h>
|
||||||
#pragma comment(lib, "iphlpapi.lib")
|
#pragma comment(lib, "iphlpapi.lib")
|
||||||
#elif __APPLE__
|
#elif __APPLE__
|
||||||
@ -132,6 +134,28 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
static bool check_internet_connection_win()
|
||||||
|
{
|
||||||
|
bool internet = true; // return true if COM object creation fails.
|
||||||
|
|
||||||
|
if (CoInitializeEx(NULL, COINIT_APARTMENTTHREADED) == S_OK) {
|
||||||
|
{
|
||||||
|
CComPtr<INetworkListManager> pNLM;
|
||||||
|
if (pNLM.CoCreateInstance(CLSID_NetworkListManager) == S_OK) {
|
||||||
|
NLM_CONNECTIVITY status;
|
||||||
|
pNLM->GetConnectivity(&status);
|
||||||
|
internet = (status & (NLM_CONNECTIVITY_IPV4_INTERNET | NLM_CONNECTIVITY_IPV6_INTERNET));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CoUninitialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
return internet;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Last version where the info was sent / dialog dismissed is saved in appconfig.
|
// Last version where the info was sent / dialog dismissed is saved in appconfig.
|
||||||
// Only show the dialog when this info is not found (e.g. fresh install) or when
|
// Only show the dialog when this info is not found (e.g. fresh install) or when
|
||||||
// current version is newer. Only major and minor versions are compared.
|
// current version is newer. Only major and minor versions are compared.
|
||||||
@ -157,16 +181,19 @@ static bool should_dialog_be_shown()
|
|||||||
if (! new_version)
|
if (! new_version)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// We'll misuse the version check to check internet connection here.
|
// We might want to check that the internet connection is ready so we don't open the dialog
|
||||||
bool is_internet = false;
|
// if it cannot really send any data. Using a dummy HTTP GET request led to
|
||||||
Http::get(wxGetApp().app_config->version_check_url())
|
// https://forum.prusaprinters.org/forum/prusaslicer/prusaslicer-2-4-0-beta1-is-out/#post-518488.
|
||||||
.size_limit(SLIC3R_VERSION_BODY_MAX)
|
// It might also trigger security softwares, which would look bad and would lead to questions
|
||||||
.timeout_max(2)
|
// about what PS is doing. We better use some less intrusive way of checking the connection.
|
||||||
.on_complete([&](std::string, unsigned) {
|
|
||||||
is_internet = true;
|
// As of now, this is only implemented on Win. The other platforms do not check beforehand.
|
||||||
})
|
|
||||||
.perform_sync();
|
#ifdef _WIN32
|
||||||
return is_internet;
|
return check_internet_connection_win();
|
||||||
|
#else
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user