mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	
							parent
							
								
									f5654d80ef
								
							
						
					
					
						commit
						73bb37b7c9
					
				
					 4 changed files with 189 additions and 284 deletions
				
			
		|  | @ -44,6 +44,7 @@ namespace Slic3r { | |||
| 
 | ||||
| static const std::string VERSION_CHECK_URL_STABLE = "https://api.github.com/repos/softfever/OrcaSlicer/releases/latest"; | ||||
| static const std::string VERSION_CHECK_URL = "https://api.github.com/repos/softfever/OrcaSlicer/releases"; | ||||
| static const std::string PROFILE_UPDATE_URL = "https://api.github.com/repos/OrcaSlicer/orcaslicer-profiles/releases/tags"; | ||||
| static const std::string MODELS_STR = "models"; | ||||
| 
 | ||||
| const std::string AppConfig::SECTION_FILAMENTS = "filaments"; | ||||
|  | @ -1264,6 +1265,11 @@ std::string AppConfig::version_check_url(bool stable_only/* = false*/) const | |||
|     return from_settings.empty() ? stable_only ? VERSION_CHECK_URL_STABLE : VERSION_CHECK_URL : from_settings; | ||||
| } | ||||
| 
 | ||||
| std::string AppConfig::profile_update_url() const | ||||
| { | ||||
|     return PROFILE_UPDATE_URL; | ||||
| } | ||||
| 
 | ||||
| bool AppConfig::exists() | ||||
| { | ||||
|     return boost::filesystem::exists(config_path()); | ||||
|  |  | |||
|  | @ -249,6 +249,9 @@ public: | |||
| 	// 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; | ||||
| 
 | ||||
| 	// Get the Orca profile update url.
 | ||||
| 	std::string 		profile_update_url() const; | ||||
| 
 | ||||
| 	// Returns the original Slic3r version found in the ini file before it was overwritten
 | ||||
| 	// by the current version
 | ||||
| 	Semver 				orig_version() const { return m_orig_version; } | ||||
|  |  | |||
|  | @ -1211,9 +1211,6 @@ void GUI_App::post_init() | |||
|     // This is ugly but I honestly found no better way to do it.
 | ||||
|     // Neither wxShowEvent nor wxWindowCreateEvent work reliably.
 | ||||
|     if (this->preset_updater) { // G-Code Viewer does not initialize preset_updater.
 | ||||
|         BOOST_LOG_TRIVIAL(info) << "before check_updates"; | ||||
|         this->check_updates(false); | ||||
|         BOOST_LOG_TRIVIAL(info) << "after check_updates"; | ||||
|         CallAfter([this] { | ||||
|             bool cw_showed = this->config_wizard_startup(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,6 +1,8 @@ | |||
| #include "PresetUpdater.hpp" | ||||
| 
 | ||||
| #include <algorithm> | ||||
| #include <boost/filesystem/operations.hpp> | ||||
| #include <boost/nowide/fstream.hpp> | ||||
| #include <functional> | ||||
| #include <thread> | ||||
| #include <unordered_map> | ||||
|  | @ -21,6 +23,7 @@ | |||
| #include "libslic3r/format.hpp" | ||||
| #include "libslic3r/Utils.hpp" | ||||
| #include "libslic3r/PresetBundle.hpp" | ||||
| #include "libslic3r_version.h" | ||||
| #include "slic3r/GUI/GUI.hpp" | ||||
| #include "slic3r/GUI/GUI_App.hpp" | ||||
| #include "slic3r/GUI/I18N.hpp" | ||||
|  | @ -215,7 +218,7 @@ struct PresetUpdater::priv | |||
| 	void sync_version() const; | ||||
| 	void parse_version_string(const std::string& body) const; | ||||
|     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(std::string http_url, const VendorMap vendors); | ||||
|     void sync_config(); | ||||
|     void sync_tooltip(std::string http_url, std::string language); | ||||
|     void sync_plugins(std::string http_url, std::string plugin_version); | ||||
|     void sync_printer_config(std::string http_url); | ||||
|  | @ -251,8 +254,9 @@ PresetUpdater::priv::priv() | |||
| void PresetUpdater::priv::set_download_prefs(AppConfig *app_config) | ||||
| { | ||||
| 	version_check_url = app_config->version_check_url(); | ||||
| 	//TODO: for debug currently
 | ||||
| 	if (version_check_url.empty()) | ||||
| 
 | ||||
| 	auto profile_update_url = app_config->profile_update_url(); | ||||
| 	if (!profile_update_url.empty()) | ||||
| 		enabled_config_update = true; | ||||
| 	else | ||||
| 		enabled_config_update = false; | ||||
|  | @ -327,29 +331,29 @@ bool PresetUpdater::priv::extract_file(const fs::path &source_path, const fs::pa | |||
| 				continue; | ||||
|             } | ||||
|             else if (stat.m_uncomp_size == 0) { | ||||
|                 BOOST_LOG_TRIVIAL(warning) << "[BBL Updater]Unzip: invalid size for file "<<stat.m_filename; | ||||
|                 BOOST_LOG_TRIVIAL(warning) << "[Orca Updater]Unzip: invalid size for file "<<stat.m_filename; | ||||
|                 continue; | ||||
|             } | ||||
|             try | ||||
|             { | ||||
|                 res = mz_zip_reader_extract_to_file(&archive, stat.m_file_index, dest_file.c_str(), 0); | ||||
|                 if (!res) { | ||||
|                     BOOST_LOG_TRIVIAL(error) << "[BBL Updater]extract file "<<stat.m_filename<<" to dest "<<dest_file<<" failed"; | ||||
|                     BOOST_LOG_TRIVIAL(error) << "[Orca Updater]extract file "<<stat.m_filename<<" to dest "<<dest_file<<" failed"; | ||||
|                     close_zip_reader(&archive); | ||||
|                     return res; | ||||
|                 } | ||||
|                 BOOST_LOG_TRIVIAL(info) << "[BBL Updater]successfully extract file " << stat.m_file_index << " to "<<dest_file; | ||||
|                 BOOST_LOG_TRIVIAL(info) << "[Orca Updater]successfully extract file " << stat.m_file_index << " to "<<dest_file; | ||||
|             } | ||||
|             catch (const std::exception& e) | ||||
|             { | ||||
|                 // ensure the zip archive is closed and rethrow the exception
 | ||||
|                 close_zip_reader(&archive); | ||||
|                 BOOST_LOG_TRIVIAL(error) << "[BBL Updater]Archive read exception:"<<e.what(); | ||||
|                 BOOST_LOG_TRIVIAL(error) << "[Orca Updater]Archive read exception:"<<e.what(); | ||||
|                 return false; | ||||
|             } | ||||
|         } | ||||
|         else { | ||||
|             BOOST_LOG_TRIVIAL(warning) << "[BBL Updater]Unzip: read file stat failed"; | ||||
|             BOOST_LOG_TRIVIAL(warning) << "[Orca Updater]Unzip: read file stat failed"; | ||||
|         } | ||||
|     } | ||||
|     close_zip_reader(&archive); | ||||
|  | @ -362,7 +366,7 @@ void PresetUpdater::priv::prune_tmps() const | |||
| { | ||||
|     for (auto &dir_entry : boost::filesystem::directory_iterator(cache_path)) | ||||
| 		if (is_plain_file(dir_entry) && dir_entry.path().extension() == TMP_EXTENSION) { | ||||
| 			BOOST_LOG_TRIVIAL(debug) << "[BBL Updater]remove old cached files: " << dir_entry.path().string(); | ||||
| 			BOOST_LOG_TRIVIAL(debug) << "[Orca Updater]remove old cached files: " << dir_entry.path().string(); | ||||
| 			fs::remove(dir_entry.path()); | ||||
| 		} | ||||
| } | ||||
|  | @ -473,7 +477,7 @@ void PresetUpdater::priv::sync_resources(std::string http_url, std::map<std::str | |||
| { | ||||
|     std::map<std::string, Resource>    resource_list; | ||||
| 
 | ||||
|     BOOST_LOG_TRIVIAL(info) << boost::format("[BBL Updater]: sync_resources get preferred setting version for app version %1%, url: %2%, current_version_str %3%, check_patch %4%")%SLIC3R_APP_NAME%http_url%current_version_str%check_patch; | ||||
|     BOOST_LOG_TRIVIAL(info) << boost::format("[Orca Updater]: sync_resources get preferred setting version for app version %1%, url: %2%, current_version_str %3%, check_patch %4%")%SLIC3R_APP_NAME%http_url%current_version_str%check_patch; | ||||
| 
 | ||||
|     std::string query_params = "?"; | ||||
|     bool        first        = true; | ||||
|  | @ -491,7 +495,7 @@ void PresetUpdater::priv::sync_resources(std::string http_url, std::map<std::str | |||
|     std::string url = http_url; | ||||
|     url += query_params; | ||||
|     Slic3r::Http http = Slic3r::Http::get(url); | ||||
|     BOOST_LOG_TRIVIAL(info) << boost::format("[BBL Updater]: sync_resources request_url: %1%")%url; | ||||
|     BOOST_LOG_TRIVIAL(info) << boost::format("[Orca Updater]: sync_resources request_url: %1%")%url; | ||||
|     http.on_progress([this](Slic3r::Http::Progress, bool &cancel_http) { | ||||
|             if (cancel) { | ||||
|                 cancel_http = true; | ||||
|  | @ -499,7 +503,7 @@ void PresetUpdater::priv::sync_resources(std::string http_url, std::map<std::str | |||
|         }) | ||||
|         .on_complete([this, &resource_list, resources](std::string body, unsigned) { | ||||
|             try { | ||||
|                 BOOST_LOG_TRIVIAL(info) << "[BBL Updater]: request_resources, body=" << body; | ||||
|                 BOOST_LOG_TRIVIAL(info) << "[Orca Updater]: request_resources, body=" << body; | ||||
| 
 | ||||
|                 json        j       = json::parse(body); | ||||
|                 std::string message = j["message"].get<std::string>(); | ||||
|  | @ -515,7 +519,7 @@ void PresetUpdater::priv::sync_resources(std::string http_url, std::map<std::str | |||
|                             for (auto sub_iter = iter.value().begin(); sub_iter != iter.value().end(); sub_iter++) { | ||||
|                                 if (boost::iequals(sub_iter.key(), "type")) { | ||||
|                                     resource = sub_iter.value(); | ||||
|                                     BOOST_LOG_TRIVIAL(trace) << "[BBL Updater]: get version of settings's type, " << sub_iter.value(); | ||||
|                                     BOOST_LOG_TRIVIAL(trace) << "[Orca Updater]: get version of settings's type, " << sub_iter.value(); | ||||
|                                 } else if (boost::iequals(sub_iter.key(), "version")) { | ||||
|                                     version = sub_iter.value(); | ||||
|                                 } else if (boost::iequals(sub_iter.key(), "description")) { | ||||
|  | @ -524,22 +528,22 @@ void PresetUpdater::priv::sync_resources(std::string http_url, std::map<std::str | |||
|                                     url = sub_iter.value(); | ||||
|                                 } | ||||
|                             } | ||||
|                             BOOST_LOG_TRIVIAL(info) << "[BBL Updater]: get type " << resource << ", version " << version << ", url " << url; | ||||
|                             BOOST_LOG_TRIVIAL(info) << "[Orca Updater]: get type " << resource << ", version " << version << ", url " << url; | ||||
| 
 | ||||
|                             resource_list.emplace(resource, Resource{version, description, url}); | ||||
|                         } | ||||
|                     } | ||||
|                 } else { | ||||
|                     BOOST_LOG_TRIVIAL(error) << "[BBL Updater]: get version of settings failed, body=" << body; | ||||
|                     BOOST_LOG_TRIVIAL(error) << "[Orca Updater]: get version of settings failed, body=" << body; | ||||
|                 } | ||||
|             } catch (std::exception &e) { | ||||
|                 BOOST_LOG_TRIVIAL(error) << (boost::format("[BBL Updater]: get version of settings failed, exception=%1% body=%2%") % e.what() % body).str(); | ||||
|                 BOOST_LOG_TRIVIAL(error) << (boost::format("[Orca Updater]: get version of settings failed, exception=%1% body=%2%") % e.what() % body).str(); | ||||
|             } catch (...) { | ||||
|                 BOOST_LOG_TRIVIAL(error) << "[BBL Updater]: get version of settings failed, body=" << body; | ||||
|                 BOOST_LOG_TRIVIAL(error) << "[Orca Updater]: get version of settings failed, body=" << body; | ||||
|             } | ||||
|         }) | ||||
|         .on_error([&](std::string body, std::string error, unsigned status) { | ||||
|             BOOST_LOG_TRIVIAL(error) << boost::format("[BBL Updater]: status=%1%, error=%2%, body=%3%") % status % error % body; | ||||
|             BOOST_LOG_TRIVIAL(error) << boost::format("[Orca Updater]: status=%1%, error=%2%, body=%3%") % status % error % body; | ||||
|         }) | ||||
|         .perform_sync(); | ||||
| 
 | ||||
|  | @ -551,7 +555,7 @@ void PresetUpdater::priv::sync_resources(std::string http_url, std::map<std::str | |||
|         boost::to_lower(resource_name); | ||||
|         auto        resource_update = resource_list.find(resource_name); | ||||
|         if (resource_update == resource_list.end()) { | ||||
|             BOOST_LOG_TRIVIAL(info) << "[BBL Updater]Vendor " << resource_name << " can not get setting versions online"; | ||||
|             BOOST_LOG_TRIVIAL(info) << "[Orca Updater]Vendor " << resource_name << " can not get setting versions online"; | ||||
|             continue; | ||||
|         } | ||||
|         Semver online_version = resource_update->second.version; | ||||
|  | @ -563,7 +567,7 @@ void PresetUpdater::priv::sync_resources(std::string http_url, std::map<std::str | |||
|             int current_cc_patch = current_version.patch()/100; | ||||
|             if (online_cc_patch != current_cc_patch) { | ||||
|                 version_match = false; | ||||
|                 BOOST_LOG_TRIVIAL(warning) << boost::format("[BBL Updater]: online patch CC not match: online_cc_patch=%1%, current_cc_patch=%2%") % online_cc_patch % current_cc_patch; | ||||
|                 BOOST_LOG_TRIVIAL(warning) << boost::format("[Orca Updater]: online patch CC not match: online_cc_patch=%1%, current_cc_patch=%2%") % online_cc_patch % current_cc_patch; | ||||
|             } | ||||
|         } | ||||
|         if (version_match && (current_version < online_version)) { | ||||
|  | @ -573,9 +577,9 @@ void PresetUpdater::priv::sync_resources(std::string http_url, std::map<std::str | |||
|             fs::path cache_path(resource.cache_root); | ||||
|             std::string online_url      = resource_update->second.url; | ||||
|             std::string cache_file_path = (fs::temp_directory_path() / (fs::unique_path().string() + TMP_EXTENSION)).string(); | ||||
|             BOOST_LOG_TRIVIAL(info) << "[BBL Updater]Downloading resource: " << resource_name << ", version " << online_version.to_string(); | ||||
|             BOOST_LOG_TRIVIAL(info) << "[Orca Updater]Downloading resource: " << resource_name << ", version " << online_version.to_string(); | ||||
|             if (!get_file(online_url, cache_file_path)) { | ||||
|                 BOOST_LOG_TRIVIAL(warning) << "[BBL Updater]download resource " << resource_name << " failed, url: " << online_url; | ||||
|                 BOOST_LOG_TRIVIAL(warning) << "[Orca Updater]download resource " << resource_name << " failed, url: " << online_url; | ||||
|                 continue; | ||||
|             } | ||||
|             if (cancel) { return; } | ||||
|  | @ -584,24 +588,24 @@ void PresetUpdater::priv::sync_resources(std::string http_url, std::map<std::str | |||
|             if (resource.sub_caches.empty()) { | ||||
|                 if (fs::exists(cache_path)) { | ||||
|                     fs::remove_all(cache_path); | ||||
|                     BOOST_LOG_TRIVIAL(info) << "[BBL Updater]remove cache path " << cache_path.string(); | ||||
|                     BOOST_LOG_TRIVIAL(info) << "[Orca Updater]remove cache path " << cache_path.string(); | ||||
|                 } | ||||
|             } else { | ||||
|                 for (auto sub : resource.sub_caches) { | ||||
|                     if (fs::exists(cache_path / sub)) { | ||||
|                         fs::remove_all(cache_path / sub); | ||||
|                         BOOST_LOG_TRIVIAL(info) << "[BBL Updater]remove cache path " << (cache_path / sub).string(); | ||||
|                         BOOST_LOG_TRIVIAL(info) << "[Orca Updater]remove cache path " << (cache_path / sub).string(); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|             // extract the file downloaded
 | ||||
|             BOOST_LOG_TRIVIAL(info) << "[BBL Updater]start to unzip the downloaded file " << cache_file_path << " to "<<cache_path; | ||||
|             BOOST_LOG_TRIVIAL(info) << "[Orca Updater]start to unzip the downloaded file " << cache_file_path << " to "<<cache_path; | ||||
|             fs::create_directories(cache_path); | ||||
|             if (!extract_file(cache_file_path, cache_path)) { | ||||
|                 BOOST_LOG_TRIVIAL(warning) << "[BBL Updater]extract resource " << resource_it.first << " failed, path: " << cache_file_path; | ||||
|                 BOOST_LOG_TRIVIAL(warning) << "[Orca Updater]extract resource " << resource_it.first << " failed, path: " << cache_file_path; | ||||
|                 continue; | ||||
|             } | ||||
|             BOOST_LOG_TRIVIAL(info) << "[BBL Updater]finished unzip the downloaded file " << cache_file_path; | ||||
|             BOOST_LOG_TRIVIAL(info) << "[Orca Updater]finished unzip the downloaded file " << cache_file_path; | ||||
| 
 | ||||
|             // save the description to disk
 | ||||
|             if (changelog_file.empty()) | ||||
|  | @ -627,202 +631,129 @@ void PresetUpdater::priv::sync_resources(std::string http_url, std::map<std::str | |||
|             resource_it.second = resource_update->second; | ||||
|         } | ||||
|         else { | ||||
|             BOOST_LOG_TRIVIAL(warning) << boost::format("[BBL Updater]: online version=%1%, current_version=%2%, no need to download") % online_version.to_string() % current_version.to_string(); | ||||
|             BOOST_LOG_TRIVIAL(warning) << boost::format("[Orca Updater]: online version=%1%, current_version=%2%, no need to download") % online_version.to_string() % current_version.to_string(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| //BBS: refine the Preset Updater logic
 | ||||
| // Download vendor indices. Also download new bundles if an index indicates there's a new one available.
 | ||||
| // Both are saved in cache.
 | ||||
| void PresetUpdater::priv::sync_config(std::string http_url, const VendorMap vendors) | ||||
| // Orca: sync config update for currect App version
 | ||||
| void PresetUpdater::priv::sync_config() | ||||
| { | ||||
|     std::map<std::string, std::pair<Semver, std::string>> vendor_list; | ||||
|     std::map<std::string, std::string> vendor_descriptions; | ||||
|     auto cache_profile_path        = cache_path; | ||||
|     auto cache_profile_update_file = cache_path / "profiles_update.json"; | ||||
|     std::string asset_name; | ||||
|     if (fs::exists(cache_profile_update_file)) { | ||||
|         try { | ||||
|             boost::nowide::ifstream f(cache_profile_update_file.string()); | ||||
|             json                    data = json::parse(f); | ||||
|             if (data.contains("name")) | ||||
|                 asset_name = data["name"].get<std::string>(); | ||||
|             f.close(); | ||||
|         } catch (const std::exception& ex) { | ||||
|             BOOST_LOG_TRIVIAL(error) << "[Orca Updater]: failed to read profiles_update.json when sync_config: " << ex.what() << std::endl; | ||||
|         } catch (...) { | ||||
|             // catch any other errors (that we have no information about)
 | ||||
|             BOOST_LOG_TRIVIAL(error) << "[Orca Updater]: unknown failure when reading profiles_update.json in sync_config" << std::endl; | ||||
|         } | ||||
|     } | ||||
|     AppConfig *app_config = GUI::wxGetApp().app_config; | ||||
| 
 | ||||
|     BOOST_LOG_TRIVIAL(info) << boost::format("[BBL Updater]: sync_config Syncing configuration enter"); | ||||
|     auto profile_update_url = app_config->profile_update_url() + "/" + SoftFever_VERSION; | ||||
|     // parse the assets section and get the latest asset by comparing the name
 | ||||
| 
 | ||||
|     if (!enabled_config_update) { return; } | ||||
| 
 | ||||
|     BOOST_LOG_TRIVIAL(info) << boost::format("[BBL Updater]: sync_config get preferred setting version for app version %1%, http_url: %2%")%SLIC3R_VERSION%http_url; | ||||
| 
 | ||||
|     std::string app_version = SLIC3R_VERSION; | ||||
|     std::string query_version = app_version.substr(0, 6) + "00.00"; | ||||
|     std::string query_params = "?"; | ||||
|     std::string vendor_string = PresetBundle::BBL_BUNDLE; | ||||
|     boost::to_lower(vendor_string); | ||||
|     std::string query_vendor = (boost::format("slicer/settings/%1%=%2%")%vendor_string % query_version ).str(); | ||||
|     query_params += query_vendor; | ||||
|     /*bool first = true;
 | ||||
|     for (auto vendor_it :vendors) { | ||||
|         if (cancel) { return; } | ||||
| 
 | ||||
|         const VendorProfile& vendor_profile = vendor_it.second; | ||||
|         std::string vendor_name = vendor_profile.id; | ||||
|         boost::to_lower(vendor_name); | ||||
| 
 | ||||
|         std::string query_vendor = (boost::format("slicer/settings/%1%=%2%") | ||||
|             % vendor_name | ||||
|             % GUI::VersionInfo::convert_full_version(SLIC3R_VERSION) | ||||
|             ).str(); | ||||
|         if (!first) | ||||
|             query_params += "&"; | ||||
|         query_params += query_vendor; | ||||
|     }*/ | ||||
| 
 | ||||
|     std::string url = http_url; | ||||
|     url += query_params; | ||||
|     Slic3r::Http http = Slic3r::Http::get(url); | ||||
|     BOOST_LOG_TRIVIAL(info) << boost::format("[BBL Updater]: sync_config request_url: %1%")%url; | ||||
|     http.on_progress([this](Slic3r::Http::Progress, bool &cancel_http) { | ||||
|             if (cancel) { | ||||
|                 cancel_http = true; | ||||
|     Http::get(profile_update_url) | ||||
|         .on_error([cache_profile_path, cache_profile_update_file](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
 | ||||
|             // updates, we can delete the cache file
 | ||||
|             if (!body.empty()) { | ||||
|                 try { | ||||
|                     json j = json::parse(body); | ||||
|                     if (j.contains("message") && j["message"].get<std::string>() == "Not Found") { | ||||
|                         // The current Orca version does not have any OTA updates, delete the cache file
 | ||||
|                         if (fs::exists(cache_profile_path / "profiles")) | ||||
|                             fs::remove_all(cache_profile_path / "profiles"); | ||||
|                         if (fs::exists(cache_profile_update_file)) | ||||
|                             fs::remove(cache_profile_update_file); | ||||
|                     } | ||||
|                 } catch (...) {} | ||||
|             } | ||||
|             BOOST_LOG_TRIVIAL(error) << format("Error getting: `%1%`: HTTP %2%, %3%", "sync_config_orca", http_status, error); | ||||
|         }) | ||||
|         .on_complete( | ||||
|         [this, &vendor_list, &vendor_descriptions, vendors](std::string body, unsigned) { | ||||
|         .timeout_connect(5) | ||||
|         .on_complete([this, asset_name, cache_profile_path, cache_profile_update_file](std::string body, unsigned http_status) { | ||||
|             // Http response OK
 | ||||
|             if (http_status != 200) | ||||
|                 return; | ||||
|             try { | ||||
|                 BOOST_LOG_TRIVIAL(info) << "[BBL Updater]::body=" << body; | ||||
| 
 | ||||
|                 json j = json::parse(body); | ||||
|                 std::string message = j["message"].get<std::string>(); | ||||
| 
 | ||||
|                 if (message == "success") { | ||||
|                     json resource =j.at("resources"); | ||||
|                     if (resource.is_array()) { | ||||
|                         for (auto iter = resource.begin(); iter != resource.end(); iter++) { | ||||
|                             Semver version; | ||||
|                             std::string url; | ||||
|                             std::string type; | ||||
|                             std::string vendor; | ||||
|                             std::string description; | ||||
|                             for (auto sub_iter = iter.value().begin(); sub_iter != iter.value().end(); sub_iter++) { | ||||
|                                 if (boost::iequals(sub_iter.key(),"type")) { | ||||
|                                     type = sub_iter.value(); | ||||
|                                     BOOST_LOG_TRIVIAL(trace) << "[BBL Updater]: get version of settings's type, " << sub_iter.value(); | ||||
|                                 } | ||||
|                                 else if (boost::iequals(sub_iter.key(),"version")) { | ||||
|                                     version = *(Semver::parse(sub_iter.value())); | ||||
|                                 } | ||||
|                                 else if (boost::iequals(sub_iter.key(),"description")) { | ||||
|                                     description = sub_iter.value(); | ||||
|                                 } | ||||
|                                 else if (boost::iequals(sub_iter.key(),"url")) { | ||||
|                                     url = sub_iter.value(); | ||||
|                                 } | ||||
|                             } | ||||
|                             BOOST_LOG_TRIVIAL(info) << "[BBL Updater]: get type "<< type <<", version "<<version.to_string()<<", url " << url; | ||||
|                 struct update | ||||
|                 { | ||||
|                     std::string url; | ||||
|                     std::string name; | ||||
|                     int         ver = -9999; | ||||
|                 } latest_update; | ||||
| 
 | ||||
|                             for (auto vendor_it :vendors) { | ||||
|                                 const VendorProfile& vendor_profile = vendor_it.second; | ||||
|                                 std::string vendor_name = vendor_profile.id; | ||||
|                                 boost::to_lower(vendor_name); | ||||
|                                 if (type.find(vendor_name) != std::string::npos) { | ||||
|                                     vendor = vendor_profile.id; | ||||
|                                     break; | ||||
|                                 } | ||||
|                 if (!(j.contains("message") && j["message"].get<std::string>() == "Not Found")) { | ||||
|                     json assets = j.at("assets"); | ||||
|                     if (assets.is_array()) { | ||||
|                         for (auto asset : assets) { | ||||
|                             std::string name          = asset["name"].get<std::string>(); | ||||
|                             int         versionNumber = -1; | ||||
|                             std::regex  regexPattern("orcaslicer-profiles_ota_.*\\.([0-9]+)\\.zip$"); | ||||
|                             std::smatch matches; | ||||
|                             if (std::regex_search(name, matches, regexPattern) && matches.size() > 1) { | ||||
|                                 versionNumber = std::stoi(matches[1].str()); | ||||
|                             } | ||||
|                             if (!vendor.empty()) { | ||||
|                                 vendor_list.emplace(vendor, std::pair<Semver, std::string>(version, url)); | ||||
|                                 vendor_descriptions.emplace(vendor, description); | ||||
|                             if (versionNumber > 0 && versionNumber > latest_update.ver) { | ||||
|                                 latest_update.url  = asset["browser_download_url"].get<std::string>(); | ||||
|                                 latest_update.name = name; | ||||
|                                 latest_update.ver  = versionNumber; | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|                 else { | ||||
|                     BOOST_LOG_TRIVIAL(error) << "[BBL Updater]: get version of settings failed, body=" << body; | ||||
| 
 | ||||
|                 if (cancel) | ||||
|                     return; | ||||
| 
 | ||||
|                 if (latest_update.ver > 0) { | ||||
|                     if (latest_update.name == asset_name) | ||||
|                         return; | ||||
|                     if (fs::exists(cache_profile_path / "profiles")) | ||||
|                         fs::remove_all(cache_profile_path / "profiles"); | ||||
|                     fs::create_directories(cache_profile_path / "profiles"); | ||||
|                     // download the file
 | ||||
|                     std::string download_url  = latest_update.url; | ||||
|                     std::string download_file = (cache_path / (latest_update.name + TMP_EXTENSION)).string(); | ||||
|                     if (!get_file(download_url, download_file)) { | ||||
|                         return; | ||||
|                     } | ||||
| 
 | ||||
|                     // extract the file downloaded
 | ||||
|                     BOOST_LOG_TRIVIAL(info) << "[Orca Updater]start to unzip the downloaded file " << download_file; | ||||
|                     if (!extract_file(download_file, cache_profile_path)) { | ||||
|                         BOOST_LOG_TRIVIAL(warning) << "[Orca Updater]extract downloaded file" | ||||
|                                                    << " failed, path: " << download_file; | ||||
|                         return; | ||||
|                     } | ||||
|                     BOOST_LOG_TRIVIAL(info) << "[Orca Updater]finished unzip the downloaded file " << download_file; | ||||
|                     boost::nowide::ofstream f(cache_profile_update_file.string()); | ||||
|                     json                    data; | ||||
|                     data["name"] = latest_update.name; | ||||
|                     f << data << std::endl; | ||||
|                     f.close(); | ||||
|                 } else { | ||||
|                     // The current Orca version does not have any OTA updates, delete the cache file
 | ||||
|                     if (fs::exists(cache_profile_path / "profiles")) | ||||
|                         fs::remove_all(cache_profile_path / "profiles"); | ||||
|                     if (fs::exists(cache_profile_update_file)) | ||||
|                         fs::remove(cache_profile_update_file); | ||||
|                 } | ||||
|             } | ||||
|             catch (std::exception& e) { | ||||
|                 BOOST_LOG_TRIVIAL(error) << (boost::format("[BBL Updater]: get version of settings failed, exception=%1% body=%2%") | ||||
|                     % e.what() | ||||
|                     % body).str(); | ||||
|             } | ||||
|             catch (...) { | ||||
|                 BOOST_LOG_TRIVIAL(error) << "[BBL Updater]: get version of settings failed,, body=" << body; | ||||
|             } | ||||
|         } | ||||
|     ) | ||||
|     .on_error([&](std::string body, std::string error, unsigned status) { | ||||
|             BOOST_LOG_TRIVIAL(error) << boost::format("[BBL Updater]: status=%1%, error=%2%, body=%3%") | ||||
|                 % status | ||||
|                 % error | ||||
|                 % body; | ||||
|         } | ||||
|     ) | ||||
|     .perform_sync(); | ||||
| 
 | ||||
|     for (auto vendor_it :vendors) { | ||||
|         if (cancel) { return; } | ||||
| 
 | ||||
|         const VendorProfile& vendor_profile = vendor_it.second; | ||||
|         std::string vendor_name = vendor_profile.id; | ||||
|         auto vendor_update = vendor_list.find(vendor_name); | ||||
|         if (vendor_update == vendor_list.end()) { | ||||
| 			BOOST_LOG_TRIVIAL(info) << "[BBL Updater]Vendor " << vendor_name << " can not get setting versions online"; | ||||
| 			continue; | ||||
| 		} | ||||
|         Semver online_version = vendor_update->second.first; | ||||
|         //Semver current_version = get_version_from_json(vendor_root_config.string());
 | ||||
|         Semver current_version = vendor_profile.config_version; | ||||
|         bool version_match = ((online_version.maj() == current_version.maj()) && (online_version.min() == current_version.min())); | ||||
|         if (version_match && (current_version < online_version)) { | ||||
|             auto cache_file = cache_path / (vendor_name+".json"); | ||||
|             auto cache_print_dir = (cache_path / vendor_name / PRESET_PRINT_NAME); | ||||
|             auto cache_filament_dir = (cache_path / vendor_name / PRESET_FILAMENT_NAME); | ||||
|             auto cache_machine_dir = (cache_path / vendor_name / PRESET_PRINTER_NAME); | ||||
| 
 | ||||
|             if (( fs::exists(cache_file)) | ||||
|                 &&( fs::exists(cache_print_dir)) | ||||
|                 &&( fs::exists(cache_filament_dir)) | ||||
|                 &&( fs::exists(cache_machine_dir))) { | ||||
|                 Semver version = get_version_from_json(cache_file.string()); | ||||
|                 bool cached_version_match = ((online_version.maj() == version.maj()) && (online_version.min() == version.min())); | ||||
|                 if (cached_version_match && (version >= online_version)) { | ||||
|                     //already downloaded before
 | ||||
|                     BOOST_LOG_TRIVIAL(info) << "[BBL Updater]Vendor " << vendor_name << ", already cached a version "<<version.to_string(); | ||||
|                     continue; | ||||
|                 } | ||||
|             } | ||||
|             if (cancel) { return; } | ||||
| 
 | ||||
|             //need to download the online files
 | ||||
|             std::string online_url = vendor_update->second.second; | ||||
|             std::string cache_file_path = (cache_path / (vendor_name + TMP_EXTENSION)).string(); | ||||
|             BOOST_LOG_TRIVIAL(info) << "[BBL Updater]Downloading online settings for vendor: " << vendor_name<<", version "<<online_version.to_string(); | ||||
|             if (!get_file(online_url, cache_file_path)) { | ||||
|                 BOOST_LOG_TRIVIAL(warning) << "[BBL Updater]download settings for vendor "<<vendor_name<<" failed, url: " << online_url; | ||||
|                 continue; | ||||
|             } | ||||
| 		    if (cancel) { return; } | ||||
| 
 | ||||
|             //remove previous files before
 | ||||
|             if (fs::exists(cache_print_dir)) | ||||
|                 fs::remove_all(cache_print_dir); | ||||
|             if (fs::exists(cache_filament_dir)) | ||||
|                 fs::remove_all(cache_filament_dir); | ||||
|             if (fs::exists(cache_machine_dir)) | ||||
|                 fs::remove_all(cache_machine_dir); | ||||
|             //extract the file downloaded
 | ||||
|             BOOST_LOG_TRIVIAL(info) << "[BBL Updater]start to unzip the downloaded file "<< cache_file_path; | ||||
|             if (!extract_file(cache_file_path)) { | ||||
|                 BOOST_LOG_TRIVIAL(warning) << "[BBL Updater]extract settings for vendor "<<vendor_name<<" failed, path: " << cache_file_path; | ||||
|                 continue; | ||||
|             } | ||||
|             BOOST_LOG_TRIVIAL(info) << "[BBL Updater]finished unzip the downloaded file "<< cache_file_path; | ||||
| 
 | ||||
|             auto vendor_description = vendor_descriptions.find(vendor_name); | ||||
|             if (vendor_description != vendor_descriptions.end()) { | ||||
|                 //save the description to disk
 | ||||
|                 std::string changelog_file = (cache_path / (vendor_name + ".changelog")).string(); | ||||
| 
 | ||||
|                 boost::nowide::ofstream c; | ||||
|                 c.open(changelog_file, std::ios::out | std::ios::trunc); | ||||
|                 c << vendor_description->second << std::endl; | ||||
|                 c.close(); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|             } catch (...) {} | ||||
|         }) | ||||
|         .perform_sync(); | ||||
| } | ||||
| 
 | ||||
| void PresetUpdater::priv::sync_tooltip(std::string http_url, std::string language) | ||||
|  | @ -851,7 +782,7 @@ void PresetUpdater::priv::sync_tooltip(std::string http_url, std::string languag | |||
|         } | ||||
|     } | ||||
|     catch (std::exception& e) { | ||||
|         BOOST_LOG_TRIVIAL(warning) << format("[BBL Updater] sync_tooltip: %1%", e.what()); | ||||
|         BOOST_LOG_TRIVIAL(warning) << format("[Orca Updater] sync_tooltip: %1%", e.what()); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | @ -989,12 +920,12 @@ void PresetUpdater::priv::sync_plugins(std::string http_url, std::string plugin_ | |||
|         sync_resources(http_url, resources, true, plugin_version, "network_plugins.json"); | ||||
|     } | ||||
|     catch (std::exception& e) { | ||||
|         BOOST_LOG_TRIVIAL(warning) << format("[BBL Updater] sync_plugins: %1%", e.what()); | ||||
|         BOOST_LOG_TRIVIAL(warning) << format("[Orca Updater] sync_plugins: %1%", e.what()); | ||||
|     } | ||||
| 
 | ||||
|     bool result = get_cached_plugins_version(cached_version); | ||||
|     if (result) { | ||||
|         BOOST_LOG_TRIVIAL(info) << format("[BBL Updater] found new plugins: %1%, prompt to update", cached_version); | ||||
|         BOOST_LOG_TRIVIAL(info) << format("[Orca Updater] found new plugins: %1%, prompt to update", cached_version); | ||||
|         GUI::wxGetApp().plater()->get_notification_manager()->push_notification(GUI::NotificationType::BBLPluginUpdateAvailable); | ||||
|     } | ||||
| } | ||||
|  | @ -1044,7 +975,7 @@ void PresetUpdater::priv::sync_printer_config(std::string http_url) | |||
|         std::map<std::string, Resource> resources{{"slicer/printer/bbl", {using_version, "", "", cache_folder.string()}}}; | ||||
|         sync_resources(http_url, resources, false, cached_version, "printer.json"); | ||||
|     } catch (std::exception &e) { | ||||
|         BOOST_LOG_TRIVIAL(warning) << format("[BBL Updater] sync_printer_config: %1%", e.what()); | ||||
|         BOOST_LOG_TRIVIAL(warning) << format("[Orca Updater] sync_printer_config: %1%", e.what()); | ||||
|     } | ||||
| 
 | ||||
|     bool result = false; | ||||
|  | @ -1054,7 +985,7 @@ void PresetUpdater::priv::sync_printer_config(std::string http_url) | |||
|         result = true; | ||||
|     } catch (...) {} | ||||
|     if (result) { | ||||
|         BOOST_LOG_TRIVIAL(info) << format("[BBL Updater] found new printer config: %1%, prompt to update", cached_version); | ||||
|         BOOST_LOG_TRIVIAL(info) << format("[Orca Updater] found new printer config: %1%, prompt to update", cached_version); | ||||
|         waiting_printer_updates = get_printer_config_updates(true); | ||||
|         if (waiting_printer_updates.updates.size() > 0) { | ||||
|             has_waiting_printer_updates = true; | ||||
|  | @ -1096,7 +1027,7 @@ bool PresetUpdater::priv::install_bundles_rsrc(std::vector<std::string> bundles, | |||
| // Install indicies from resources. Only installs those that are either missing or older than in resources.
 | ||||
| void PresetUpdater::priv::check_installed_vendor_profiles() const | ||||
| { | ||||
|     BOOST_LOG_TRIVIAL(info) << "[BBL Updater]:Checking whether the profile from resource is newer"; | ||||
|     BOOST_LOG_TRIVIAL(info) << "[Orca Updater]:Checking whether the profile from resource is newer"; | ||||
| 
 | ||||
|     AppConfig *app_config = GUI::wxGetApp().app_config; | ||||
|     const auto enabled_vendors = app_config->vendors(); | ||||
|  | @ -1120,7 +1051,7 @@ void PresetUpdater::priv::check_installed_vendor_profiles() const | |||
|                         bool version_match = ((resource_ver.maj() == vendor_ver.maj()) && (resource_ver.min() == vendor_ver.min())); | ||||
| 
 | ||||
|                         if (!version_match || (vendor_ver < resource_ver)) { | ||||
|                             BOOST_LOG_TRIVIAL(info) << "[BBL Updater]:found vendor "<<vendor_name<<" newer version "<<resource_ver.to_string() <<" from resource, old version "<<vendor_ver.to_string(); | ||||
|                             BOOST_LOG_TRIVIAL(info) << "[Orca Updater]:found vendor "<<vendor_name<<" newer version "<<resource_ver.to_string() <<" from resource, old version "<<vendor_ver.to_string(); | ||||
|                             bundles.push_back(vendor_name); | ||||
|                         } | ||||
|                     } | ||||
|  | @ -1171,7 +1102,7 @@ Updates PresetUpdater::priv::get_printer_config_updates(bool update) const | |||
|         bool version_match = ((resc_ver.maj() == curr_ver.maj()) && (resc_ver.min() == curr_ver.min())); | ||||
| 
 | ||||
|         if (!version_match || (curr_ver < resc_ver)) { | ||||
|             BOOST_LOG_TRIVIAL(info) << "[BBL Updater]:found newer version " << resc_version << " from resource, old version " << curr_version; | ||||
|             BOOST_LOG_TRIVIAL(info) << "[Orca Updater]:found newer version " << resc_version << " from resource, old version " << curr_version; | ||||
|         } else { | ||||
|             return {}; | ||||
|         } | ||||
|  | @ -1196,14 +1127,17 @@ Updates PresetUpdater::priv::get_printer_config_updates(bool update) const | |||
| // Generates a list of bundle updates that are to be performed.
 | ||||
| // Version of slic3r that was running the last time and which was read out from PrusaSlicer.ini is provided
 | ||||
| // as a parameter.
 | ||||
| //BBS: refine the Preset Updater logic
 | ||||
| // Orca: OTA profile updates should be loacated in ota/profiles folder
 | ||||
| Updates PresetUpdater::priv::get_config_updates(const Semver &old_slic3r_version) const | ||||
| { | ||||
| 	Updates updates; | ||||
| 
 | ||||
| 	BOOST_LOG_TRIVIAL(info) << "[BBL Updater]:Checking for cached configuration updates..."; | ||||
| 	BOOST_LOG_TRIVIAL(info) << "[Orca Updater]:Checking for cached configuration updates..."; | ||||
|     auto cache_profile_path =  cache_path / "profiles"; | ||||
|     if (!fs::exists(cache_profile_path)) | ||||
|         return updates; | ||||
| 
 | ||||
|     for (auto &dir_entry : boost::filesystem::directory_iterator(cache_path)) { | ||||
|     for (auto &dir_entry : boost::filesystem::directory_iterator(cache_profile_path)) { | ||||
|         const auto &path = dir_entry.path(); | ||||
|         std::string file_path = path.string(); | ||||
|         if (is_json_file(file_path)) { | ||||
|  | @ -1211,9 +1145,9 @@ Updates PresetUpdater::priv::get_config_updates(const Semver &old_slic3r_version | |||
|             std::string vendor_name = path.filename().string(); | ||||
|             // Remove the .json suffix.
 | ||||
|             vendor_name.erase(vendor_name.size() - 5); | ||||
|             auto print_in_cache = (cache_path / vendor_name / PRESET_PRINT_NAME); | ||||
|             auto filament_in_cache = (cache_path / vendor_name / PRESET_FILAMENT_NAME); | ||||
|             auto machine_in_cache = (cache_path / vendor_name / PRESET_PRINTER_NAME); | ||||
|             auto print_in_cache = (cache_profile_path / vendor_name / PRESET_PRINT_NAME); | ||||
|             auto filament_in_cache = (cache_profile_path / vendor_name / PRESET_FILAMENT_NAME); | ||||
|             auto machine_in_cache = (cache_profile_path / vendor_name / PRESET_PRINTER_NAME); | ||||
| 
 | ||||
|             if (( fs::exists(path_in_vendor)) | ||||
|                 &&( fs::exists(print_in_cache)) | ||||
|  | @ -1237,13 +1171,12 @@ Updates PresetUpdater::priv::get_config_updates(const Semver &old_slic3r_version | |||
|                     cache_ver = *config_version; | ||||
| 
 | ||||
|                 std::string changelog; | ||||
|                 std::string changelog_file = (cache_path / (vendor_name + ".changelog")).string(); | ||||
|                 std::string changelog_file = (cache_profile_path / (vendor_name + ".changelog")).string(); | ||||
|                 boost::nowide::ifstream ifs(changelog_file); | ||||
|                 if (ifs) { | ||||
|                     std::ostringstream oss; | ||||
|                     oss<< ifs.rdbuf(); | ||||
|                     changelog = oss.str(); | ||||
|                     //ifs>>changelog;
 | ||||
|                     ifs.close(); | ||||
|                 } | ||||
| 
 | ||||
|  | @ -1251,15 +1184,13 @@ Updates PresetUpdater::priv::get_config_updates(const Semver &old_slic3r_version | |||
|                 if (version_match && (vendor_ver < cache_ver)) { | ||||
|                     Semver app_ver = *Semver::parse(SLIC3R_VERSION); | ||||
|                     if (cache_ver.maj() == app_ver.maj()){ | ||||
|                         BOOST_LOG_TRIVIAL(info) << "[BBL Updater]:need to update settings from "<<vendor_ver.to_string()<<" to newer version "<<cache_ver.to_string() <<", app version "<<SLIC3R_VERSION; | ||||
|                         BOOST_LOG_TRIVIAL(info) << "[Orca Updater]:need to update settings from "<<vendor_ver.to_string()<<" to newer version "<<cache_ver.to_string() <<", app version "<<SLIC3R_VERSION; | ||||
|                         Version version; | ||||
|                         version.config_version = cache_ver; | ||||
|                         version.comment = description; | ||||
| 
 | ||||
|                         updates.updates.emplace_back(std::move(file_path), std::move(path_in_vendor.string()), std::move(version), vendor_name, changelog, "", force_update, false); | ||||
| 
 | ||||
|                         //BBS: add directory support
 | ||||
|                         updates.updates.emplace_back(cache_path / vendor_name, vendor_path / vendor_name, Version(), vendor_name, "", "", force_update, true); | ||||
|                         updates.updates.emplace_back(cache_profile_path / vendor_name, vendor_path / vendor_name, Version(), vendor_name, "", "", force_update, true); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|  | @ -1281,7 +1212,7 @@ bool PresetUpdater::priv::perform_updates(Updates &&updates, bool snapshot) cons | |||
|         //		_u8L("Continue and install configuration updates?")))
 | ||||
|         //		return false;
 | ||||
|         //}
 | ||||
|         BOOST_LOG_TRIVIAL(info) << format("[BBL 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) { | ||||
|             BOOST_LOG_TRIVIAL(info) << '\t' << incompat; | ||||
|  | @ -1295,7 +1226,7 @@ bool PresetUpdater::priv::perform_updates(Updates &&updates, bool snapshot) cons | |||
|         //		return false;
 | ||||
|         //}
 | ||||
| 
 | ||||
|         BOOST_LOG_TRIVIAL(info) << format("[BBL Updater]:Performing %1% updates", updates.updates.size()); | ||||
|         BOOST_LOG_TRIVIAL(info) << format("[Orca Updater]:Performing %1% updates", updates.updates.size()); | ||||
| 
 | ||||
|         for (const auto &update : updates.updates) { | ||||
|             BOOST_LOG_TRIVIAL(info) << '\t' << update; | ||||
|  | @ -1371,7 +1302,7 @@ void PresetUpdater::sync(std::string http_url, std::string language, std::string | |||
| 		if (p->cancel) | ||||
| 			return; | ||||
|         if (!vendors.empty()) { | ||||
| 		    this->p->sync_config(http_url, std::move(vendors)); | ||||
| 		    this->p->sync_config(); | ||||
| 		    if (p->cancel) | ||||
| 			    return; | ||||
|             GUI::wxGetApp().CallAfter([] { | ||||
|  | @ -1413,81 +1344,50 @@ static bool reload_configs_update_gui() | |||
| 	return true; | ||||
| } | ||||
| 
 | ||||
| //BBS: refine the preset updater logic
 | ||||
| 
 | ||||
| PresetUpdater::UpdateResult PresetUpdater::config_update(const Semver& old_slic3r_version, UpdateParams params) const | ||||
| { | ||||
|     if (! p->enabled_config_update) { return R_NOOP; } | ||||
| 
 | ||||
|     auto updates = p->get_config_updates(old_slic3r_version); | ||||
|     //if (updates.incompats.size() > 0) {
 | ||||
|     //	BOOST_LOG_TRIVIAL(info) << format("%1% bundles incompatible. Asking for action...", updates.incompats.size());
 | ||||
| 
 | ||||
|     //	std::unordered_map<std::string, wxString> incompats_map;
 | ||||
|     //	for (const auto &incompat : updates.incompats) {
 | ||||
|     //		const auto min_slic3r = incompat.version.min_slic3r_version;
 | ||||
|     //		const auto max_slic3r = incompat.version.max_slic3r_version;
 | ||||
|     //		wxString restrictions;
 | ||||
|     //		if (min_slic3r != Semver::zero() && max_slic3r != Semver::inf()) {
 | ||||
|     //               restrictions = GUI::format_wxstr(_L("requires min. %s and max. %s"),
 | ||||
|     //                   min_slic3r.to_string(),
 | ||||
|     //                   max_slic3r.to_string());
 | ||||
|     //		} else if (min_slic3r != Semver::zero()) {
 | ||||
|     //			restrictions = GUI::format_wxstr(_L("requires min. %s"), min_slic3r.to_string());
 | ||||
|     //			BOOST_LOG_TRIVIAL(debug) << "Bundle is not downgrade, user will now have to do whole wizard. This should not happen.";
 | ||||
|     //		} else {
 | ||||
|     //               restrictions = GUI::format_wxstr(_L("requires max. %s"), max_slic3r.to_string());
 | ||||
|     //		}
 | ||||
| 
 | ||||
|     //		incompats_map.emplace(std::make_pair(incompat.vendor, std::move(restrictions)));
 | ||||
|     //	}
 | ||||
| 
 | ||||
|     //	GUI::MsgDataIncompatible dlg(std::move(incompats_map));
 | ||||
|     //	const auto res = dlg.ShowModal();
 | ||||
|     //	if (res == wxID_REPLACE) {
 | ||||
|     //		BOOST_LOG_TRIVIAL(info) << "User wants to re-configure...";
 | ||||
| 
 | ||||
|     //		// This effectively removes the incompatible bundles:
 | ||||
|     //		// (snapshot is taken beforehand)
 | ||||
|     //		if (! p->perform_updates(std::move(updates)) ||
 | ||||
|     //			! GUI::wxGetApp().run_wizard(GUI::ConfigWizard::RR_DATA_INCOMPAT))
 | ||||
|     //			return R_INCOMPAT_EXIT;
 | ||||
| 
 | ||||
|     //		return R_INCOMPAT_CONFIGURED;
 | ||||
|     //	}
 | ||||
|     //	else {
 | ||||
|     //		BOOST_LOG_TRIVIAL(info) << "User wants to exit Slic3r, bye...";
 | ||||
|     //		return R_INCOMPAT_EXIT;
 | ||||
|     //	}
 | ||||
| 
 | ||||
|     //} else
 | ||||
|     if (updates.updates.size() > 0) { | ||||
| 
 | ||||
|         bool force_update = false; | ||||
|         for (const auto& update : updates.updates) { | ||||
|             force_update = (update.forced_update ? true : force_update); | ||||
|             //td::cout << update.forced_update << std::endl;
 | ||||
|             //BOOST_LOG_TRIVIAL(info) << format("Update requires higher version.");
 | ||||
|         } | ||||
| 
 | ||||
|         //forced update
 | ||||
|         if (force_update) | ||||
|         { | ||||
|             BOOST_LOG_TRIVIAL(info) << format("[BBL Updater]:Force updating will start, size %1% ", updates.updates.size()); | ||||
|             BOOST_LOG_TRIVIAL(info) << format("[Orca Updater]:Force updating will start, size %1% ", updates.updates.size()); | ||||
|             std::vector<std::string> bundles; | ||||
|             for (const auto& update : updates.updates) { | ||||
|                 if (update.is_directory) | ||||
|                     continue; | ||||
|                 bundles.push_back(update.vendor); | ||||
|             } | ||||
|             bool ret = p->perform_updates(std::move(updates)); | ||||
|             if (!ret) { | ||||
|                 BOOST_LOG_TRIVIAL(warning) << format("[BBL Updater]:perform_updates failed"); | ||||
|                 BOOST_LOG_TRIVIAL(warning) << format("[Orca Updater]:perform_updates failed"); | ||||
|                 return R_INCOMPAT_EXIT; | ||||
|             } | ||||
| 
 | ||||
|             ret = reload_configs_update_gui(); | ||||
|             if (!ret) { | ||||
|                 BOOST_LOG_TRIVIAL(warning) << format("[BBL Updater]:reload_configs_update_gui failed"); | ||||
|                 BOOST_LOG_TRIVIAL(warning) << format("[Orca Updater]:reload_configs_update_gui failed"); | ||||
|                 return R_INCOMPAT_EXIT; | ||||
|             } | ||||
|             Semver cur_ver = GUI::wxGetApp().preset_bundle->get_vendor_profile_version(PresetBundle::BBL_BUNDLE); | ||||
| 
 | ||||
|             GUI::wxGetApp().plater()->get_notification_manager()->push_notification(GUI::NotificationType::PresetUpdateFinished, GUI::NotificationManager::NotificationLevel::ImportantNotificationLevel,  _u8L("Configuration package updated to ")+cur_ver.to_string()); | ||||
| 
 | ||||
|             for(auto b : bundles){ | ||||
|             Semver cur_ver = GUI::wxGetApp().preset_bundle->get_vendor_profile_version(b); | ||||
|             GUI::wxGetApp() | ||||
|                 .plater() | ||||
|                 ->get_notification_manager() | ||||
|                 ->push_notification(GUI::NotificationType::PresetUpdateFinished, | ||||
|                                     GUI::NotificationManager::NotificationLevel::ImportantNotificationLevel, | ||||
|                                     _u8L("Configuration package: ") + b + _u8L(" updated to ") + cur_ver.to_string()); | ||||
|             } | ||||
|             return R_UPDATE_INSTALLED; | ||||
|         } | ||||
| 
 | ||||
|  | @ -1497,11 +1397,10 @@ PresetUpdater::UpdateResult PresetUpdater::config_update(const Semver& old_slic3 | |||
|             GUI::wxGetApp().plater()->get_notification_manager()->push_notification(GUI::NotificationType::PresetUpdateAvailable); | ||||
|         } | ||||
|         else { | ||||
|             BOOST_LOG_TRIVIAL(info) << format("[BBL Updater]:Configuration package available. size %1%, need to confirm...", p->waiting_updates.updates.size()); | ||||
|             BOOST_LOG_TRIVIAL(info) << format("[Orca Updater]:Configuration package available. size %1%, need to confirm...", p->waiting_updates.updates.size()); | ||||
| 
 | ||||
|             std::vector<GUI::MsgUpdateConfig::Update> updates_msg; | ||||
|             for (const auto& update : updates.updates) { | ||||
|                 //BBS: skip directory
 | ||||
|                 if (update.is_directory) | ||||
|                     continue; | ||||
|                 std::string changelog = update.change_log; | ||||
|  | @ -1512,14 +1411,14 @@ PresetUpdater::UpdateResult PresetUpdater::config_update(const Semver& old_slic3 | |||
| 
 | ||||
|             const auto res = dlg.ShowModal(); | ||||
|             if (res == wxID_OK) { | ||||
|                 BOOST_LOG_TRIVIAL(debug) << "[BBL Updater]:selected yes to update"; | ||||
|                 BOOST_LOG_TRIVIAL(debug) << "[Orca Updater]:selected yes to update"; | ||||
|                 if (! p->perform_updates(std::move(updates)) || | ||||
|                     ! reload_configs_update_gui()) | ||||
|                     return R_ALL_CANCELED; | ||||
|                 return R_UPDATE_INSTALLED; | ||||
|             } | ||||
|             else { | ||||
|                 BOOST_LOG_TRIVIAL(info) << "[BBL Updater]:selected no for updating"; | ||||
|                 BOOST_LOG_TRIVIAL(info) << "[Orca Updater]:selected no for updating"; | ||||
|                 if (params == UpdateParams::FORCED_BEFORE_WIZARD && res == wxID_CANCEL) | ||||
|                     return R_ALL_CANCELED; | ||||
|                 return R_UPDATE_REJECT; | ||||
|  | @ -1528,7 +1427,7 @@ PresetUpdater::UpdateResult PresetUpdater::config_update(const Semver& old_slic3 | |||
| 
 | ||||
|         // MsgUpdateConfig will show after the notificaation is clicked
 | ||||
|     } else { | ||||
|         BOOST_LOG_TRIVIAL(info) << "[BBL Updater]:No configuration updates available."; | ||||
|         BOOST_LOG_TRIVIAL(info) << "[Orca Updater]:No configuration updates available."; | ||||
|     } | ||||
| 
 | ||||
| 	return R_NOOP; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 SoftFever
						SoftFever