mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 06:26:06 +08:00
Repetier validation using 'software' value if present #7807
This commit is contained in:
parent
4e315bcf27
commit
39af553c2a
@ -35,6 +35,24 @@ Repetier::Repetier(DynamicPrintConfig *config) :
|
|||||||
|
|
||||||
const char* Repetier::get_name() const { return "Repetier"; }
|
const char* Repetier::get_name() const { return "Repetier"; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static bool validate_repetier(const boost::optional<std::string>& name,
|
||||||
|
const boost::optional<std::string>& 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
|
bool Repetier::test(wxString &msg) const
|
||||||
{
|
{
|
||||||
// Since the request is performed synchronously here,
|
// Since the request is performed synchronously here,
|
||||||
@ -64,9 +82,10 @@ bool Repetier::test(wxString &msg) const
|
|||||||
pt::read_json(ss, ptree);
|
pt::read_json(ss, ptree);
|
||||||
|
|
||||||
const auto text = ptree.get_optional<std::string>("name");
|
const auto text = ptree.get_optional<std::string>("name");
|
||||||
res = validate_version_text(text);
|
const auto soft = ptree.get_optional<std::string>("software");
|
||||||
|
res = validate_repetier(text, soft);
|
||||||
if (! res) {
|
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 &) {
|
catch (const std::exception &) {
|
||||||
@ -154,10 +173,7 @@ bool Repetier::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Error
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Repetier::validate_version_text(const boost::optional<std::string> &version_text) const
|
|
||||||
{
|
|
||||||
return version_text ? boost::starts_with(*version_text, "Repetier") : true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Repetier::set_auth(Http &http) const
|
void Repetier::set_auth(Http &http) const
|
||||||
{
|
{
|
||||||
|
@ -33,9 +33,6 @@ public:
|
|||||||
bool get_groups(wxArrayString &groups) const override;
|
bool get_groups(wxArrayString &groups) const override;
|
||||||
bool get_printers(wxArrayString &printers) const override;
|
bool get_printers(wxArrayString &printers) const override;
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual bool validate_version_text(const boost::optional<std::string> &version_text) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string host;
|
std::string host;
|
||||||
std::string apikey;
|
std::string apikey;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user