2018-07-08 12:32:48 +00:00
|
|
|
#ifndef slic3r_PrintHost_hpp_
|
|
|
|
#define slic3r_PrintHost_hpp_
|
|
|
|
|
2018-08-21 09:10:32 +00:00
|
|
|
#include <memory>
|
2018-07-08 12:32:48 +00:00
|
|
|
#include <string>
|
2018-12-19 17:43:03 +00:00
|
|
|
#include <functional>
|
2018-12-12 13:15:08 +00:00
|
|
|
#include <boost/filesystem/path.hpp>
|
|
|
|
|
2018-07-08 12:32:48 +00:00
|
|
|
#include <wx/string.h>
|
|
|
|
|
2018-12-14 14:27:34 +00:00
|
|
|
#include "Http.hpp"
|
|
|
|
|
2018-07-08 12:32:48 +00:00
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
|
|
|
|
class DynamicPrintConfig;
|
|
|
|
|
2018-12-11 09:33:11 +00:00
|
|
|
|
|
|
|
struct PrintHostUpload
|
|
|
|
{
|
|
|
|
boost::filesystem::path source_path;
|
|
|
|
boost::filesystem::path upload_path;
|
|
|
|
bool start_print = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-07-08 12:32:48 +00:00
|
|
|
class PrintHost
|
|
|
|
{
|
|
|
|
public:
|
2018-12-11 09:33:11 +00:00
|
|
|
virtual ~PrintHost();
|
|
|
|
|
2018-12-19 17:43:03 +00:00
|
|
|
typedef Http::ProgressFn ProgressFn;
|
|
|
|
typedef std::function<void(wxString /* error */)> ErrorFn;
|
|
|
|
|
2019-03-05 14:15:41 +00:00
|
|
|
virtual const char* get_name() const = 0;
|
|
|
|
|
2018-12-11 09:33:11 +00:00
|
|
|
virtual bool test(wxString &curl_msg) const = 0;
|
|
|
|
virtual wxString get_test_ok_msg () const = 0;
|
|
|
|
virtual wxString get_test_failed_msg (wxString &msg) const = 0;
|
2018-12-19 17:43:03 +00:00
|
|
|
virtual bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const = 0;
|
2018-12-11 09:33:11 +00:00
|
|
|
virtual bool has_auto_discovery() const = 0;
|
|
|
|
virtual bool can_test() const = 0;
|
2019-03-04 15:50:43 +00:00
|
|
|
virtual bool can_start_print() const = 0;
|
2018-12-14 14:27:34 +00:00
|
|
|
virtual std::string get_host() const = 0;
|
2018-12-11 09:33:11 +00:00
|
|
|
|
2019-03-05 14:15:41 +00:00
|
|
|
static PrintHost* get_print_host(DynamicPrintConfig *config);
|
2018-12-20 15:00:51 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual wxString format_error(const std::string &body, const std::string &error, unsigned status) const;
|
2018-12-11 09:33:11 +00:00
|
|
|
};
|
2018-07-08 12:32:48 +00:00
|
|
|
|
2018-08-21 09:10:32 +00:00
|
|
|
|
2018-12-11 09:33:11 +00:00
|
|
|
struct PrintHostJob
|
|
|
|
{
|
|
|
|
PrintHostUpload upload_data;
|
|
|
|
std::unique_ptr<PrintHost> printhost;
|
2018-12-14 14:27:34 +00:00
|
|
|
bool cancelled = false;
|
2018-12-11 09:33:11 +00:00
|
|
|
|
|
|
|
PrintHostJob() {}
|
2018-12-12 12:35:00 +00:00
|
|
|
PrintHostJob(const PrintHostJob&) = delete;
|
|
|
|
PrintHostJob(PrintHostJob &&other)
|
|
|
|
: upload_data(std::move(other.upload_data))
|
|
|
|
, printhost(std::move(other.printhost))
|
2018-12-20 12:36:49 +00:00
|
|
|
, cancelled(other.cancelled)
|
2018-12-12 12:35:00 +00:00
|
|
|
{}
|
|
|
|
|
2018-12-11 09:33:11 +00:00
|
|
|
PrintHostJob(DynamicPrintConfig *config)
|
|
|
|
: printhost(PrintHost::get_print_host(config))
|
|
|
|
{}
|
|
|
|
|
2018-12-12 12:35:00 +00:00
|
|
|
PrintHostJob& operator=(const PrintHostJob&) = delete;
|
|
|
|
PrintHostJob& operator=(PrintHostJob &&other)
|
|
|
|
{
|
|
|
|
upload_data = std::move(other.upload_data);
|
|
|
|
printhost = std::move(other.printhost);
|
2018-12-20 12:36:49 +00:00
|
|
|
cancelled = other.cancelled;
|
2018-12-12 12:35:00 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2018-12-11 09:33:11 +00:00
|
|
|
bool empty() const { return !printhost; }
|
|
|
|
operator bool() const { return !!printhost; }
|
2018-07-08 12:32:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-12-14 14:27:34 +00:00
|
|
|
namespace GUI { class PrintHostQueueDialog; }
|
|
|
|
|
2018-12-11 09:33:11 +00:00
|
|
|
class PrintHostJobQueue
|
|
|
|
{
|
|
|
|
public:
|
2018-12-14 14:27:34 +00:00
|
|
|
PrintHostJobQueue(GUI::PrintHostQueueDialog *queue_dialog);
|
2018-12-11 09:33:11 +00:00
|
|
|
PrintHostJobQueue(const PrintHostJobQueue &) = delete;
|
|
|
|
PrintHostJobQueue(PrintHostJobQueue &&other) = delete;
|
|
|
|
~PrintHostJobQueue();
|
|
|
|
|
|
|
|
PrintHostJobQueue& operator=(const PrintHostJobQueue &) = delete;
|
|
|
|
PrintHostJobQueue& operator=(PrintHostJobQueue &&other) = delete;
|
|
|
|
|
2018-12-14 14:27:34 +00:00
|
|
|
void enqueue(PrintHostJob job);
|
|
|
|
void cancel(size_t id);
|
|
|
|
|
2018-12-11 09:33:11 +00:00
|
|
|
private:
|
|
|
|
struct priv;
|
|
|
|
std::shared_ptr<priv> p;
|
|
|
|
};
|
|
|
|
|
2018-07-08 12:32:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|