Merge pull request #169 from Snapmaker/dev_2.3.0_alves

feature add donwloadandopen for module station
This commit is contained in:
Alves
2026-02-27 09:48:12 +08:00
committed by GitHub
9 changed files with 130 additions and 111 deletions

View File

@@ -71,6 +71,44 @@ namespace common
#endif // _WIN32 #endif // _WIN32
return machineId; return machineId;
} }
std::string get_profile_version()
{
std::string versionFilePath = "";
#ifdef _WIN32
PWSTR pszPath = nullptr;
char* path = new char[MAX_PATH]();
size_t pathLength = 0;
HRESULT hr = SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, nullptr, &pszPath);
if (SUCCEEDED(hr)) {
wcstombs_s(&pathLength, path, MAX_PATH, pszPath, MAX_PATH);
CoTaskMemFree(pszPath);
}
std::string filePath = path;
versionFilePath = filePath + "\\" + std::string("Snapmaker_Orca\\system\\Snapmaker.json");
delete[] path;
#elif __APPLE__
const char* home_env = getenv("HOME");
versionFilePath = home_env;
versionFilePath = versionFilePath + "/Library/Application Support/Snapmaker_Orca/system/Snapmaker.json";
#else
#endif
std::ifstream json_file(versionFilePath);
if (!json_file.is_open()) {
std::ifstream json_file(versionFilePath);
return "";
}
nlohmann::json json_data;
json_file >> json_data;
std::string str_version = json_data.value("version", "");
return str_version;
}
std::string get_flutter_version() std::string get_flutter_version()
{ {

View File

@@ -23,6 +23,8 @@ namespace common
std::string get_flutter_version(); std::string get_flutter_version();
std::string get_profile_version();
std::string getMachineId(); std::string getMachineId();
std::string getLocalArea(); std::string getLocalArea();

View File

@@ -422,17 +422,12 @@ public:
// This function is useful to split values from multiple extrder / filament settings into separate configurations. // This function is useful to split values from multiple extrder / filament settings into separate configurations.
void set_at(const ConfigOption *rhs, size_t i, size_t j) override void set_at(const ConfigOption *rhs, size_t i, size_t j) override
{ {
// SM Orca: Debug logging
BOOST_LOG_TRIVIAL(error) << "ConfigOptionVector::set_at: START - this->values.size()=" << this->values.size()
<< ", i=" << i << ", j=" << j;
// It is expected that the vector value has at least one value, which is the default, if not overwritten. // It is expected that the vector value has at least one value, which is the default, if not overwritten.
assert(! this->values.empty()); assert(! this->values.empty());
if (this->values.size() <= i) { if (this->values.size() <= i) {
// Resize this vector, fill in the new vector fields with the copy of the first field. // Resize this vector, fill in the new vector fields with the copy of the first field.
T v = this->values.front(); T v = this->values.front();
this->values.resize(i + 1, v); this->values.resize(i + 1, v);
BOOST_LOG_TRIVIAL(error) << "ConfigOptionVector::set_at: resized to " << this->values.size();
} }
if (rhs->type() == this->type()) { if (rhs->type() == this->type()) {
@@ -449,8 +444,7 @@ public:
before_ss << this->values[k]; before_ss << this->values[k];
} }
before_ss << "]"; before_ss << "]";
BOOST_LOG_TRIVIAL(error) << "ConfigOptionVector::set_at: before this->values=" << before_ss.str();
// Log other vector // Log other vector
std::stringstream other_ss; std::stringstream other_ss;
other_ss << "["; other_ss << "[";
@@ -459,8 +453,6 @@ public:
other_ss << other->values[k]; other_ss << other->values[k];
} }
other_ss << "]"; other_ss << "]";
BOOST_LOG_TRIVIAL(error) << "ConfigOptionVector::set_at: other->values=" << other_ss.str()
<< ", other->get_at(" << j << ")=" << other->get_at(j);
this->values[i] = other->get_at(j); this->values[i] = other->get_at(j);
@@ -472,12 +464,10 @@ public:
after_ss << this->values[k]; after_ss << this->values[k];
} }
after_ss << "]"; after_ss << "]";
BOOST_LOG_TRIVIAL(error) << "ConfigOptionVector::set_at: after this->values[" << i << "]=" << this->values[i]
<< ", full=" << after_ss.str();
} else if (rhs->type() == this->scalar_type()) { } else if (rhs->type() == this->scalar_type()) {
this->values[i] = static_cast<const ConfigOptionSingle<T>*>(rhs)->value; this->values[i] = static_cast<const ConfigOptionSingle<T>*>(rhs)->value;
BOOST_LOG_TRIVIAL(error) << "ConfigOptionVector::set_at: assigned scalar value=" << this->values[i];
} else } else
throw ConfigurationError("ConfigOptionVector::set_at(): Assigning an incompatible type"); throw ConfigurationError("ConfigOptionVector::set_at(): Assigning an incompatible type");
} }

View File

@@ -136,11 +136,7 @@ public:
// 映射表为空或没有该耗材的映射,使用默认模运算映射 // 映射表为空或没有该耗材的映射,使用默认模运算映射
physical_extruder_id = filament_idx % m_physical_extruder_count; physical_extruder_id = filament_idx % m_physical_extruder_count;
} }
// SM Orca: 日志 - 映射查询
BOOST_LOG_TRIVIAL(info) << "GCodeWriter::get_physical_extruder: filament_id=" << filament_idx
<< " -> physical_extruder_id=" << physical_extruder_id
<< " (map_size=" << m_filament_extruder_map.size() << ", physical_count=" << m_physical_extruder_count << ")"
<< (it != m_filament_extruder_map.end() ? " [from_map]" : " [default_mod]");
return physical_extruder_id; return physical_extruder_id;
} }

View File

@@ -907,16 +907,11 @@ public:
if (physical_count == 0) { if (physical_count == 0) {
// 防止除零,使用安全的默认值 // 防止除零,使用安全的默认值
physical_extruder_id = 0; physical_extruder_id = 0;
BOOST_LOG_TRIVIAL(warning) << "Print::get_physical_extruder: nozzle_diameter is empty! Using default physical_extruder=0";
} else { } else {
physical_extruder_id = filament_idx % physical_count; physical_extruder_id = filament_idx % physical_count;
} }
} }
// SM Orca: 日志 - 映射查询
BOOST_LOG_TRIVIAL(info) << "Print::get_physical_extruder: filament_id=" << filament_idx
<< " -> physical_extruder_id=" << physical_extruder_id
<< " (map_size=" << m_filament_extruder_map.size() << ")"
<< (it != m_filament_extruder_map.end() ? " [from_map]" : " [default_mod]");
return physical_extruder_id; return physical_extruder_id;
} }
// SM Orca: Initialize filament-to-physical-extruder mapping table // SM Orca: Initialize filament-to-physical-extruder mapping table

View File

@@ -1082,7 +1082,9 @@ GUI_App::GUI_App()
m_page_http_server.setPort(PAGE_HTTP_PORT); m_page_http_server.setPort(PAGE_HTTP_PORT);
m_page_http_server.set_request_handler(HttpServer::web_server_handle_request); m_page_http_server.set_request_handler(HttpServer::web_server_handle_request);
m_page_http_server.start(); m_page_http_server.start();
BOOST_LOG_TRIVIAL(info) << "[Flutter] Version:"<<common::get_flutter_version();
BOOST_LOG_TRIVIAL(info) << "[Profile] Version:" << common::get_profile_version();
flush_logs();
m_fltviews.set_app(this); m_fltviews.set_app(this);
} }
@@ -4893,7 +4895,7 @@ void GUI_App::check_new_version_sf(bool show_tips, bool by_user)
BOOST_LOG_TRIVIAL(fatal) << "request server soft update data error:" << errorMsg; BOOST_LOG_TRIVIAL(fatal) << "request server soft update data error:" << errorMsg;
} }
}) })
.perform_sync(); .perform();
} }
void GUI_App::process_network_msg(std::string dev_id, std::string msg) void GUI_App::process_network_msg(std::string dev_id, std::string msg)
{ {
@@ -6974,16 +6976,7 @@ bool GUI_App::config_wizard_startup()
BOOST_LOG_TRIVIAL(info) << "finished run wizard"; BOOST_LOG_TRIVIAL(info) << "finished run wizard";
return true; return true;
} /*else if (get_app_config()->legacy_datadir()) { }
// Looks like user has legacy pre-vendorbundle data directory,
// explain what this is and run the wizard
MsgDataLegacy dlg;
dlg.ShowModal();
run_wizard(ConfigWizard::RR_DATA_LEGACY);
return true;
}*/
if (isAgree.empty()) if (isAgree.empty())
{ {

View File

@@ -6050,7 +6050,8 @@ std::unordered_set<std::string> SSWCP::m_project_cmd_list = {
}; };
std::unordered_set<std::string> SSWCP::m_login_cmd_list = {"sw_UserLogin", "sw_UserLogout", "sw_GetUserLoginState", "sw_SubscribeUserLoginState", std::unordered_set<std::string> SSWCP::m_login_cmd_list = {"sw_UserLogin", "sw_UserLogout", "sw_GetUserLoginState", "sw_SubscribeUserLoginState",
UPDATE_PRIVACY_STATUS, GET_PRIVACY_STATUS}; UPDATE_PRIVACY_STATUS, GET_PRIVACY_STATUS,
DOWNLOAD_FILE,FILE_VIEW, CANCEL_DOWNLOAD, DOWNLOAD_FILE_AND_OPEN};
std::unordered_set<std::string> SSWCP::m_machine_manage_cmd_list = { std::unordered_set<std::string> SSWCP::m_machine_manage_cmd_list = {
"sw_GetLocalDevices", "sw_AddDevice", "sw_SubscribeLocalDevices", "sw_RenameDevice", "sw_SwitchModel", "sw_DeleteDevices" "sw_GetLocalDevices", "sw_AddDevice", "sw_SubscribeLocalDevices", "sw_RenameDevice", "sw_SwitchModel", "sw_DeleteDevices"

View File

@@ -31,7 +31,7 @@ using tcp = asio::ip::tcp;
#define DELETE_CAMERA_TIMELAPSE "sw_DeleteCameraTimelapse" #define DELETE_CAMERA_TIMELAPSE "sw_DeleteCameraTimelapse"
#define GET_DEVICEDATA_STORAGESPACE "sw_GetDeviceDataStorageSpace" #define GET_DEVICEDATA_STORAGESPACE "sw_GetDeviceDataStorageSpace"
#define DOWNLOAD_FILE "sw_DownloadFile" #define DOWNLOAD_FILE "sw_DownloadFile"
#define DOWNLOAD_FILE_AND_OPEN "sw_DownloadFileAndOpen" #define DOWNLOAD_FILE_AND_OPEN "sw_DownLoadFileAndOpen"
#define CANCEL_DOWNLOAD "sw_CancelDownload" #define CANCEL_DOWNLOAD "sw_CancelDownload"
#define FILE_VIEW "sw_FileView" #define FILE_VIEW "sw_FileView"

View File

@@ -232,7 +232,11 @@ struct PresetUpdater::priv
void sync_resources(std::string http_url, std::map<std::string, Resource> &resources, bool check_patch = false, std::string current_version="", std::string changelog_file=""); void sync_resources(std::string http_url, std::map<std::string, Resource> &resources, bool check_patch = false, std::string current_version="", std::string changelog_file="");
void sync_config(bool isAuto_check = true); void sync_config(bool isAuto_check = true);
void sync_update_flutter_resource(bool isAuto_check = true); void sync_update_flutter_resource(bool isAuto_check = true);
bool download_file(const std::string& url, const std::string& target_path, int timeout_sec = 30, bool* cancel_flag = nullptr); bool download_file(const std::string& url,
const std::string& target_path,
const std::string& extract_path,
int timeout_sec = 30,
bool* cancel_flag = nullptr);
void sync_tooltip(std::string http_url, std::string language); void sync_tooltip(std::string http_url, std::string language);
void sync_plugins(std::string http_url, std::string plugin_version); void sync_plugins(std::string http_url, std::string plugin_version);
void sync_printer_config(std::string http_url); void sync_printer_config(std::string http_url);
@@ -320,7 +324,7 @@ bool PresetUpdater::priv::extract_file(const fs::path &source_path, const fs::pa
{ {
bool res = true; bool res = true;
std::string file_path = source_path.string(); std::string file_path = source_path.string();
std::string parent_path = (!dest_path.empty() ? dest_path : source_path.parent_path()).string(); fs::path parent_path = !dest_path.empty() ? dest_path : source_path.parent_path();
mz_zip_archive archive; mz_zip_archive archive;
mz_zip_zero_struct(&archive); mz_zip_zero_struct(&archive);
@@ -331,6 +335,7 @@ bool PresetUpdater::priv::extract_file(const fs::path &source_path, const fs::pa
} }
mz_uint num_entries = mz_zip_reader_get_num_files(&archive); mz_uint num_entries = mz_zip_reader_get_num_files(&archive);
fs::path base_path = parent_path.lexically_normal();
mz_zip_archive_file_stat stat; mz_zip_archive_file_stat stat;
// we first loop the entries to read from the archive the .amf file only, in order to extract the version from it // we first loop the entries to read from the archive the .amf file only, in order to extract the version from it
@@ -338,30 +343,48 @@ bool PresetUpdater::priv::extract_file(const fs::path &source_path, const fs::pa
{ {
if (mz_zip_reader_file_stat(&archive, i, &stat)) if (mz_zip_reader_file_stat(&archive, i, &stat))
{ {
std::string dest_file = parent_path+"/"+stat.m_filename; fs::path full_dest = (base_path / stat.m_filename).lexically_normal();
if (stat.m_is_directory) { // Reject paths that escape base (e.g. ".." in zip entry)
fs::path dest_path(dest_file); std::string rel_str = full_dest.lexically_relative(base_path).generic_string();
if (!fs::exists(dest_path)) if (rel_str.empty() || rel_str.find("..") == 0) {
fs::create_directories(dest_path); BOOST_LOG_TRIVIAL(warning) << "[Orca Updater]Unzip: skip invalid path "<<stat.m_filename;
continue; continue;
} }
else if (stat.m_uncomp_size == 0) { if (stat.m_is_directory) {
if (!fs::exists(full_dest))
fs::create_directories(full_dest);
continue;
}
if (stat.m_uncomp_size == 0) {
BOOST_LOG_TRIVIAL(warning) << "[Orca Updater]Unzip: invalid size for file "<<stat.m_filename; BOOST_LOG_TRIVIAL(warning) << "[Orca Updater]Unzip: invalid size for file "<<stat.m_filename;
continue; continue;
} }
try try
{ {
res = mz_zip_reader_extract_to_file(&archive, stat.m_file_index, dest_file.c_str(), 0); // Ensure parent directory exists (zip often has no directory entries, e.g. "flutter_web/version.json" only)
fs::path parent_dir = full_dest.parent_path();
if (!parent_dir.empty() && !fs::exists(parent_dir))
fs::create_directories(parent_dir);
std::string dest_file_encoded = encode_path(full_dest.string().c_str());
res = mz_zip_reader_extract_to_file(&archive, stat.m_file_index, dest_file_encoded.c_str(), 0);
#ifdef _WIN32
if (!res) { if (!res) {
BOOST_LOG_TRIVIAL(error) << "[Orca Updater]extract file "<<stat.m_filename<<" to dest "<<dest_file<<" failed"; std::wstring dest_file_w = boost::nowide::widen(full_dest.generic_string());
close_zip_reader(&archive); res = mz_zip_reader_extract_to_file_w(&archive, stat.m_file_index, dest_file_w.c_str(), 0);
return res;
} }
BOOST_LOG_TRIVIAL(info) << "[Orca Updater]successfully extract file " << stat.m_file_index << " to "<<dest_file; #endif
if (!res) {
mz_zip_error zip_err = mz_zip_get_last_error(&archive);
BOOST_LOG_TRIVIAL(error) << "[Orca Updater]extract file "<<stat.m_filename<<" to dest "<<full_dest.string()
<< " failed: " << (zip_err != MZ_ZIP_NO_ERROR ? mz_zip_get_error_string(zip_err) : "unknown");
close_zip_reader(&archive);
return false;
}
BOOST_LOG_TRIVIAL(info) << "[Orca Updater]successfully extract file " << stat.m_file_index << " to "<<full_dest.string();
} }
catch (const std::exception& e) catch (const std::exception& e)
{ {
// ensure the zip archive is closed and rethrow the exception
close_zip_reader(&archive); close_zip_reader(&archive);
BOOST_LOG_TRIVIAL(error) << "[Orca Updater]Archive read exception:"<<e.what(); BOOST_LOG_TRIVIAL(error) << "[Orca Updater]Archive read exception:"<<e.what();
return false; return false;
@@ -373,7 +396,7 @@ bool PresetUpdater::priv::extract_file(const fs::path &source_path, const fs::pa
} }
close_zip_reader(&archive); close_zip_reader(&archive);
return true; return true;
} }
// Remove leftover paritally downloaded files, if any. // Remove leftover paritally downloaded files, if any.
@@ -656,7 +679,8 @@ void PresetUpdater::priv::sync_resources(std::string http_url, std::map<std::str
} }
} }
bool PresetUpdater::priv::download_file(const std::string& url, bool PresetUpdater::priv::download_file(const std::string& url,
const std::string& target_path, const std::string& target_path,
const std::string& extract_path,
int timeout_sec, int timeout_sec,
bool* cancel_flag ) bool* cancel_flag )
{ {
@@ -676,7 +700,7 @@ bool PresetUpdater::priv::download_file(const std::string& url,
.on_error([&url](std::string body, std::string error, unsigned http_status) { .on_error([&url](std::string body, std::string error, unsigned http_status) {
BOOST_LOG_TRIVIAL(error) << "Download failed: " << url << ", HTTP status: " << http_status << ", error: " << error; BOOST_LOG_TRIVIAL(error) << "Download failed: " << url << ", HTTP status: " << http_status << ", error: " << error;
}) })
.on_complete([&](std::string body, unsigned http_status) { .on_complete([&, target_path,tmp_path,extract_path](std::string body, unsigned http_status) {
if (http_status != 200) { if (http_status != 200) {
BOOST_LOG_TRIVIAL(error) << "Download failed with HTTP status: " << http_status; BOOST_LOG_TRIVIAL(error) << "Download failed with HTTP status: " << http_status;
return; return;
@@ -700,12 +724,12 @@ bool PresetUpdater::priv::download_file(const std::string& url,
BOOST_LOG_TRIVIAL(error) << "Failed to rename temp file: " << ec.message(); BOOST_LOG_TRIVIAL(error) << "Failed to rename temp file: " << ec.message();
return; return;
} }
extract_file(target_path, "../ota/profiles/"); extract_file(target_path, extract_path);
BOOST_LOG_TRIVIAL(info) << "Download completed: " << target_path; BOOST_LOG_TRIVIAL(info) << "Download completed: " << target_path;
res = true;
}) })
.timeout_max(timeout_sec) .timeout_max(timeout_sec)
.perform_sync(); .perform();
if (fs::exists(tmp_path)) { if (fs::exists(tmp_path)) {
fs::remove(tmp_path); fs::remove(tmp_path);
@@ -803,8 +827,19 @@ void PresetUpdater::priv::sync_update_flutter_resource(bool isAuto_check)
return; return;
} }
if (currentPresetVersion < remoteVersion) if (currentPresetVersion < remoteVersion) {
download_file(fileUrl, fileName);
if (fs::exists(fileName))
fs::remove(fileName);
fs::path tmpPath = fileName;
auto dirPath = tmpPath.parent_path() / "profiles/flutter_web";
if (fs::exists(dirPath))
fs::remove_all(dirPath);
download_file(fileUrl, fileName, "../ota/profiles/");
}
else { else {
if (!isAuto_check) { if (!isAuto_check) {
wxCommandEvent* evt = new wxCommandEvent(EVT_NO_WEB_RESOURCE_UPDATE); wxCommandEvent* evt = new wxCommandEvent(EVT_NO_WEB_RESOURCE_UPDATE);
@@ -819,7 +854,7 @@ void PresetUpdater::priv::sync_update_flutter_resource(bool isAuto_check)
BOOST_LOG_TRIVIAL(fatal) << "request server flutter update data error:" << errorMsg; BOOST_LOG_TRIVIAL(fatal) << "request server flutter update data error:" << errorMsg;
} }
}) })
.perform_sync(); .perform();
} }
// Orca: sync config update for currect App version // Orca: sync config update for currect App version
void PresetUpdater::priv::sync_config(bool isAuto_check) void PresetUpdater::priv::sync_config(bool isAuto_check)
@@ -912,8 +947,18 @@ void PresetUpdater::priv::sync_config(bool isAuto_check)
return; return;
} }
if (currentPresetVersion < remoteVersion) if (currentPresetVersion < remoteVersion) {
download_file(fileUrl, fileName); if (fs::exists(fileName))
fs::remove(fileName);
fs::path tmpPath = fileName;
auto dirPath = tmpPath.parent_path() / "profiles/profiles";
if (fs::exists(dirPath))
fs::remove_all(dirPath);
download_file(fileUrl, fileName, "../ota/profiles/profiles/");
}
else { else {
if (!isAuto_check) { if (!isAuto_check) {
wxCommandEvent* evt = new wxCommandEvent(EVT_NO_PRESET_UPDATE); wxCommandEvent* evt = new wxCommandEvent(EVT_NO_PRESET_UPDATE);
@@ -928,7 +973,7 @@ void PresetUpdater::priv::sync_config(bool isAuto_check)
BOOST_LOG_TRIVIAL(fatal) << "request server preset update data error:" << errorMsg; BOOST_LOG_TRIVIAL(fatal) << "request server preset update data error:" << errorMsg;
} }
}) })
.perform_sync(); .perform();
} }
void PresetUpdater::priv::sync_tooltip(std::string http_url, std::string language) void PresetUpdater::priv::sync_tooltip(std::string http_url, std::string language)
@@ -1375,7 +1420,7 @@ Updates PresetUpdater::priv::get_config_updates(const Semver &old_slic3r_version
Updates updates; Updates updates;
BOOST_LOG_TRIVIAL(info) << "[Orca Updater]:Checking for cached configuration updates..."; BOOST_LOG_TRIVIAL(info) << "[Orca Updater]:Checking for cached configuration updates...";
auto cache_profile_path = cache_path / "profiles"; auto cache_profile_path = cache_path / "profiles/profiles";
if (!fs::exists(cache_profile_path)) if (!fs::exists(cache_profile_path))
return updates; return updates;
@@ -1465,15 +1510,8 @@ Updates PresetUpdater::priv::get_config_updates(const Semver &old_slic3r_version
//BBS: switch to new BBL.json configs //BBS: switch to new BBL.json configs
bool PresetUpdater::priv::perform_updates(Updates &&updates, bool snapshot) const bool PresetUpdater::priv::perform_updates(Updates &&updates, bool snapshot) const
{ {
//std::string vendor_path;
//std::string vendor_name;
if (updates.incompats.size() > 0) { if (updates.incompats.size() > 0) {
//if (snapshot) {
// BOOST_LOG_TRIVIAL(info) << "Taking a snapshot...";
// if (! GUI::Config::take_config_snapshot_cancel_on_error(*GUI::wxGetApp().app_config, Snapshot::SNAPSHOT_DOWNGRADE, "",
// _u8L("Continue and install configuration updates?")))
// return false;
//}
BOOST_LOG_TRIVIAL(info) << format("[Orca Updater]:Deleting %1% incompatible bundles", updates.incompats.size()); BOOST_LOG_TRIVIAL(info) << format("[Orca Updater]:Deleting %1% incompatible bundles", updates.incompats.size());
for (auto &incompat : updates.incompats) { for (auto &incompat : updates.incompats) {
@@ -1481,12 +1519,6 @@ bool PresetUpdater::priv::perform_updates(Updates &&updates, bool snapshot) cons
incompat.remove(); incompat.remove();
} }
} else if (updates.updates.size() > 0) { } else if (updates.updates.size() > 0) {
//if (snapshot) {
// BOOST_LOG_TRIVIAL(info) << "Taking a snapshot...";
// if (! GUI::Config::take_config_snapshot_cancel_on_error(*GUI::wxGetApp().app_config, Snapshot::SNAPSHOT_UPGRADE, "",
// _u8L("Continue and install configuration updates?")))
// return false;
//}
BOOST_LOG_TRIVIAL(info) << format("[Orca Updater]:Performing %1% updates", updates.updates.size()); BOOST_LOG_TRIVIAL(info) << format("[Orca Updater]:Performing %1% updates", updates.updates.size());
@@ -1495,28 +1527,8 @@ bool PresetUpdater::priv::perform_updates(Updates &&updates, bool snapshot) cons
if (update.can_install) if (update.can_install)
update.install(); update.install();
//if (!update.is_directory) {
// vendor_path = update.source.parent_path().string();
// vendor_name = update.vendor;
//}
} }
//if (!vendor_path.empty()) {
// PresetBundle bundle;
// // Throw when parsing invalid configuration. Only valid configuration is supposed to be provided over the air.
// bundle.load_vendor_configs_from_json(vendor_path, vendor_name, PresetBundle::LoadConfigBundleAttribute::LoadSystem, ForwardCompatibilitySubstitutionRule::Disable);
// BOOST_LOG_TRIVIAL(info) << format("Deleting %1% conflicting presets", bundle.prints.size() + bundle.filaments.size() + bundle.printers.size());
// auto preset_remover = [](const Preset& preset) {
// BOOST_LOG_TRIVIAL(info) << '\t' << preset.file;
// fs::remove(preset.file);
// };
// for (const auto &preset : bundle.prints) { preset_remover(preset); }
// for (const auto &preset : bundle.filaments) { preset_remover(preset); }
// for (const auto &preset : bundle.printers) { preset_remover(preset); }
//}
} }
return true; return true;
@@ -1555,12 +1567,9 @@ PresetUpdater::~PresetUpdater()
//BBS: refine the preset updater logic //BBS: refine the preset updater logic
void PresetUpdater::sync(std::string http_url, std::string language, std::string plugin_version, PresetBundle *preset_bundle) void PresetUpdater::sync(std::string http_url, std::string language, std::string plugin_version, PresetBundle *preset_bundle)
{ {
//p->set_download_prefs(GUI::wxGetApp().app_config);
if (!p->enabled_version_check && !p->enabled_config_update) { return; } if (!p->enabled_version_check && !p->enabled_config_update) { return; }
// Copy the whole vendors data for use in the background thread
// Unfortunatelly as of C++11, it needs to be copied again
// into the closure (but perhaps the compiler can elide this).
VendorMap vendors = preset_bundle ? preset_bundle->vendors : VendorMap{}; VendorMap vendors = preset_bundle ? preset_bundle->vendors : VendorMap{};
p->thread = std::thread([this, vendors, http_url, language, plugin_version]() { p->thread = std::thread([this, vendors, http_url, language, plugin_version]() {
@@ -1582,10 +1591,7 @@ void PresetUpdater::sync(std::string http_url, std::string language, std::string
return; return;
this->p->sync_plugins(http_url, plugin_version); this->p->sync_plugins(http_url, plugin_version);
this->p->sync_printer_config(http_url); this->p->sync_printer_config(http_url);
//if (p->cancel)
// return;
//remove the tooltip currently
//this->p->sync_tooltip(http_url, language);
}); });
} }
@@ -1603,9 +1609,7 @@ static bool reload_configs_update_gui()
// Reload global configuration // Reload global configuration
auto* app_config = GUI::wxGetApp().app_config; auto* app_config = GUI::wxGetApp().app_config;
// System profiles should not trigger any substitutions, user profiles may trigger substitutions, but these substitutions
// were already presented to the user on application start up. Just do substitutions now and keep quiet about it.
// However throw on substitutions in system profiles, those shall never happen with system profiles installed over the air.
GUI::wxGetApp().preset_bundle->load_presets(*app_config, ForwardCompatibilitySubstitutionRule::EnableSilentDisableSystem); GUI::wxGetApp().preset_bundle->load_presets(*app_config, ForwardCompatibilitySubstitutionRule::EnableSilentDisableSystem);
GUI::wxGetApp().load_current_presets(); GUI::wxGetApp().load_current_presets();
GUI::wxGetApp().plater()->set_bed_shape(); GUI::wxGetApp().plater()->set_bed_shape();