mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-16 13:32:44 +00:00
fix: move non-mandatory printer agent function stubs to IPrinterAgent
This commit is contained in:
@@ -150,12 +150,16 @@ public:
|
||||
/**
|
||||
* Validate current user certificates for the printer.
|
||||
*/
|
||||
virtual int check_cert() = 0;
|
||||
virtual int check_cert() { return BAMBU_NETWORK_SUCCESS; }
|
||||
|
||||
/**
|
||||
* Install or refresh device certificate for LAN TLS.
|
||||
*/
|
||||
virtual void install_device_cert(std::string dev_id, bool lan_only) = 0;
|
||||
virtual void install_device_cert(std::string dev_id, bool lan_only)
|
||||
{
|
||||
(void) dev_id;
|
||||
(void) lan_only;
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// Discovery
|
||||
@@ -171,7 +175,11 @@ public:
|
||||
/**
|
||||
* Ping the binding endpoint to check printer readiness.
|
||||
*/
|
||||
virtual int ping_bind(std::string ping_code) = 0;
|
||||
virtual int ping_bind(std::string ping_code)
|
||||
{
|
||||
(void) ping_code;
|
||||
return BAMBU_NETWORK_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform binding detection/handshake on a LAN printer.
|
||||
@@ -181,23 +189,50 @@ public:
|
||||
/**
|
||||
* Execute the multi-stage printer binding workflow.
|
||||
*/
|
||||
virtual int bind(std::string dev_ip, std::string dev_id, std::string dev_model, std::string sec_link, std::string timezone, bool improved, OnUpdateStatusFn update_fn) = 0;
|
||||
virtual int bind(std::string dev_ip, std::string dev_id, std::string dev_model, std::string sec_link,
|
||||
std::string timezone, bool improved, OnUpdateStatusFn update_fn)
|
||||
{
|
||||
(void) dev_ip;
|
||||
(void) dev_id;
|
||||
(void) dev_model;
|
||||
(void) sec_link;
|
||||
(void) timezone;
|
||||
(void) improved;
|
||||
(void) update_fn;
|
||||
return BAMBU_NETWORK_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the association between account and printer.
|
||||
*/
|
||||
virtual int unbind(std::string dev_id) = 0;
|
||||
virtual int unbind(std::string dev_id)
|
||||
{
|
||||
(void) dev_id;
|
||||
return BAMBU_NETWORK_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request a one-time bind ticket from the server.
|
||||
*/
|
||||
virtual int request_bind_ticket(std::string* ticket) = 0;
|
||||
virtual int request_bind_ticket(std::string* ticket)
|
||||
{
|
||||
if (ticket)
|
||||
*ticket = {};
|
||||
return BAMBU_NETWORK_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the cloud snapshot image captured at a print failure.
|
||||
* Returns 0 if the request was dispatched; the image body arrives via callback(body, http_status).
|
||||
*/
|
||||
virtual int get_hms_snapshot(std::string dev_id, std::string file_name, std::function<void(std::string, int)> callback) = 0;
|
||||
virtual int get_hms_snapshot(std::string dev_id, std::string file_name,
|
||||
std::function<void(std::string, int)> callback)
|
||||
{
|
||||
(void) dev_id;
|
||||
(void) file_name;
|
||||
(void) callback;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register callback for fatal HTTP errors.
|
||||
|
||||
@@ -191,14 +191,6 @@ int MoonrakerPrinterAgent::disconnect_printer()
|
||||
return BAMBU_NETWORK_SUCCESS;
|
||||
}
|
||||
|
||||
int MoonrakerPrinterAgent::check_cert() { return BAMBU_NETWORK_SUCCESS; }
|
||||
|
||||
void MoonrakerPrinterAgent::install_device_cert(std::string dev_id, bool lan_only)
|
||||
{
|
||||
(void) dev_id;
|
||||
(void) lan_only;
|
||||
}
|
||||
|
||||
bool MoonrakerPrinterAgent::start_discovery(bool start, bool sending)
|
||||
{
|
||||
(void) sending;
|
||||
@@ -208,12 +200,6 @@ bool MoonrakerPrinterAgent::start_discovery(bool start, bool sending)
|
||||
return true;
|
||||
}
|
||||
|
||||
int MoonrakerPrinterAgent::ping_bind(std::string ping_code)
|
||||
{
|
||||
(void) ping_code;
|
||||
return BAMBU_NETWORK_SUCCESS;
|
||||
}
|
||||
|
||||
int MoonrakerPrinterAgent::bind_detect(std::string dev_ip, std::string sec_link, detectResult& detect)
|
||||
{
|
||||
(void) sec_link;
|
||||
@@ -230,41 +216,6 @@ int MoonrakerPrinterAgent::bind_detect(std::string dev_ip, std::string sec_link,
|
||||
return BAMBU_NETWORK_SUCCESS;
|
||||
}
|
||||
|
||||
int MoonrakerPrinterAgent::bind(
|
||||
std::string dev_ip, std::string dev_id, std::string dev_model, std::string sec_link, std::string timezone, bool improved, OnUpdateStatusFn update_fn)
|
||||
{
|
||||
(void) dev_ip;
|
||||
(void) dev_id;
|
||||
(void) dev_model;
|
||||
(void) sec_link;
|
||||
(void) timezone;
|
||||
(void) improved;
|
||||
(void) update_fn;
|
||||
return BAMBU_NETWORK_SUCCESS;
|
||||
}
|
||||
|
||||
int MoonrakerPrinterAgent::unbind(std::string dev_id)
|
||||
{
|
||||
(void) dev_id;
|
||||
return BAMBU_NETWORK_SUCCESS;
|
||||
}
|
||||
|
||||
int MoonrakerPrinterAgent::request_bind_ticket(std::string* ticket)
|
||||
{
|
||||
if (ticket)
|
||||
*ticket = "";
|
||||
return BAMBU_NETWORK_SUCCESS;
|
||||
}
|
||||
|
||||
int MoonrakerPrinterAgent::get_hms_snapshot(std::string dev_id, std::string file_name, std::function<void(std::string, int)> callback)
|
||||
{
|
||||
// No BBL cloud snapshot source; report failure so the caller falls back.
|
||||
(void) dev_id;
|
||||
(void) file_name;
|
||||
(void) callback;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int MoonrakerPrinterAgent::set_server_callback(OnServerErrFn fn)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(state_mutex);
|
||||
|
||||
@@ -32,20 +32,11 @@ public:
|
||||
int disconnect_printer() override;
|
||||
int send_message_to_printer(std::string dev_id, std::string json_str, int qos, int flag) override;
|
||||
|
||||
// Certificates
|
||||
int check_cert() override;
|
||||
void install_device_cert(std::string dev_id, bool lan_only) override;
|
||||
|
||||
// Discovery
|
||||
bool start_discovery(bool start, bool sending) override;
|
||||
|
||||
// Binding
|
||||
int ping_bind(std::string ping_code) override;
|
||||
int bind_detect(std::string dev_ip, std::string sec_link, detectResult& detect) override;
|
||||
int bind(std::string dev_ip, std::string dev_id, std::string dev_model, std::string sec_link, std::string timezone, bool improved, OnUpdateStatusFn update_fn) override;
|
||||
int unbind(std::string dev_id) override;
|
||||
int request_bind_ticket(std::string* ticket) override;
|
||||
int get_hms_snapshot(std::string dev_id, std::string file_name, std::function<void(std::string, int)> callback) override;
|
||||
int set_server_callback(OnServerErrFn fn) override;
|
||||
|
||||
// Machine Selection
|
||||
|
||||
@@ -41,19 +41,6 @@ int OrcaPrinterAgent::send_message_to_printer(std::string dev_id, std::string js
|
||||
return BAMBU_NETWORK_SUCCESS;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Certificates - All Stubs
|
||||
// ============================================================================
|
||||
|
||||
int OrcaPrinterAgent::check_cert()
|
||||
{
|
||||
return BAMBU_NETWORK_SUCCESS;
|
||||
}
|
||||
|
||||
void OrcaPrinterAgent::install_device_cert(std::string dev_id, bool lan_only)
|
||||
{
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Discovery - Stub
|
||||
// ============================================================================
|
||||
@@ -63,47 +50,11 @@ bool OrcaPrinterAgent::start_discovery(bool start, bool sending)
|
||||
return true;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Binding - All Stubs
|
||||
// ============================================================================
|
||||
|
||||
int OrcaPrinterAgent::ping_bind(std::string ping_code)
|
||||
{
|
||||
return BAMBU_NETWORK_SUCCESS;
|
||||
}
|
||||
|
||||
int OrcaPrinterAgent::bind_detect(std::string dev_ip, std::string sec_link, detectResult& detect)
|
||||
{
|
||||
return BAMBU_NETWORK_SUCCESS;
|
||||
}
|
||||
|
||||
int OrcaPrinterAgent::bind(
|
||||
std::string dev_ip, std::string dev_id, std::string dev_model, std::string sec_link, std::string timezone, bool improved, OnUpdateStatusFn update_fn)
|
||||
{
|
||||
return BAMBU_NETWORK_SUCCESS;
|
||||
}
|
||||
|
||||
int OrcaPrinterAgent::unbind(std::string dev_id)
|
||||
{
|
||||
return BAMBU_NETWORK_SUCCESS;
|
||||
}
|
||||
|
||||
int OrcaPrinterAgent::request_bind_ticket(std::string* ticket)
|
||||
{
|
||||
if (ticket)
|
||||
*ticket = "";
|
||||
return BAMBU_NETWORK_SUCCESS;
|
||||
}
|
||||
|
||||
int OrcaPrinterAgent::get_hms_snapshot(std::string dev_id, std::string file_name, std::function<void(std::string, int)> callback)
|
||||
{
|
||||
// No BBL cloud snapshot source; report failure so the caller falls back.
|
||||
(void) dev_id;
|
||||
(void) file_name;
|
||||
(void) callback;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int OrcaPrinterAgent::set_server_callback(OnServerErrFn fn)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(state_mutex);
|
||||
|
||||
@@ -32,20 +32,11 @@ public:
|
||||
int disconnect_printer() override;
|
||||
int send_message_to_printer(std::string dev_id, std::string json_str, int qos, int flag) override;
|
||||
|
||||
// Certificates
|
||||
int check_cert() override;
|
||||
void install_device_cert(std::string dev_id, bool lan_only) override;
|
||||
|
||||
// Discovery
|
||||
bool start_discovery(bool start, bool sending) override;
|
||||
|
||||
// Binding
|
||||
int ping_bind(std::string ping_code) override;
|
||||
int bind_detect(std::string dev_ip, std::string sec_link, detectResult& detect) override;
|
||||
int bind(std::string dev_ip, std::string dev_id, std::string dev_model, std::string sec_link, std::string timezone, bool improved, OnUpdateStatusFn update_fn) override;
|
||||
int unbind(std::string dev_id) override;
|
||||
int request_bind_ticket(std::string* ticket) override;
|
||||
int get_hms_snapshot(std::string dev_id, std::string file_name, std::function<void(std::string, int)> callback) override;
|
||||
int set_server_callback(OnServerErrFn fn) override;
|
||||
|
||||
// Machine Selection
|
||||
|
||||
@@ -24,8 +24,8 @@ public:
|
||||
PluginCapabilityType get_type() const override { return PluginCapabilityType::PrinterConnection; }
|
||||
|
||||
// set_cloud_agent is the host-managed dependency injection point — the host hands the
|
||||
// capability its ICloudServiceAgent — so it is the one operation kept native here. Every
|
||||
// other IPrinterAgent operation is pure: the Python plugin must implement all of them.
|
||||
// capability its ICloudServiceAgent — so it is the one operation kept native here. Optional
|
||||
// operations inherit IPrinterAgent's defaults; the remaining operations are plugin-defined.
|
||||
void set_cloud_agent(std::shared_ptr<ICloudServiceAgent> cloud) final override { (void) cloud; }
|
||||
|
||||
AgentInfo get_agent_info() override = 0;
|
||||
@@ -57,31 +57,6 @@ public:
|
||||
int set_on_local_message_fn(OnMessageFn fn) override = 0;
|
||||
int set_queue_on_main_fn(QueueOnMainFn fn) override = 0;
|
||||
|
||||
// The following functions are not required to be implemented for the printer agent to work.
|
||||
// Each default mirrors IPrinterAgent's own "not supported" fallback, so a plugin that skips
|
||||
// one of these behaves like an agent that never had the capability.
|
||||
FilamentSyncMode get_filament_sync_mode() const override { return FilamentSyncMode::none; }
|
||||
bool fetch_filament_info(std::string dev_id, FilamentSyncMode sync_mode) override { return false; }
|
||||
CameraStreamMode get_camera_stream_mode() const override { return CameraStreamMode::none; }
|
||||
std::string get_camera_url() const override { return {}; }
|
||||
void install_device_cert(std::string dev_id, bool lan_only) override {}
|
||||
int check_cert() override { return ORCA_NETWORK_ERR_CAP_NOT_AVAILABLE; }
|
||||
int ping_bind(std::string ping_code) override { return ORCA_NETWORK_ERR_CAP_NOT_AVAILABLE; }
|
||||
int bind(std::string dev_ip,
|
||||
std::string dev_id,
|
||||
std::string dev_model,
|
||||
std::string sec_link,
|
||||
std::string timezone,
|
||||
bool improved,
|
||||
OnUpdateStatusFn update_fn) override
|
||||
{ return ORCA_NETWORK_ERR_CAP_NOT_AVAILABLE; }
|
||||
int unbind(std::string dev_id) override { return ORCA_NETWORK_ERR_CAP_NOT_AVAILABLE; }
|
||||
// request_bind_ticket has a std::string* out-param that cannot round-trip through a
|
||||
// pybind11 override directly; the trampoline dispatches it manually (the Python plugin
|
||||
// returns a (result, ticket) tuple) and falls back to this default when there's no override.
|
||||
int request_bind_ticket(std::string* ticket) override { return ORCA_NETWORK_ERR_CAP_NOT_AVAILABLE; }
|
||||
int get_hms_snapshot(std::string dev_id, std::string file_name, std::function<void(std::string, int)> callback) override
|
||||
{ return ORCA_NETWORK_ERR_CAP_NOT_AVAILABLE; }
|
||||
};
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
Reference in New Issue
Block a user