mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-13 03:21:49 +08:00
SendSystemInfo macOS fixes (get system language, fix ping)
This commit is contained in:
parent
5b20406a33
commit
692a0dade7
@ -38,6 +38,7 @@
|
|||||||
#pragma comment(lib, "iphlpapi.lib")
|
#pragma comment(lib, "iphlpapi.lib")
|
||||||
#elif __APPLE__
|
#elif __APPLE__
|
||||||
#import <IOKit/IOKitLib.h>
|
#import <IOKit/IOKitLib.h>
|
||||||
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
#else // Linux/BSD
|
#else // Linux/BSD
|
||||||
#include <charconv>
|
#include <charconv>
|
||||||
#endif
|
#endif
|
||||||
@ -155,7 +156,9 @@ static bool should_dialog_be_shown()
|
|||||||
bool is_internet =
|
bool is_internet =
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
std::system((std::string("ping /n 1 /w 1 ") + SEND_SYSTEM_INFO_DOMAIN).data()) == 0; // 1 packet, 1 sec timeout
|
std::system((std::string("ping /n 1 /w 1 ") + SEND_SYSTEM_INFO_DOMAIN).data()) == 0; // 1 packet, 1 sec timeout
|
||||||
#else
|
#elif __APPLE__
|
||||||
|
std::system((std::string("ping -c 1 -q -t 1 ") + SEND_SYSTEM_INFO_DOMAIN).data()) == 0; // 1 packet, quiet output, 1 sec timeout
|
||||||
|
#else // Linux/BSD
|
||||||
std::system((std::string("ping -c 1 -q -w 1 ") + SEND_SYSTEM_INFO_DOMAIN).data()) == 0; // 1 packet, quiet output, 1 sec timeout
|
std::system((std::string("ping -c 1 -q -w 1 ") + SEND_SYSTEM_INFO_DOMAIN).data()) == 0; // 1 packet, quiet output, 1 sec timeout
|
||||||
#endif
|
#endif
|
||||||
std::cout << "Pinging prusa3d.com was " << (is_internet ? "" : "NOT ") << "successful." << std::endl;
|
std::cout << "Pinging prusa3d.com was " << (is_internet ? "" : "NOT ") << "successful." << std::endl;
|
||||||
@ -336,11 +339,20 @@ static std::string generate_system_info_json()
|
|||||||
std::string unique_id = get_unique_id();
|
std::string unique_id = get_unique_id();
|
||||||
|
|
||||||
// Get system language.
|
// Get system language.
|
||||||
std::string sys_language = "Unknown";
|
std::string sys_language = "Unknown"; // important to init, see the __APPLE__ block.
|
||||||
const wxLanguage lang_system = wxLanguage(wxLocale::GetSystemLanguage());
|
#ifndef __APPLE__
|
||||||
if (lang_system != wxLANGUAGE_UNKNOWN)
|
// Following apparently does not work on macOS.
|
||||||
sys_language = wxLocale::GetLanguageInfo(lang_system)->CanonicalName.ToUTF8().data();
|
const wxLanguage lang_system = wxLanguage(wxLocale::GetSystemLanguage());
|
||||||
|
if (lang_system != wxLANGUAGE_UNKNOWN)
|
||||||
|
sys_language = wxLocale::GetLanguageInfo(lang_system)->CanonicalName.ToUTF8().data();
|
||||||
|
#else // __APPLE__
|
||||||
|
CFLocaleRef cflocale = CFLocaleCopyCurrent();
|
||||||
|
CFStringRef value = (CFStringRef)CFLocaleGetValue(cflocale, kCFLocaleLanguageCode);
|
||||||
|
char temp[10] = "";
|
||||||
|
CFStringGetCString(value, temp, 10, kCFStringEncodingUTF8);
|
||||||
|
sys_language = temp;
|
||||||
|
CFRelease(cflocale);
|
||||||
|
#endif
|
||||||
// Build a property tree with all the information.
|
// Build a property tree with all the information.
|
||||||
namespace pt = boost::property_tree;
|
namespace pt = boost::property_tree;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user