OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::PresetUpdater Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/Utils/PresetUpdater.hpp>

Collaboration diagram for Slic3r::PresetUpdater:

Classes

struct  priv

Public Types

enum  UpdateResult {
  R_NOOP , R_INCOMPAT_EXIT , R_INCOMPAT_CONFIGURED , R_UPDATE_INSTALLED ,
  R_UPDATE_REJECT , R_UPDATE_NOTIFICATION , R_ALL_CANCELED
}
enum class  UpdateParams { SHOW_TEXT_BOX , SHOW_NOTIFICATION , FORCED_BEFORE_WIZARD }

Public Member Functions

 PresetUpdater ()
 PresetUpdater (PresetUpdater &&)=delete
 PresetUpdater (const PresetUpdater &)=delete
PresetUpdater & operator= (PresetUpdater &&)=delete
PresetUpdater & operator= (const PresetUpdater &)=delete
 ~PresetUpdater ()
void sync (std::string http_url, std::string language, std::string plugin_version, PresetBundle *preset_bundle)
void slic3r_update_notify ()
UpdateResult config_update (const Semver &old_slic3r_version, UpdateParams params) const
bool install_bundles_rsrc (std::vector< std::string > bundles, bool snapshot=true) const
void on_update_notification_confirm ()
void do_printer_config_update ()
void check_vendor_update (const std::string &vendor_id)
void check_new_vendors (const std::set< std::string > &system_vendors, std::function< void(std::vector< std::string > installed_vendors, bool declined)> callback)
bool version_check_enabled () const

Private Attributes

std::unique_ptr< priv > p

Detailed Description

Member Enumeration Documentation

◆ UpdateParams

Enumerator
SHOW_TEXT_BOX 
SHOW_NOTIFICATION 
FORCED_BEFORE_WIZARD 
47 {
48 SHOW_TEXT_BOX, // force modal textbox
49 SHOW_NOTIFICATION, // only shows notification
50 FORCED_BEFORE_WIZARD // indicates that check of updated is forced before ConfigWizard opening
51 };

◆ UpdateResult

Enumerator
R_NOOP 
R_INCOMPAT_EXIT 
R_INCOMPAT_CONFIGURED 
R_UPDATE_INSTALLED 
R_UPDATE_REJECT 
R_UPDATE_NOTIFICATION 
R_ALL_CANCELED 
37 {
38 R_NOOP,
45 };
@ R_NOOP
Definition PresetUpdater.hpp:38
@ R_INCOMPAT_EXIT
Definition PresetUpdater.hpp:39
@ R_UPDATE_REJECT
Definition PresetUpdater.hpp:42
@ R_INCOMPAT_CONFIGURED
Definition PresetUpdater.hpp:40
@ R_UPDATE_NOTIFICATION
Definition PresetUpdater.hpp:43
@ R_ALL_CANCELED
Definition PresetUpdater.hpp:44
@ R_UPDATE_INSTALLED
Definition PresetUpdater.hpp:41

Constructor & Destructor Documentation

◆ PresetUpdater() [1/3]

Slic3r::PresetUpdater::PresetUpdater ( )
1328 :
1329 p(new priv())
1330{}
std::unique_ptr< priv > p
Definition PresetUpdater.hpp:76
Definition PresetUpdater.cpp:218

References p.

Referenced by PresetUpdater(), PresetUpdater(), operator=(), and operator=().

Here is the caller graph for this function:

◆ PresetUpdater() [2/3]

Slic3r::PresetUpdater::PresetUpdater ( PresetUpdater && )
delete

References PresetUpdater().

Here is the call graph for this function:

◆ PresetUpdater() [3/3]

Slic3r::PresetUpdater::PresetUpdater ( const PresetUpdater & )
delete

References PresetUpdater().

Here is the call graph for this function:

◆ ~PresetUpdater()

Slic3r::PresetUpdater::~PresetUpdater ( )
1336{
1337 if (p && p->thread.joinable()) {
1338 // This will stop transfers being done by the thread, if any.
1339 // Cancelling takes some time, but should complete soon enough.
1340 p->cancel = true;
1341 p->thread.join();
1342 }
1343 if (p) {
1344 p->vendor_check_cancel = true;
1345 for (auto& t : p->vendor_check_threads)
1346 if (t.joinable())
1347 t.join();
1348 }
1349}

References p.

Member Function Documentation

◆ check_new_vendors()

void Slic3r::PresetUpdater::check_new_vendors ( const std::set< std::string > & system_vendors,
std::function< void(std::vector< std::string > installed_vendors, bool declined)> callback )
1698{
1699 p->check_new_vendors(system_vendors, std::move(callback));
1700}

References p.

◆ check_vendor_update()

void Slic3r::PresetUpdater::check_vendor_update ( const std::string & vendor_id)
1383{
1384 if (!p->enabled_config_update) return;
1385 if (vendor_id.empty()) return;
1386
1387 if (!p->checked_vendors.insert(vendor_id).second)
1388 return;
1389
1390 p->vendor_check_threads.emplace_back([this, vendor_id]() {
1391 try {
1392 this->p->prune_tmp(vendor_id);
1393 this->p->sync_vendor_config(vendor_id);
1394 } catch (const std::exception& e) {
1395 BOOST_LOG_TRIVIAL(error) << "[Orca Updater] vendor update failed for " << vendor_id << ": " << e.what();
1396 } catch (...) {
1397 BOOST_LOG_TRIVIAL(error) << "[Orca Updater] vendor update failed for " << vendor_id << " with an unknown exception";
1398 }
1399 });
1400}

References p.

◆ config_update()

PresetUpdater::UpdateResult Slic3r::PresetUpdater::config_update ( const Semver & old_slic3r_version,
UpdateParams params ) const
1727{
1728 if (! p->enabled_config_update) { return R_NOOP; }
1729
1730 auto updates = p->get_config_updates(old_slic3r_version);
1731
1732 if (updates.updates.size() > 0) {
1733
1734 bool force_update = false;
1735 for (const auto& update : updates.updates) {
1736 force_update = (update.forced_update ? true : force_update);
1737 }
1738
1739 //forced update
1740 if (force_update)
1741 {
1742 BOOST_LOG_TRIVIAL(info) << format("[Orca Updater]:Force updating will start, size %1% ", updates.updates.size());
1743 std::vector<std::string> bundles;
1744 for (const auto& update : updates.updates) {
1745 if (update.is_directory)
1746 continue;
1747 bundles.push_back(update.vendor);
1748 }
1749 bool ret = p->perform_updates(std::move(updates));
1750 if (!ret) {
1751 BOOST_LOG_TRIVIAL(warning) << format("[Orca Updater]:perform_updates failed");
1752 return R_INCOMPAT_EXIT;
1753 }
1754
1756 if (!ret) {
1757 BOOST_LOG_TRIVIAL(warning) << format("[Orca Updater]:reload_configs_update_gui failed");
1758 return R_INCOMPAT_EXIT;
1759 }
1760 for(auto b : bundles){
1761 Semver cur_ver = GUI::wxGetApp().preset_bundle->get_vendor_profile_version(b);
1762 GUI::wxGetApp()
1763 .plater()
1764 ->get_notification_manager()
1767 Slic3r::format(_u8L("Configuration package: %1% updated to %2%"), b, cur_ver.to_string()));
1768 }
1769 return R_UPDATE_INSTALLED;
1770 }
1771
1772 // regular update
1773 if (params == UpdateParams::SHOW_NOTIFICATION) {
1774 p->set_waiting_updates(updates);
1775 GUI::wxGetApp().plater()->get_notification_manager()->push_notification(GUI::NotificationType::PresetUpdateAvailable);
1776 }
1777 else {
1778 BOOST_LOG_TRIVIAL(info) << format("[Orca Updater]:Configuration package available. size %1%, need to confirm...", p->waiting_updates.updates.size());
1779
1780 std::vector<GUI::MsgUpdateConfig::Update> updates_msg;
1781 for (const auto& update : updates.updates) {
1782 if (update.is_directory)
1783 continue;
1784 std::string changelog = update.change_log;
1785 updates_msg.emplace_back(update.vendor, update.version.config_version, update.descriptions, std::move(changelog));
1786 }
1787
1788 GUI::MsgUpdateConfig dlg(updates_msg, params == UpdateParams::FORCED_BEFORE_WIZARD);
1789
1790 const auto res = dlg.ShowModal();
1791 if (res == wxID_OK) {
1792 BOOST_LOG_TRIVIAL(debug) << "[Orca Updater]:selected yes to update";
1793 if (! p->perform_updates(std::move(updates)) ||
1795 return R_ALL_CANCELED;
1796 return R_UPDATE_INSTALLED;
1797 }
1798 else {
1799 BOOST_LOG_TRIVIAL(info) << "[Orca Updater]:selected no for updating";
1800 if (params == UpdateParams::FORCED_BEFORE_WIZARD && res == wxID_CANCEL)
1801 return R_ALL_CANCELED;
1802 return R_UPDATE_REJECT;
1803 }
1804 }
1805
1806 // MsgUpdateConfig will show after the notificaation is clicked
1807 } else {
1808 BOOST_LOG_TRIVIAL(info) << "[Orca Updater]:No configuration updates available.";
1809 }
1810
1811 return R_NOOP;
1812}
@ ImportantNotificationLevel
Definition NotificationManager.hpp:222
@ FORCED_BEFORE_WIZARD
Definition PresetUpdater.hpp:50
@ SHOW_NOTIFICATION
Definition PresetUpdater.hpp:49
@ PresetUpdateAvailable
Definition NotificationManager.hpp:87
@ PresetUpdateFinished
Definition NotificationManager.hpp:88
static bool reload_configs_update_gui()
Definition PresetUpdater.cpp:1708
std::string format(const char *fmt, TArgs &&... args)
Definition format.hpp:45
#define _u8L(s)
Definition I18N.hpp:11

References _u8L, FORCED_BEFORE_WIZARD, Slic3r::format(), Slic3r::GUI::NotificationManager::ImportantNotificationLevel, p, Slic3r::GUI::PresetUpdateAvailable, Slic3r::GUI::PresetUpdateFinished, R_ALL_CANCELED, R_INCOMPAT_EXIT, R_NOOP, R_UPDATE_INSTALLED, R_UPDATE_REJECT, Slic3r::reload_configs_update_gui(), SHOW_NOTIFICATION, Slic3r::GUI::DPIAware< P >::ShowModal(), and Slic3r::Semver::to_string().

Here is the call graph for this function:

◆ do_printer_config_update()

void Slic3r::PresetUpdater::do_printer_config_update ( )
1851{
1852 if (!p->has_waiting_printer_updates)
1853 return;
1854 BOOST_LOG_TRIVIAL(info) << "Update of printer configs available. Asking for confirmation ...";
1855
1856 std::vector<GUI::MsgUpdateConfig::Update> updates_msg;
1857 for (const auto &update : p->waiting_printer_updates.updates) {
1858 std::string changelog = update.change_log;
1859 updates_msg.emplace_back(update.vendor, update.version.config_version, update.descriptions, std::move(changelog));
1860 }
1861
1862 GUI::MsgUpdateConfig dlg(updates_msg);
1863
1864 const auto res = dlg.ShowModal();
1865 if (res == wxID_OK) {
1866 BOOST_LOG_TRIVIAL(debug) << "User agreed to perform the update";
1867 if (p->perform_updates(std::move(p->waiting_printer_updates)))
1868 p->has_waiting_printer_updates = false;
1869 } else {
1870 BOOST_LOG_TRIVIAL(info) << "User refused the update";
1871 }
1872}

References p, and Slic3r::GUI::DPIAware< P >::ShowModal().

Here is the call graph for this function:

◆ install_bundles_rsrc()

bool Slic3r::PresetUpdater::install_bundles_rsrc ( std::vector< std::string > bundles,
bool snapshot = true ) const
1816{
1817 return p->install_bundles_rsrc(bundles, snapshot);
1818}

References p.

Referenced by Slic3r::GUI::ConfigWizard::priv::apply_config(), and Slic3r::PresetUpdater::priv::check_installed_vendor_profiles().

Here is the caller graph for this function:

◆ on_update_notification_confirm()

void Slic3r::PresetUpdater::on_update_notification_confirm ( )
1821{
1822 if (!p->has_waiting_updates)
1823 return;
1824 BOOST_LOG_TRIVIAL(info) << format("Update of %1% bundles available. Asking for confirmation ...", p->waiting_updates.updates.size());
1825
1826 std::vector<GUI::MsgUpdateConfig::Update> updates_msg;
1827 for (const auto& update : p->waiting_updates.updates) {
1828 //BBS: skip directory
1829 if (update.is_directory)
1830 continue;
1831 std::string changelog = update.change_log;
1832 updates_msg.emplace_back(update.vendor, update.version.config_version, update.descriptions, std::move(changelog));
1833 }
1834
1835 GUI::MsgUpdateConfig dlg(updates_msg);
1836
1837 const auto res = dlg.ShowModal();
1838 if (res == wxID_OK) {
1839 BOOST_LOG_TRIVIAL(debug) << "User agreed to perform the update";
1840 if (p->perform_updates(std::move(p->waiting_updates)) &&
1842 p->has_waiting_updates = false;
1843 }
1844 }
1845 else {
1846 BOOST_LOG_TRIVIAL(info) << "User refused the update";
1847 }
1848}

References Slic3r::format(), p, Slic3r::reload_configs_update_gui(), and Slic3r::GUI::DPIAware< P >::ShowModal().

Here is the call graph for this function:

◆ operator=() [1/2]

PresetUpdater & Slic3r::PresetUpdater::operator= ( const PresetUpdater & )
delete

References PresetUpdater().

Here is the call graph for this function:

◆ operator=() [2/2]

PresetUpdater & Slic3r::PresetUpdater::operator= ( PresetUpdater && )
delete

References PresetUpdater().

Here is the call graph for this function:

◆ slic3r_update_notify()

void Slic3r::PresetUpdater::slic3r_update_notify ( )
1703{
1704 if (! p->enabled_version_check)
1705 return;
1706}

References p.

◆ sync()

void Slic3r::PresetUpdater::sync ( std::string http_url,
std::string language,
std::string plugin_version,
PresetBundle * preset_bundle )
1354{
1355 //p->set_download_prefs(GUI::wxGetApp().app_config);
1356 if (!p->enabled_version_check && !p->enabled_config_update) { return; }
1357
1358 p->thread = std::thread([this, http_url, language, plugin_version]() {
1359 try {
1360 this->p->sync_version();
1361 if (p->cancel)
1362 return;
1363 // Vendor profile updates are triggered by check_vendor_update()
1364 // after the startup printer preset has been restored.
1365 this->p->sync_plugins(http_url, plugin_version);
1366 this->p->sync_printer_config(http_url);
1367 // Orca (PR #130): the filament library is always installed, so refresh it
1368 // from the updater on every startup sync rather than deferring to check_vendor_update().
1369 this->p->sync_vendor_config(PresetBundle::ORCA_FILAMENT_LIBRARY);
1370 //if (p->cancel)
1371 // return;
1372 //remove the tooltip currently
1373 //this->p->sync_tooltip(http_url, language);
1374 } catch (const std::exception &e) {
1375 BOOST_LOG_TRIVIAL(error) << "[Orca Updater] background sync failed: " << e.what();
1376 } catch (...) {
1377 BOOST_LOG_TRIVIAL(error) << "[Orca Updater] background sync failed with an unknown exception";
1378 }
1379 });
1380}
static const char * ORCA_FILAMENT_LIBRARY
Definition PresetBundle.hpp:690

References Slic3r::PresetBundle::ORCA_FILAMENT_LIBRARY, and p.

◆ version_check_enabled()

bool Slic3r::PresetUpdater::version_check_enabled ( ) const
1875{
1876 return p->enabled_version_check;
1877}

References p.

Member Data Documentation

◆ p


The documentation for this class was generated from the following files: