feature diff cn and the other area to download soft.and request to server fail show the error dialog.

This commit is contained in:
alves
2026-01-05 17:36:27 +08:00
parent 8fcabfcbb5
commit 808e1da45b
6 changed files with 59 additions and 20 deletions

View File

@@ -43,6 +43,20 @@ static const std::string PROFILE_UPDATE_URL = "https://public.resource.snapmaker
static const std::string FLUTTER_UPDATE_URL = "https://public.resource.snapmaker.com/upgrade/packages/flutter/flutter_config.json"; static const std::string FLUTTER_UPDATE_URL = "https://public.resource.snapmaker.com/upgrade/packages/flutter/flutter_config.json";
static const std::string MODELS_STR = "models"; static const std::string MODELS_STR = "models";
#define APP_UPDATE_URL_BASE_CN "https://public.resource.snapmaker.com/upgrade/packages/orca"
#define APP_UPDATE_URL_BASE_EN "https://public.resource.snapmaker.com/upgrade/packages/orca"
#if defined(_WIN32)
static const std::string APP_UPDATE_URL = std::string("/win/manifest.json");
#elif defined(__APPLE__)
static const std::string APP_UPDATE_URL = std::string("/mac/manifest.json");
#elif defined(__linux__)
static const std::string APP_UPDATE_URL = std::string("/linux/manifest.json");
#else
static const std::string APP_UPDATE_URL = "";
#endif
const std::string AppConfig::SECTION_FILAMENTS = "filaments"; const std::string AppConfig::SECTION_FILAMENTS = "filaments";
const std::string AppConfig::SECTION_MATERIALS = "sla_materials"; const std::string AppConfig::SECTION_MATERIALS = "sla_materials";
const std::string AppConfig::SECTION_EMBOSS_STYLE = "font"; const std::string AppConfig::SECTION_EMBOSS_STYLE = "font";
@@ -1424,6 +1438,17 @@ std::string AppConfig::config_path()
return path; return path;
} }
std::string AppConfig::get_version_upgrade_url(bool stable_only /* = false*/)
{
//get local area and get the resource from diff server
std::string url = APP_UPDATE_URL_BASE_EN + APP_UPDATE_URL;
auto countryArea = get_country_code();
if (countryArea == std::string("CN"))
url = APP_UPDATE_URL_BASE_CN + APP_UPDATE_URL;
return url;
}
std::string AppConfig::version_check_url(bool stable_only/* = false*/) const std::string AppConfig::version_check_url(bool stable_only/* = false*/) const
{ {
auto from_settings = get("version_check_url"); auto from_settings = get("version_check_url");

View File

@@ -324,6 +324,7 @@ public:
// Get the Slic3r version check url. // Get the Slic3r version check url.
// This returns a hardcoded string unless it is overriden by "version_check_url" in the ini file. // This returns a hardcoded string unless it is overriden by "version_check_url" in the ini file.
std::string version_check_url(bool stable_only = false) const; std::string version_check_url(bool stable_only = false) const;
std::string get_version_upgrade_url(bool stable_only = false);
// Get the Orca profile update url. // Get the Orca profile update url.
std::string profile_update_url() const; std::string profile_update_url() const;

View File

@@ -2592,6 +2592,12 @@ bool GUI_App::on_init_inner()
InfoDialog dlg(nullptr, _L("Info"), msg); InfoDialog dlg(nullptr, _L("Info"), msg);
dlg.ShowModal(); dlg.ShowModal();
}); });
Bind(EVT_REQUEST_SERVER_FAIL, [this](const wxCommandEvent& evt) {
wxString msg = evt.GetString();
InfoDialog dlg(nullptr, _L("Error"), msg);
dlg.ShowModal();
});
} }
else { else {
#ifdef __WXMSW__ #ifdef __WXMSW__
@@ -4743,27 +4749,23 @@ void GUI_App::check_preset_version()
} }
void GUI_App::check_new_version_sf(bool show_tips, bool by_user) void GUI_App::check_new_version_sf(bool show_tips, bool by_user)
{ {
std::string update_url = ""; std::string update_url = app_config->get_version_upgrade_url();
#ifdef __WINDOWS__
update_url = "https://public.resource.snapmaker.com/upgrade/packages/orca/win/manifest.json";
#endif
#ifdef __APPLE__
update_url = "https://public.resource.snapmaker.com/upgrade/packages/orca/mac/manifest.json";
#endif
#ifdef __LINUX__
update_url = "https://public.resource.snapmaker.com/upgrade/packages/orca/linux/manifest.json";
#endif
AppConfig* app_config = wxGetApp().app_config; AppConfig* app_config = wxGetApp().app_config;
Http::get(update_url) Http::get(update_url)
.on_error([&](std::string body, std::string error, unsigned http_status) { .on_error([&](std::string body, std::string error, unsigned http_status) {
(void)body; (void)body;
wxCommandEvent* evt = new wxCommandEvent(EVT_REQUEST_SERVER_FAIL);
wxString errorMsg = wxString::Format(_L("request to server update soft fail with body:%s,error:%s,status:%d"), body,
error, http_status);
evt->SetString(errorMsg);
GUI::wxGetApp().QueueEvent(evt);
BOOST_LOG_TRIVIAL(error) << format("Error getting: `%1%`: HTTP %2%, %3%", "check_new_version_sf", http_status, BOOST_LOG_TRIVIAL(error) << format("Error getting: `%1%`: HTTP %2%, %3%", "check_new_version_sf", http_status,
error); error);
}) })
.timeout_connect(1) .timeout_connect(TIMEOUT_CONNECT)
.on_complete([this,by_user](std::string body, unsigned http_status) { .on_complete([this,by_user](std::string body, unsigned http_status) {
// Http response OK // Http response OK
if (http_status != 200) { if (http_status != 200) {

View File

@@ -1198,7 +1198,7 @@ wxWindow* PreferencesDialog::create_general_page()
app_config->save(); app_config->save();
auto item_check_stable_version_only = create_item_checkbox(_L("Check for stable updates only"), page, _L("Check for stable updates only"), 50, "check_stable_update_only"); //auto item_check_stable_version_only = create_item_checkbox(_L("Check for stable updates only"), page, _L("Check for stable updates only"), 50, "check_stable_update_only");
std::vector<wxString> Units = {_L("Metric") + " (mm, g)", _L("Imperial") + " (in, oz)"}; std::vector<wxString> Units = {_L("Metric") + " (mm, g)", _L("Imperial") + " (in, oz)"};
auto item_currency = create_item_combobox(_L("Units"), page, _L("Units"), "use_inches", Units); auto item_currency = create_item_combobox(_L("Units"), page, _L("Units"), "use_inches", Units);
@@ -1233,7 +1233,7 @@ wxWindow* PreferencesDialog::create_general_page()
auto item_multi_machine = create_item_checkbox(_L("Multi-device Management (Take effect after restarting Snapmaker Orca)."), page, _L("With this option enabled, you can send a task to multiple devices at the same time and manage multiple devices."), 50, "enable_multi_machine"); auto item_multi_machine = create_item_checkbox(_L("Multi-device Management (Take effect after restarting Snapmaker Orca)."), page, _L("With this option enabled, you can send a task to multiple devices at the same time and manage multiple devices."), 50, "enable_multi_machine");
auto item_auto_arrange = create_item_checkbox(_L("Auto arrange plate after cloning"), page, _L("Auto arrange plate after object cloning"), 50, "auto_arrange"); auto item_auto_arrange = create_item_checkbox(_L("Auto arrange plate after cloning"), page, _L("Auto arrange plate after object cloning"), 50, "auto_arrange");
auto title_presets = create_item_title(_L("Presets"), page, _L("Presets")); auto title_presets = create_item_title(_L("Presets"), page, _L("Presets"));
auto title_network = create_item_title(_L("Network"), page, _L("Network")); //auto title_network = create_item_title(_L("Network"), page, _L("Network"));
auto item_user_sync = create_item_checkbox(_L("Auto sync user presets (Printer/Filament/Process)"), page, _L("User Sync"), 50, "sync_user_preset"); auto item_user_sync = create_item_checkbox(_L("Auto sync user presets (Printer/Filament/Process)"), page, _L("User Sync"), 50, "sync_user_preset");
auto item_system_sync = create_item_checkbox(_L("Update built-in Presets automatically."), page, _L("System Sync"), 50, "sync_system_preset"); auto item_system_sync = create_item_checkbox(_L("Update built-in Presets automatically."), page, _L("System Sync"), 50, "sync_system_preset");
auto item_save_presets = create_item_button(_L("Clear my choice on the unsaved presets."), _L("Clear"), page, L"", _L("Clear my choice on the unsaved presets."), []() { auto item_save_presets = create_item_button(_L("Clear my choice on the unsaved presets."), _L("Clear"), page, L"", _L("Clear my choice on the unsaved presets."), []() {
@@ -1338,8 +1338,8 @@ wxWindow* PreferencesDialog::create_general_page()
sizer_page->Add(item_system_sync, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_system_sync, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_remember_printer_config, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_remember_printer_config, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_save_presets, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_save_presets, 0, wxTOP, FromDIP(3));
sizer_page->Add(title_network, 0, wxTOP | wxEXPAND, FromDIP(20)); //sizer_page->Add(title_network, 0, wxTOP | wxEXPAND, FromDIP(20));
sizer_page->Add(item_check_stable_version_only, 0, wxTOP, FromDIP(3)); //sizer_page->Add(item_check_stable_version_only, 0, wxTOP, FromDIP(3));
// SM Beta: temporarily open the item_stealth_mode and close the network plugin // SM Beta: temporarily open the item_stealth_mode and close the network plugin

View File

@@ -181,6 +181,7 @@ struct Updates
std::vector<Update> updates; std::vector<Update> updates;
}; };
wxDEFINE_EVENT(EVT_REQUEST_SERVER_FAIL, wxCommandEvent);
wxDEFINE_EVENT(EVT_NO_WEB_RESOURCE_UPDATE, wxCommandEvent); wxDEFINE_EVENT(EVT_NO_WEB_RESOURCE_UPDATE, wxCommandEvent);
wxDEFINE_EVENT(EVT_NO_PRESET_UPDATE, wxCommandEvent); wxDEFINE_EVENT(EVT_NO_PRESET_UPDATE, wxCommandEvent);
wxDEFINE_EVENT(EVT_SLIC3R_VERSION_ONLINE, wxCommandEvent); wxDEFINE_EVENT(EVT_SLIC3R_VERSION_ONLINE, wxCommandEvent);
@@ -722,9 +723,14 @@ void PresetUpdater::priv::sync_update_flutter_resource(bool isAuto_check)
Http::get(preset_update_url) Http::get(preset_update_url)
.on_error([cache_profile_path, isAuto_check](std::string body, std::string error, unsigned http_status) { .on_error([cache_profile_path, isAuto_check](std::string body, std::string error, unsigned http_status) {
wxCommandEvent* evt = new wxCommandEvent(EVT_REQUEST_SERVER_FAIL);
wxString errorMsg = wxString::Format(_L("request to server update web resource fail with body:%s,error:%s,status:%d"), body, error, http_status);
evt->SetString(errorMsg);
GUI::wxGetApp().QueueEvent(evt);
GUI::wxGetApp().QueueEvent(evt);
BOOST_LOG_TRIVIAL(info) << format("Error getting: `%1%`: HTTP %2%, %3%", "sync_update_flutter_resource", http_status, error); BOOST_LOG_TRIVIAL(info) << format("Error getting: `%1%`: HTTP %2%, %3%", "sync_update_flutter_resource", http_status, error);
}) })
.timeout_connect(5) .timeout_connect(TIMEOUT_CONNECT)
.on_complete([this, cache_profile_path, isAuto_check](std::string body, unsigned http_status) { .on_complete([this, cache_profile_path, isAuto_check](std::string body, unsigned http_status) {
// Http response OK // Http response OK
if (http_status != 200) if (http_status != 200)
@@ -756,7 +762,7 @@ void PresetUpdater::priv::sync_update_flutter_resource(bool isAuto_check)
if (fs::exists(localProfilesjson)) { if (fs::exists(localProfilesjson)) {
Semver localOtaVersion = get_version_from_json(localProfilesjson.string()); Semver localOtaVersion = get_version_from_json(localProfilesjson.string());
if (localOtaVersion >= remoteVersion) if (localOtaVersion > remoteVersion)
return; return;
else { else {
if (currentPresetVersion >= remoteVersion){ if (currentPresetVersion >= remoteVersion){
@@ -802,9 +808,13 @@ void PresetUpdater::priv::sync_config(bool isAuto_check)
.on_error([cache_profile_path, isAuto_check](std::string body, std::string error, unsigned http_status) { .on_error([cache_profile_path, isAuto_check](std::string body, std::string error, unsigned http_status) {
// Orca: we check the response body to see if it's "Not Found", if so, it means for the current Orca version we don't have OTA // Orca: we check the response body to see if it's "Not Found", if so, it means for the current Orca version we don't have OTA
// updates, we can delete the cache file // updates, we can delete the cache file
wxCommandEvent* evt = new wxCommandEvent(EVT_REQUEST_SERVER_FAIL);
wxString errorMsg = wxString::Format(_L("request to server update preset resource fail with body:%s,error:%s,status:%d"), body,error, http_status);
evt->SetString(errorMsg);
GUI::wxGetApp().QueueEvent(evt);
BOOST_LOG_TRIVIAL(info) << format("Error getting: `%1%`: HTTP %2%, %3%", "sync_config_orca", http_status, error); BOOST_LOG_TRIVIAL(info) << format("Error getting: `%1%`: HTTP %2%, %3%", "sync_config_orca", http_status, error);
}) })
.timeout_connect(5) .timeout_connect(TIMEOUT_CONNECT)
.on_complete([this, cache_profile_path, isAuto_check](std::string body, unsigned http_status) { .on_complete([this, cache_profile_path, isAuto_check](std::string body, unsigned http_status) {
// Http response OK // Http response OK
if (http_status != 200) if (http_status != 200)
@@ -835,7 +845,7 @@ void PresetUpdater::priv::sync_config(bool isAuto_check)
if (fs::exists(localProfilesjson)) { if (fs::exists(localProfilesjson)) {
Semver localOtaVersion = get_version_from_json(localProfilesjson.string()); Semver localOtaVersion = get_version_from_json(localProfilesjson.string());
//don't allow jump version. first upgrade localOta //don't allow jump version. first upgrade localOta
if (localOtaVersion >= currentPresetVersion) if (localOtaVersion > currentPresetVersion)
return; return;
else else
{ {

View File

@@ -74,6 +74,7 @@ public:
struct priv; struct priv;
std::unique_ptr<priv> p; std::unique_ptr<priv> p;
}; };
wxDECLARE_EVENT(EVT_REQUEST_SERVER_FAIL, wxCommandEvent);
wxDECLARE_EVENT(EVT_NO_WEB_RESOURCE_UPDATE, wxCommandEvent); wxDECLARE_EVENT(EVT_NO_WEB_RESOURCE_UPDATE, wxCommandEvent);
wxDECLARE_EVENT(EVT_NO_PRESET_UPDATE, wxCommandEvent); wxDECLARE_EVENT(EVT_NO_PRESET_UPDATE, wxCommandEvent);
wxDECLARE_EVENT(EVT_SLIC3R_VERSION_ONLINE, wxCommandEvent); wxDECLARE_EVENT(EVT_SLIC3R_VERSION_ONLINE, wxCommandEvent);