From 39af553c2a8b1566a06136caffa3b3385a66c624 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 2 Sep 2022 11:29:58 +0200 Subject: [PATCH 1/2] Repetier validation using 'software' value if present #7807 --- src/slic3r/Utils/Repetier.cpp | 30 +++++++++++++++++++++++------- src/slic3r/Utils/Repetier.hpp | 3 --- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/slic3r/Utils/Repetier.cpp b/src/slic3r/Utils/Repetier.cpp index 57c03c556..f9d03390f 100644 --- a/src/slic3r/Utils/Repetier.cpp +++ b/src/slic3r/Utils/Repetier.cpp @@ -35,6 +35,24 @@ Repetier::Repetier(DynamicPrintConfig *config) : const char* Repetier::get_name() const { return "Repetier"; } + + +static bool validate_repetier(const boost::optional& name, + const boost::optional& soft) +{ + if (soft) { + // See https://github.com/prusa3d/PrusaSlicer/issues/7807: + // Repetier allows "rebranding", so the "name" value is not reliable when detecting + // server type. Newer Repetier versions send "software", which should be invariant. + return ((*soft) == "Repetier-Server"); + } else { + // If there is no "software" value, validate as we did before: + return name ? boost::starts_with(*name, "Repetier") : true; + } +} + + + bool Repetier::test(wxString &msg) const { // Since the request is performed synchronously here, @@ -62,11 +80,12 @@ bool Repetier::test(wxString &msg) const std::stringstream ss(body); pt::ptree ptree; pt::read_json(ss, ptree); - + const auto text = ptree.get_optional("name"); - res = validate_version_text(text); + const auto soft = ptree.get_optional("software"); + res = validate_repetier(text, soft); if (! res) { - msg = GUI::from_u8((boost::format(_utf8(L("Mismatched type of print host: %s"))) % (text ? *text : "Repetier")).str()); + msg = GUI::from_u8((boost::format(_utf8(L("Mismatched type of print host: %s"))) % (soft ? *soft : (text ? *text : "Repetier"))).str()); } } catch (const std::exception &) { @@ -154,10 +173,7 @@ bool Repetier::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Error return res; } -bool Repetier::validate_version_text(const boost::optional &version_text) const -{ - return version_text ? boost::starts_with(*version_text, "Repetier") : true; -} + void Repetier::set_auth(Http &http) const { diff --git a/src/slic3r/Utils/Repetier.hpp b/src/slic3r/Utils/Repetier.hpp index 8646681e9..0c2f7e507 100644 --- a/src/slic3r/Utils/Repetier.hpp +++ b/src/slic3r/Utils/Repetier.hpp @@ -33,9 +33,6 @@ public: bool get_groups(wxArrayString &groups) const override; bool get_printers(wxArrayString &printers) const override; -protected: - virtual bool validate_version_text(const boost::optional &version_text) const; - private: std::string host; std::string apikey; From d4dde50145c281673550c94f3a0bc6df39f8fb2a Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Mon, 5 Sep 2022 14:23:29 +0200 Subject: [PATCH 2/2] Repetier: enforce autostart #7807 --- src/slic3r/Utils/Repetier.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/slic3r/Utils/Repetier.cpp b/src/slic3r/Utils/Repetier.cpp index f9d03390f..17724c350 100644 --- a/src/slic3r/Utils/Repetier.cpp +++ b/src/slic3r/Utils/Repetier.cpp @@ -148,6 +148,7 @@ bool Repetier::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Error if(upload_data.post_action == PrintHostPostUploadAction::StartPrint) { http.form_add("name", upload_filename.string()); + http.form_add("autostart", "true"); // See https://github.com/prusa3d/PrusaSlicer/issues/7807#issuecomment-1235519371 } http.form_add("a", "upload")