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"))
|
||||
{}
|
||||
|
||||
AstroBox::~AstroBox() {}
|
||||
|
||||
const char* AstroBox::get_name() const { return "AstroBox"; }
|
||||
|
||||
bool AstroBox::test(wxString &msg) const
|
||||
|
@ -142,21 +140,6 @@ bool AstroBox::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Error
|
|||
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
|
||||
{
|
||||
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"
|
||||
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
|
||||
class DynamicPrintConfig;
|
||||
class Http;
|
||||
|
||||
|
@ -18,21 +16,21 @@ class AstroBox : public PrintHost
|
|||
{
|
||||
public:
|
||||
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;
|
||||
virtual wxString get_test_ok_msg () const;
|
||||
virtual wxString get_test_failed_msg (wxString &msg) const;
|
||||
virtual bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const;
|
||||
virtual bool has_auto_discovery() const;
|
||||
virtual bool can_test() const;
|
||||
virtual bool can_start_print() const;
|
||||
virtual std::string get_host() const { return host; }
|
||||
bool test(wxString &curl_msg) const override;
|
||||
wxString get_test_ok_msg () const override;
|
||||
wxString get_test_failed_msg (wxString &msg) const override;
|
||||
bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override;
|
||||
bool has_auto_discovery() const override { return true; }
|
||||
bool can_test() const override { return true; }
|
||||
bool can_start_print() const override { return true; }
|
||||
std::string get_host() const override { return host; }
|
||||
|
||||
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:
|
||||
std::string host;
|
||||
|
@ -43,23 +41,6 @@ private:
|
|||
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
|
||||
|
|
|
@ -32,8 +32,6 @@ Duet::Duet(DynamicPrintConfig *config) :
|
|||
password(config->opt_string("printhost_apikey"))
|
||||
{}
|
||||
|
||||
Duet::~Duet() {}
|
||||
|
||||
const char* Duet::get_name() const { return "Duet"; }
|
||||
|
||||
bool Duet::test(wxString &msg) const
|
||||
|
@ -111,21 +109,6 @@ bool Duet::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn e
|
|||
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 res = false;
|
||||
|
|
|
@ -6,10 +6,8 @@
|
|||
|
||||
#include "PrintHost.hpp"
|
||||
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
|
||||
class DynamicPrintConfig;
|
||||
class Http;
|
||||
|
||||
|
@ -17,18 +15,18 @@ class Duet : public PrintHost
|
|||
{
|
||||
public:
|
||||
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;
|
||||
virtual wxString get_test_ok_msg () const;
|
||||
virtual wxString get_test_failed_msg (wxString &msg) const;
|
||||
virtual bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const;
|
||||
virtual bool has_auto_discovery() const;
|
||||
virtual bool can_test() const;
|
||||
virtual bool can_start_print() const;
|
||||
virtual std::string get_host() const { return host; }
|
||||
bool test(wxString &curl_msg) const override;
|
||||
wxString get_test_ok_msg() const override;
|
||||
wxString get_test_failed_msg(wxString &msg) const override;
|
||||
bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override;
|
||||
bool has_auto_discovery() const override { return false; }
|
||||
bool can_test() const override { return true; }
|
||||
bool can_start_print() const override { return true; }
|
||||
std::string get_host() const override { return host; }
|
||||
|
||||
private:
|
||||
std::string host;
|
||||
|
@ -44,7 +42,6 @@ private:
|
|||
int get_err_code_from_body(const std::string &body) const;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,8 +30,6 @@ FlashAir::FlashAir(DynamicPrintConfig *config) :
|
|||
host(config->opt_string("print_host"))
|
||||
{}
|
||||
|
||||
FlashAir::~FlashAir() {}
|
||||
|
||||
const char* FlashAir::get_name() const { return "FlashAir"; }
|
||||
|
||||
bool FlashAir::test(wxString &msg) const
|
||||
|
@ -150,21 +148,6 @@ bool FlashAir::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Error
|
|||
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
|
||||
{
|
||||
auto t = std::time(nullptr);
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
namespace Slic3r {
|
||||
|
||||
|
||||
class DynamicPrintConfig;
|
||||
class Http;
|
||||
|
||||
|
@ -17,18 +16,18 @@ class FlashAir : public PrintHost
|
|||
{
|
||||
public:
|
||||
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;
|
||||
virtual wxString get_test_ok_msg () const;
|
||||
virtual wxString get_test_failed_msg (wxString &msg) const;
|
||||
virtual bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const;
|
||||
virtual bool has_auto_discovery() const;
|
||||
virtual bool can_test() const;
|
||||
virtual bool can_start_print() const;
|
||||
virtual std::string get_host() const { return host; }
|
||||
bool test(wxString &curl_msg) const override;
|
||||
wxString get_test_ok_msg() const override;
|
||||
wxString get_test_failed_msg(wxString &msg) const override;
|
||||
bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override;
|
||||
bool has_auto_discovery() const override { return false; }
|
||||
bool can_test() const override { return true; }
|
||||
bool can_start_print() const override { return false; }
|
||||
std::string get_host() const override { return host; }
|
||||
|
||||
private:
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -28,8 +28,6 @@ OctoPrint::OctoPrint(DynamicPrintConfig *config) :
|
|||
cafile(config->opt_string("printhost_cafile"))
|
||||
{}
|
||||
|
||||
OctoPrint::~OctoPrint() {}
|
||||
|
||||
const char* OctoPrint::get_name() const { return "OctoPrint"; }
|
||||
|
||||
bool OctoPrint::test(wxString &msg) const
|
||||
|
@ -142,21 +140,6 @@ bool OctoPrint::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Erro
|
|||
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
|
||||
{
|
||||
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() {}
|
||||
|
||||
const char* SL1Host::get_name() const { return "SL1Host"; }
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
namespace Slic3r {
|
||||
|
||||
|
||||
class DynamicPrintConfig;
|
||||
class Http;
|
||||
|
||||
|
@ -18,18 +17,18 @@ class OctoPrint : public PrintHost
|
|||
{
|
||||
public:
|
||||
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;
|
||||
virtual wxString get_test_ok_msg () const;
|
||||
virtual wxString get_test_failed_msg (wxString &msg) const;
|
||||
virtual bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const;
|
||||
virtual bool has_auto_discovery() const;
|
||||
virtual bool can_test() const;
|
||||
virtual bool can_start_print() const;
|
||||
virtual std::string get_host() const { return host; }
|
||||
bool test(wxString &curl_msg) const override;
|
||||
wxString get_test_ok_msg () const override;
|
||||
wxString get_test_failed_msg (wxString &msg) const override;
|
||||
bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override;
|
||||
bool has_auto_discovery() const override { return true; }
|
||||
bool can_test() const override { return true; }
|
||||
bool can_start_print() const override { return true; }
|
||||
std::string get_host() const override { return host; }
|
||||
|
||||
protected:
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
class SL1Host: public OctoPrint
|
||||
{
|
||||
public:
|
||||
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:
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue