mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Clean-up of the "Upload to" code (AstroBox, Duet, FlashAir, OctoPrint)
This commit is contained in:
parent
b08a315a46
commit
791f487c76
8 changed files with 48 additions and 179 deletions
|
@ -28,8 +28,6 @@ AstroBox::AstroBox(DynamicPrintConfig *config) :
|
||||||
cafile(config->opt_string("printhost_cafile"))
|
cafile(config->opt_string("printhost_cafile"))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
AstroBox::~AstroBox() {}
|
|
||||||
|
|
||||||
const char* AstroBox::get_name() const { return "AstroBox"; }
|
const char* AstroBox::get_name() const { return "AstroBox"; }
|
||||||
|
|
||||||
bool AstroBox::test(wxString &msg) const
|
bool AstroBox::test(wxString &msg) const
|
||||||
|
@ -142,21 +140,6 @@ bool AstroBox::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Error
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AstroBox::has_auto_discovery() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AstroBox::can_test() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AstroBox::can_start_print() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AstroBox::validate_version_text(const boost::optional<std::string> &version_text) const
|
bool AstroBox::validate_version_text(const boost::optional<std::string> &version_text) const
|
||||||
{
|
{
|
||||||
return version_text ? boost::starts_with(*version_text, "AstroBox") : true;
|
return version_text ? boost::starts_with(*version_text, "AstroBox") : true;
|
||||||
|
@ -184,32 +167,4 @@ std::string AstroBox::make_url(const std::string &path) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// SL1Host
|
|
||||||
|
|
||||||
SL1Host::~SL1Host() {}
|
|
||||||
|
|
||||||
const char* SL1Host::get_name() const { return "SL1Host"; }
|
|
||||||
|
|
||||||
wxString SL1Host::get_test_ok_msg () const
|
|
||||||
{
|
|
||||||
return _(L("Connection to Prusa SL1 works correctly."));
|
|
||||||
}
|
|
||||||
|
|
||||||
wxString SL1Host::get_test_failed_msg (wxString &msg) const
|
|
||||||
{
|
|
||||||
return wxString::Format("%s: %s", _(L("Could not connect to Prusa SLA")), msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SL1Host::can_start_print() const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SL1Host::validate_version_text(const boost::optional<std::string> &version_text) const
|
|
||||||
{
|
|
||||||
return version_text ? boost::starts_with(*version_text, "Prusa SLA") : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,10 +7,8 @@
|
||||||
|
|
||||||
#include "PrintHost.hpp"
|
#include "PrintHost.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
|
|
||||||
class DynamicPrintConfig;
|
class DynamicPrintConfig;
|
||||||
class Http;
|
class Http;
|
||||||
|
|
||||||
|
@ -18,21 +16,21 @@ class AstroBox : public PrintHost
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AstroBox(DynamicPrintConfig *config);
|
AstroBox(DynamicPrintConfig *config);
|
||||||
virtual ~AstroBox();
|
~AstroBox() override = default;
|
||||||
|
|
||||||
virtual const char* get_name() const;
|
const char* get_name() const override;
|
||||||
|
|
||||||
virtual bool test(wxString &curl_msg) const;
|
bool test(wxString &curl_msg) const override;
|
||||||
virtual wxString get_test_ok_msg () const;
|
wxString get_test_ok_msg () const override;
|
||||||
virtual wxString get_test_failed_msg (wxString &msg) const;
|
wxString get_test_failed_msg (wxString &msg) const override;
|
||||||
virtual bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const;
|
bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override;
|
||||||
virtual bool has_auto_discovery() const;
|
bool has_auto_discovery() const override { return true; }
|
||||||
virtual bool can_test() const;
|
bool can_test() const override { return true; }
|
||||||
virtual bool can_start_print() const;
|
bool can_start_print() const override { return true; }
|
||||||
virtual std::string get_host() const { return host; }
|
std::string get_host() const override { return host; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool validate_version_text(const boost::optional<std::string> &version_text) const;
|
bool validate_version_text(const boost::optional<std::string> &version_text) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string host;
|
std::string host;
|
||||||
|
@ -43,23 +41,6 @@ private:
|
||||||
std::string make_url(const std::string &path) const;
|
std::string make_url(const std::string &path) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class SL1Host: public AstroBox
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SL1Host(DynamicPrintConfig *config) : AstroBox(config) {}
|
|
||||||
virtual ~SL1Host();
|
|
||||||
|
|
||||||
virtual const char* get_name() const;
|
|
||||||
|
|
||||||
virtual wxString get_test_ok_msg () const;
|
|
||||||
virtual wxString get_test_failed_msg (wxString &msg) const;
|
|
||||||
virtual bool can_start_print() const ;
|
|
||||||
protected:
|
|
||||||
virtual bool validate_version_text(const boost::optional<std::string> &version_text) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -32,8 +32,6 @@ Duet::Duet(DynamicPrintConfig *config) :
|
||||||
password(config->opt_string("printhost_apikey"))
|
password(config->opt_string("printhost_apikey"))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Duet::~Duet() {}
|
|
||||||
|
|
||||||
const char* Duet::get_name() const { return "Duet"; }
|
const char* Duet::get_name() const { return "Duet"; }
|
||||||
|
|
||||||
bool Duet::test(wxString &msg) const
|
bool Duet::test(wxString &msg) const
|
||||||
|
@ -111,21 +109,6 @@ bool Duet::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn e
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Duet::has_auto_discovery() const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Duet::can_test() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Duet::can_start_print() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Duet::connect(wxString &msg) const
|
bool Duet::connect(wxString &msg) const
|
||||||
{
|
{
|
||||||
bool res = false;
|
bool res = false;
|
||||||
|
|
|
@ -6,10 +6,8 @@
|
||||||
|
|
||||||
#include "PrintHost.hpp"
|
#include "PrintHost.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
|
|
||||||
class DynamicPrintConfig;
|
class DynamicPrintConfig;
|
||||||
class Http;
|
class Http;
|
||||||
|
|
||||||
|
@ -17,18 +15,18 @@ class Duet : public PrintHost
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Duet(DynamicPrintConfig *config);
|
Duet(DynamicPrintConfig *config);
|
||||||
virtual ~Duet();
|
~Duet() override = default;
|
||||||
|
|
||||||
virtual const char* get_name() const;
|
const char* get_name() const override;
|
||||||
|
|
||||||
virtual bool test(wxString &curl_msg) const;
|
bool test(wxString &curl_msg) const override;
|
||||||
virtual wxString get_test_ok_msg () const;
|
wxString get_test_ok_msg() const override;
|
||||||
virtual wxString get_test_failed_msg (wxString &msg) const;
|
wxString get_test_failed_msg(wxString &msg) const override;
|
||||||
virtual bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const;
|
bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override;
|
||||||
virtual bool has_auto_discovery() const;
|
bool has_auto_discovery() const override { return false; }
|
||||||
virtual bool can_test() const;
|
bool can_test() const override { return true; }
|
||||||
virtual bool can_start_print() const;
|
bool can_start_print() const override { return true; }
|
||||||
virtual std::string get_host() const { return host; }
|
std::string get_host() const override { return host; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string host;
|
std::string host;
|
||||||
|
@ -44,7 +42,6 @@ private:
|
||||||
int get_err_code_from_body(const std::string &body) const;
|
int get_err_code_from_body(const std::string &body) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,8 +30,6 @@ FlashAir::FlashAir(DynamicPrintConfig *config) :
|
||||||
host(config->opt_string("print_host"))
|
host(config->opt_string("print_host"))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
FlashAir::~FlashAir() {}
|
|
||||||
|
|
||||||
const char* FlashAir::get_name() const { return "FlashAir"; }
|
const char* FlashAir::get_name() const { return "FlashAir"; }
|
||||||
|
|
||||||
bool FlashAir::test(wxString &msg) const
|
bool FlashAir::test(wxString &msg) const
|
||||||
|
@ -150,21 +148,6 @@ bool FlashAir::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Error
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FlashAir::has_auto_discovery() const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FlashAir::can_test() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FlashAir::can_start_print() const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string FlashAir::timestamp_str() const
|
std::string FlashAir::timestamp_str() const
|
||||||
{
|
{
|
||||||
auto t = std::time(nullptr);
|
auto t = std::time(nullptr);
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
|
|
||||||
class DynamicPrintConfig;
|
class DynamicPrintConfig;
|
||||||
class Http;
|
class Http;
|
||||||
|
|
||||||
|
@ -17,18 +16,18 @@ class FlashAir : public PrintHost
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FlashAir(DynamicPrintConfig *config);
|
FlashAir(DynamicPrintConfig *config);
|
||||||
virtual ~FlashAir();
|
~FlashAir() override = default;
|
||||||
|
|
||||||
virtual const char* get_name() const;
|
const char* get_name() const override;
|
||||||
|
|
||||||
virtual bool test(wxString &curl_msg) const;
|
bool test(wxString &curl_msg) const override;
|
||||||
virtual wxString get_test_ok_msg () const;
|
wxString get_test_ok_msg() const override;
|
||||||
virtual wxString get_test_failed_msg (wxString &msg) const;
|
wxString get_test_failed_msg(wxString &msg) const override;
|
||||||
virtual bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const;
|
bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override;
|
||||||
virtual bool has_auto_discovery() const;
|
bool has_auto_discovery() const override { return false; }
|
||||||
virtual bool can_test() const;
|
bool can_test() const override { return true; }
|
||||||
virtual bool can_start_print() const;
|
bool can_start_print() const override { return false; }
|
||||||
virtual std::string get_host() const { return host; }
|
std::string get_host() const override { return host; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string host;
|
std::string host;
|
||||||
|
@ -38,7 +37,6 @@ private:
|
||||||
std::string make_url(const std::string &path, const std::string &arg, const std::string &val) const;
|
std::string make_url(const std::string &path, const std::string &arg, const std::string &val) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -28,8 +28,6 @@ OctoPrint::OctoPrint(DynamicPrintConfig *config) :
|
||||||
cafile(config->opt_string("printhost_cafile"))
|
cafile(config->opt_string("printhost_cafile"))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
OctoPrint::~OctoPrint() {}
|
|
||||||
|
|
||||||
const char* OctoPrint::get_name() const { return "OctoPrint"; }
|
const char* OctoPrint::get_name() const { return "OctoPrint"; }
|
||||||
|
|
||||||
bool OctoPrint::test(wxString &msg) const
|
bool OctoPrint::test(wxString &msg) const
|
||||||
|
@ -142,21 +140,6 @@ bool OctoPrint::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Erro
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OctoPrint::has_auto_discovery() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OctoPrint::can_test() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OctoPrint::can_start_print() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OctoPrint::validate_version_text(const boost::optional<std::string> &version_text) const
|
bool OctoPrint::validate_version_text(const boost::optional<std::string> &version_text) const
|
||||||
{
|
{
|
||||||
return version_text ? boost::starts_with(*version_text, "OctoPrint") : true;
|
return version_text ? boost::starts_with(*version_text, "OctoPrint") : true;
|
||||||
|
@ -186,9 +169,6 @@ std::string OctoPrint::make_url(const std::string &path) const
|
||||||
|
|
||||||
|
|
||||||
// SL1Host
|
// SL1Host
|
||||||
|
|
||||||
SL1Host::~SL1Host() {}
|
|
||||||
|
|
||||||
const char* SL1Host::get_name() const { return "SL1Host"; }
|
const char* SL1Host::get_name() const { return "SL1Host"; }
|
||||||
|
|
||||||
wxString SL1Host::get_test_ok_msg () const
|
wxString SL1Host::get_test_ok_msg () const
|
||||||
|
@ -201,15 +181,9 @@ wxString SL1Host::get_test_failed_msg (wxString &msg) const
|
||||||
return wxString::Format("%s: %s", _(L("Could not connect to Prusa SLA")), msg);
|
return wxString::Format("%s: %s", _(L("Could not connect to Prusa SLA")), msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SL1Host::can_start_print() const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SL1Host::validate_version_text(const boost::optional<std::string> &version_text) const
|
bool SL1Host::validate_version_text(const boost::optional<std::string> &version_text) const
|
||||||
{
|
{
|
||||||
return version_text ? boost::starts_with(*version_text, "Prusa SLA") : false;
|
return version_text ? boost::starts_with(*version_text, "Prusa SLA") : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
|
|
||||||
class DynamicPrintConfig;
|
class DynamicPrintConfig;
|
||||||
class Http;
|
class Http;
|
||||||
|
|
||||||
|
@ -18,18 +17,18 @@ class OctoPrint : public PrintHost
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OctoPrint(DynamicPrintConfig *config);
|
OctoPrint(DynamicPrintConfig *config);
|
||||||
virtual ~OctoPrint();
|
~OctoPrint() override = default;
|
||||||
|
|
||||||
virtual const char* get_name() const;
|
const char* get_name() const;
|
||||||
|
|
||||||
virtual bool test(wxString &curl_msg) const;
|
bool test(wxString &curl_msg) const override;
|
||||||
virtual wxString get_test_ok_msg () const;
|
wxString get_test_ok_msg () const override;
|
||||||
virtual wxString get_test_failed_msg (wxString &msg) const;
|
wxString get_test_failed_msg (wxString &msg) const override;
|
||||||
virtual bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const;
|
bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override;
|
||||||
virtual bool has_auto_discovery() const;
|
bool has_auto_discovery() const override { return true; }
|
||||||
virtual bool can_test() const;
|
bool can_test() const override { return true; }
|
||||||
virtual bool can_start_print() const;
|
bool can_start_print() const override { return true; }
|
||||||
virtual std::string get_host() const { return host; }
|
std::string get_host() const override { return host; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool validate_version_text(const boost::optional<std::string> &version_text) const;
|
virtual bool validate_version_text(const boost::optional<std::string> &version_text) const;
|
||||||
|
@ -43,23 +42,22 @@ private:
|
||||||
std::string make_url(const std::string &path) const;
|
std::string make_url(const std::string &path) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class SL1Host: public OctoPrint
|
class SL1Host: public OctoPrint
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SL1Host(DynamicPrintConfig *config) : OctoPrint(config) {}
|
SL1Host(DynamicPrintConfig *config) : OctoPrint(config) {}
|
||||||
virtual ~SL1Host();
|
~SL1Host() override = default;
|
||||||
|
|
||||||
virtual const char* get_name() const;
|
const char* get_name() const override;
|
||||||
|
|
||||||
|
wxString get_test_ok_msg() const override;
|
||||||
|
wxString get_test_failed_msg(wxString &msg) const override;
|
||||||
|
bool can_start_print() const override { return false; }
|
||||||
|
|
||||||
virtual wxString get_test_ok_msg () const;
|
|
||||||
virtual wxString get_test_failed_msg (wxString &msg) const;
|
|
||||||
virtual bool can_start_print() const ;
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool validate_version_text(const boost::optional<std::string> &version_text) const;
|
bool validate_version_text(const boost::optional<std::string> &version_text) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue