mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-24 01:01:15 -06:00
PrusaLink - cherrypick pick from stable branch
Added to config enums, visible in Physical Printer Dialog and class derived from Octoprint
This commit is contained in:
parent
f10ec4d21c
commit
b14345012d
8 changed files with 164 additions and 16 deletions
|
|
@ -213,4 +213,48 @@ void SL1Host::set_auth(Http &http) const
|
|||
}
|
||||
}
|
||||
|
||||
// PrusaLink
|
||||
PrusaLink::PrusaLink(DynamicPrintConfig* config) :
|
||||
OctoPrint(config),
|
||||
authorization_type(dynamic_cast<const ConfigOptionEnum<AuthorizationType>*>(config->option("printhost_authorization_type"))->value),
|
||||
username(config->opt_string("printhost_user")),
|
||||
password(config->opt_string("printhost_password"))
|
||||
{
|
||||
}
|
||||
|
||||
const char* PrusaLink::get_name() const { return "PrusaLink"; }
|
||||
|
||||
wxString PrusaLink::get_test_ok_msg() const
|
||||
{
|
||||
return _(L("Connection to PrusaLink works correctly."));
|
||||
}
|
||||
|
||||
wxString PrusaLink::get_test_failed_msg(wxString& msg) const
|
||||
{
|
||||
return GUI::from_u8((boost::format("%s: %s")
|
||||
% _utf8(L("Could not connect to PrusaLink"))
|
||||
% std::string(msg.ToUTF8())).str());
|
||||
}
|
||||
|
||||
bool PrusaLink::validate_version_text(const boost::optional<std::string>& version_text) const
|
||||
{
|
||||
return version_text ? (boost::starts_with(*version_text, "PrusaLink") || boost::starts_with(*version_text, "OctoPrint")) : false;
|
||||
}
|
||||
|
||||
void PrusaLink::set_auth(Http& http) const
|
||||
{
|
||||
switch (authorization_type) {
|
||||
case atKeyPassword:
|
||||
http.header("X-Api-Key", get_apikey());
|
||||
break;
|
||||
case atUserPassword:
|
||||
http.auth_digest(username, password);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!get_cafile().empty()) {
|
||||
http.ca_file(get_cafile());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,6 +70,31 @@ private:
|
|||
std::string password;
|
||||
};
|
||||
|
||||
class PrusaLink : public OctoPrint
|
||||
{
|
||||
public:
|
||||
PrusaLink(DynamicPrintConfig* config);
|
||||
~PrusaLink() override = default;
|
||||
|
||||
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 true; }
|
||||
|
||||
protected:
|
||||
bool validate_version_text(const boost::optional<std::string>& version_text) const override;
|
||||
|
||||
private:
|
||||
void set_auth(Http& http) const override;
|
||||
|
||||
// Host authorization type.
|
||||
AuthorizationType authorization_type;
|
||||
// username and password for HTTP Digest Authentization (RFC RFC2617)
|
||||
std::string username;
|
||||
std::string password;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ PrintHost* PrintHost::get_print_host(DynamicPrintConfig *config)
|
|||
case htFlashAir: return new FlashAir(config);
|
||||
case htAstroBox: return new AstroBox(config);
|
||||
case htRepetier: return new Repetier(config);
|
||||
case htPrusaLink: return new PrusaLink(config);
|
||||
default: return nullptr;
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue