1 #ifndef slic3r_PresetUpdate_hpp_
2 #define slic3r_PresetUpdate_hpp_
3 
4 #include <memory>
5 #include <vector>
6 
7 #include <wx/event.h>
8 
9 namespace Slic3r {
10 
11 
12 class AppConfig;
13 class PresetBundle;
14 class Semver;
15 
16 class PresetUpdater
17 {
18 public:
19 	PresetUpdater();
20 	PresetUpdater(PresetUpdater &&) = delete;
21 	PresetUpdater(const PresetUpdater &) = delete;
22 	PresetUpdater &operator=(PresetUpdater &&) = delete;
23 	PresetUpdater &operator=(const PresetUpdater &) = delete;
24 	~PresetUpdater();
25 
26 	// If either version check or config updating is enabled, get the appropriate data in the background and cache it.
27 	void sync(PresetBundle *preset_bundle);
28 
29 	// If version check is enabled, check if chaced online slic3r version is newer, notify if so.
30 	void slic3r_update_notify();
31 
32 	enum UpdateResult {
33 		R_NOOP,
34 		R_INCOMPAT_EXIT,
35 		R_INCOMPAT_CONFIGURED,
36 		R_UPDATE_INSTALLED,
37 		R_UPDATE_REJECT,
38 		R_UPDATE_NOTIFICATION,
39 		R_ALL_CANCELED
40 	};
41 
42 	enum class UpdateParams {
43 		SHOW_TEXT_BOX,				// force modal textbox
44 		SHOW_NOTIFICATION,			// only shows notification
45 		FORCED_BEFORE_WIZARD		// indicates that check of updated is forced before ConfigWizard opening
46 	};
47 
48 	// If updating is enabled, check if updates are available in cache, if so, ask about installation.
49 	// A false return value implies Slic3r should exit due to incompatibility of configuration.
50 	// Providing old slic3r version upgrade profiles on upgrade of an application even in case
51 	// that the config index installed from the Internet is equal to the index contained in the installation package.
52 	UpdateResult config_update(const Semver &old_slic3r_version, UpdateParams params) const;
53 
54 	// "Update" a list of bundles from resources (behaves like an online update).
55 	bool install_bundles_rsrc(std::vector<std::string> bundles, bool snapshot = true) const;
56 
57 	void on_update_notification_confirm();
58 private:
59 	struct priv;
60 	std::unique_ptr<priv> p;
61 };
62 
63 wxDECLARE_EVENT(EVT_SLIC3R_VERSION_ONLINE, wxCommandEvent);
64 
65 
66 }
67 #endif
68