From ce1da350d3ecf463fd9436c69b3ba5f52ca857ef Mon Sep 17 00:00:00 2001 From: Pedro Lamas Date: Fri, 26 May 2023 14:59:17 +0100 Subject: [PATCH] Use Moonraker as Klipper API --- src/libslic3r/PrintConfig.cpp | 4 ++-- src/libslic3r/PrintConfig.hpp | 2 +- src/slic3r/CMakeLists.txt | 4 ++-- .../Utils/{Mainsail.cpp => Moonraker.cpp} | 22 +++++++++---------- .../Utils/{Mainsail.hpp => Moonraker.hpp} | 10 ++++----- src/slic3r/Utils/PrintHost.cpp | 4 ++-- 6 files changed, 23 insertions(+), 23 deletions(-) rename src/slic3r/Utils/{Mainsail.cpp => Moonraker.cpp} (94%) rename src/slic3r/Utils/{Mainsail.hpp => Moonraker.hpp} (91%) diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index a8cc410ab..9eda4078c 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -68,7 +68,7 @@ static const t_config_enum_values s_keys_map_PrintHostType { { "prusalink", htPrusaLink }, { "prusaconnect", htPrusaConnect }, { "octoprint", htOctoPrint }, - { "mainsail", htMainSail }, + { "moonraker", htMoonraker }, { "duet", htDuet }, { "flashair", htFlashAir }, { "astrobox", htAstroBox }, @@ -1953,7 +1953,7 @@ void PrintConfigDef::init_fff_params() { "prusalink", "PrusaLink" }, { "prusaconnect", "PrusaConnect" }, { "octoprint", "OctoPrint" }, - { "mainsail", "Mainsail/Fluidd" }, + { "moonraker", "Klipper (via Moonraker)" }, { "duet", "Duet" }, { "flashair", "FlashAir" }, { "astrobox", "AstroBox" }, diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 36a63d33d..54a835fe7 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -44,7 +44,7 @@ enum class MachineLimitsUsage { }; enum PrintHostType { - htPrusaLink, htPrusaConnect, htOctoPrint, htMainSail, htDuet, htFlashAir, htAstroBox, htRepetier, htMKS + htPrusaLink, htPrusaConnect, htOctoPrint, htMoonraker, htDuet, htFlashAir, htAstroBox, htRepetier, htMKS }; enum AuthorizationType { diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index 0227cc266..5d7b2c0ef 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -251,8 +251,8 @@ set(SLIC3R_GUI_SOURCES Utils/Http.hpp Utils/FixModelByWin10.cpp Utils/FixModelByWin10.hpp - Utils/Mainsail.cpp - Utils/Mainsail.hpp + Utils/Moonraker.cpp + Utils/Moonraker.hpp Utils/OctoPrint.cpp Utils/OctoPrint.hpp Utils/Duet.cpp diff --git a/src/slic3r/Utils/Mainsail.cpp b/src/slic3r/Utils/Moonraker.cpp similarity index 94% rename from src/slic3r/Utils/Mainsail.cpp rename to src/slic3r/Utils/Moonraker.cpp index 303d754e3..53aeb08b0 100644 --- a/src/slic3r/Utils/Mainsail.cpp +++ b/src/slic3r/Utils/Moonraker.cpp @@ -1,4 +1,4 @@ -#include "Mainsail.hpp" +#include "Moonraker.hpp" #include #include @@ -63,28 +63,28 @@ std::string substitute_host(const std::string& orig_addr, std::string sub_addr) } #endif } -Mainsail::Mainsail(DynamicPrintConfig *config) : +Moonraker::Moonraker(DynamicPrintConfig *config) : m_host(config->opt_string("print_host")), m_apikey(config->opt_string("printhost_apikey")), m_cafile(config->opt_string("printhost_cafile")), m_ssl_revoke_best_effort(config->opt_bool("printhost_ssl_ignore_revoke")) {} -const char* Mainsail::get_name() const { return "Mainsail"; } +const char* Moonraker::get_name() const { return "Moonraker"; } -wxString Mainsail::get_test_ok_msg () const +wxString Moonraker::get_test_ok_msg () const { - return _(L("Connection to Mainsail works correctly.")); + return _(L("Connection to Moonraker works correctly.")); } -wxString Mainsail::get_test_failed_msg (wxString &msg) const +wxString Moonraker::get_test_failed_msg (wxString &msg) const { return GUI::format_wxstr("%s: %s" - , _L("Could not connect to Mainsail") + , _L("Could not connect to Moonraker") , msg); } -bool Mainsail::test(wxString& msg) const +bool Moonraker::test(wxString& msg) const { // GET /server/info @@ -142,7 +142,7 @@ bool Mainsail::test(wxString& msg) const return res; } -bool Mainsail::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn, InfoFn info_fn) const +bool Moonraker::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn, InfoFn info_fn) const { // POST /server/files/upload @@ -232,7 +232,7 @@ bool Mainsail::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Error return res; } -void Mainsail::set_auth(Http &http) const +void Moonraker::set_auth(Http &http) const { if (!m_apikey.empty()) http.header("X-Api-Key", m_apikey); @@ -240,7 +240,7 @@ void Mainsail::set_auth(Http &http) const http.ca_file(m_cafile); } -std::string Mainsail::make_url(const std::string &path) const +std::string Moonraker::make_url(const std::string &path) const { if (m_host.find("http://") == 0 || m_host.find("https://") == 0) { if (m_host.back() == '/') { diff --git a/src/slic3r/Utils/Mainsail.hpp b/src/slic3r/Utils/Moonraker.hpp similarity index 91% rename from src/slic3r/Utils/Mainsail.hpp rename to src/slic3r/Utils/Moonraker.hpp index 136c7dc57..09a231f49 100644 --- a/src/slic3r/Utils/Mainsail.hpp +++ b/src/slic3r/Utils/Moonraker.hpp @@ -1,5 +1,5 @@ -#ifndef slic3r_Mainsail_hpp_ -#define slic3r_Mainsail_hpp_ +#ifndef slic3r_Moonraker_hpp_ +#define slic3r_Moonraker_hpp_ #include #include @@ -16,11 +16,11 @@ class DynamicPrintConfig; class Http; // https://moonraker.readthedocs.io/en/latest/web_api -class Mainsail : public PrintHost +class Moonraker : public PrintHost { public: - Mainsail(DynamicPrintConfig *config); - ~Mainsail() override = default; + Moonraker(DynamicPrintConfig *config); + ~Moonraker() override = default; const char* get_name() const override; diff --git a/src/slic3r/Utils/PrintHost.cpp b/src/slic3r/Utils/PrintHost.cpp index cddada068..d9152ef21 100644 --- a/src/slic3r/Utils/PrintHost.cpp +++ b/src/slic3r/Utils/PrintHost.cpp @@ -19,7 +19,7 @@ #include "AstroBox.hpp" #include "Repetier.hpp" #include "MKS.hpp" -#include "Mainsail.hpp" +#include "Moonraker.hpp" #include "../GUI/PrintHostDialogs.hpp" namespace fs = boost::filesystem; @@ -55,7 +55,7 @@ PrintHost* PrintHost::get_print_host(DynamicPrintConfig *config) case htPrusaLink: return new PrusaLink(config); case htPrusaConnect: return new PrusaConnect(config); case htMKS: return new MKS(config); - case htMainSail: return new Mainsail(config); + case htMoonraker: return new Moonraker(config); default: return nullptr; } } else {