mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-08-05 01:02:08 +00:00
* Add OrcaCloud sync platform and preset bundle sharing system Introduce OrcaCloud, a cloud sync platform for user presets, alongside a preset bundle system that enables sharing printer/filament/process profiles as local exportable bundles or subscribed cloud bundles. OrcaCloud platform: - Auth to Orca Cloud - Encrypted token storage (file-based or system keychain) - User preset sync with - Profile migration from default/bambu folders on first login - Homepage integration with entrance to cloud.orcaslicer.com Preset bundles: - Local bundle import/export with bundle_structure.json metadata - Subscribed cloud bundles with version-based update checking - Thread-safe concurrent bundle access with read-write mutex - Canonical bundle preset naming (_local/<id>/... and _subscribed/<id>/...) - Bundle presets are read-only; grouped under subheaders in combo boxes - PresetBundleDialog with auto-sync toggle, refresh, update notifications - Hyperlinked bundle names to cloud bundle pages Co-authored-by: Sabriel Koh <sabrielkcr@gmail.com> Co-authored-by: Derrick <derrick992110@gmail.com> Co-authored-by: Mykola Nahirnyi <mnahirnyi@amcbridge.com> Co-authored-by: Ian Chua <iancrb00@gmail.com> Co-authored-by: Draginraptor <draginraptor@gmail.com> Co-authored-by: ExPikaPaka <112851715+ExPikaPaka@users.noreply.github.com> Co-authored-by: Ian Bassi <ian.bassi@outlook.com> Co-authored-by: Ocraftyone <Ocraftyone@users.noreply.github.com> Co-authored-by: yw4z <ywsyildiz@gmail.com> Co-authored-by: peterm-m <101202951+peterm-m@users.noreply.github.com> * Fixed an issue on Windows it failed to login Orca Cloud with Google account
454 lines
14 KiB
C++
454 lines
14 KiB
C++
#include "BBLPrinterAgent.hpp"
|
|
#include "BBLNetworkPlugin.hpp"
|
|
#include "NetworkAgentFactory.hpp"
|
|
|
|
#include <boost/log/trivial.hpp>
|
|
|
|
namespace Slic3r {
|
|
|
|
BBLPrinterAgent::BBLPrinterAgent() = default;
|
|
|
|
BBLPrinterAgent::~BBLPrinterAgent() = default;
|
|
|
|
void BBLPrinterAgent::set_cloud_agent(std::shared_ptr<ICloudServiceAgent> cloud)
|
|
{
|
|
m_cloud_agent = cloud;
|
|
// BBL DLL manages tokens internally, so this is just for interface compliance
|
|
}
|
|
|
|
// ============================================================================
|
|
// Communication
|
|
// ============================================================================
|
|
|
|
int BBLPrinterAgent::send_message(std::string dev_id, std::string json_str, int qos, int flag)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_send_message();
|
|
if (func && agent) {
|
|
if (plugin.use_legacy_network()) {
|
|
auto legacy_func = reinterpret_cast<func_send_message_legacy>(func);
|
|
return legacy_func(agent, dev_id, json_str, qos);
|
|
}
|
|
return func(agent, dev_id, json_str, qos, flag);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int BBLPrinterAgent::connect_printer(std::string dev_id, std::string dev_ip, std::string username, std::string password, bool use_ssl)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_connect_printer();
|
|
if (func && agent) {
|
|
return func(agent, dev_id, dev_ip, username, password, use_ssl);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int BBLPrinterAgent::disconnect_printer()
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_disconnect_printer();
|
|
if (func && agent) {
|
|
return func(agent);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int BBLPrinterAgent::send_message_to_printer(std::string dev_id, std::string json_str, int qos, int flag)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_send_message_to_printer();
|
|
if (func && agent) {
|
|
if (plugin.use_legacy_network()) {
|
|
auto legacy_func = reinterpret_cast<func_send_message_to_printer_legacy>(func);
|
|
return legacy_func(agent, dev_id, json_str, qos);
|
|
}
|
|
return func(agent, dev_id, json_str, qos, flag);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
// ============================================================================
|
|
// Certificates
|
|
// ============================================================================
|
|
|
|
int BBLPrinterAgent::check_cert()
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_check_cert();
|
|
if (func && agent) {
|
|
return func(agent);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
void BBLPrinterAgent::install_device_cert(std::string dev_id, bool lan_only)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_install_device_cert();
|
|
if (func && agent) {
|
|
func(agent, dev_id, lan_only);
|
|
}
|
|
}
|
|
|
|
// ============================================================================
|
|
// Discovery
|
|
// ============================================================================
|
|
|
|
bool BBLPrinterAgent::start_discovery(bool start, bool sending)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_start_discovery();
|
|
if (func && agent) {
|
|
return func(agent, start, sending);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// ============================================================================
|
|
// Binding
|
|
// ============================================================================
|
|
|
|
int BBLPrinterAgent::ping_bind(std::string ping_code)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_ping_bind();
|
|
if (func && agent) {
|
|
return func(agent, ping_code);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int BBLPrinterAgent::bind_detect(std::string dev_ip, std::string sec_link, detectResult& detect)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_bind_detect();
|
|
if (func && agent) {
|
|
return func(agent, dev_ip, sec_link, detect);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int BBLPrinterAgent::bind(std::string dev_ip, std::string dev_id, std::string sec_link, std::string timezone, bool improved, OnUpdateStatusFn update_fn)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_bind();
|
|
if (func && agent) {
|
|
return func(agent, dev_ip, dev_id, sec_link, timezone, improved, update_fn);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int BBLPrinterAgent::unbind(std::string dev_id)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_unbind();
|
|
if (func && agent) {
|
|
return func(agent, dev_id);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int BBLPrinterAgent::request_bind_ticket(std::string* ticket)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_request_bind_ticket();
|
|
if (func && agent) {
|
|
return func(agent, ticket);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int BBLPrinterAgent::set_server_callback(OnServerErrFn fn)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_set_server_callback();
|
|
if (func && agent) {
|
|
return func(agent, fn);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
// ============================================================================
|
|
// Machine Selection
|
|
// ============================================================================
|
|
|
|
std::string BBLPrinterAgent::get_user_selected_machine()
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_get_user_selected_machine();
|
|
if (func && agent) {
|
|
return func(agent);
|
|
}
|
|
return "";
|
|
}
|
|
|
|
int BBLPrinterAgent::set_user_selected_machine(std::string dev_id)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_set_user_selected_machine();
|
|
if (func && agent) {
|
|
return func(agent, dev_id);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
// ============================================================================
|
|
// Subscriptions
|
|
// ============================================================================
|
|
|
|
int BBLPrinterAgent::start_subscribe(std::string module)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_start_subscribe();
|
|
if (func && agent) {
|
|
return func(agent, module);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int BBLPrinterAgent::stop_subscribe(std::string module)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_stop_subscribe();
|
|
if (func && agent) {
|
|
return func(agent, module);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int BBLPrinterAgent::add_subscribe(std::vector<std::string> dev_list)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_add_subscribe();
|
|
if (func && agent) {
|
|
return func(agent, dev_list);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int BBLPrinterAgent::del_subscribe(std::vector<std::string> dev_list)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_del_subscribe();
|
|
if (func && agent) {
|
|
return func(agent, dev_list);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
// ============================================================================
|
|
// Agent Information
|
|
// ============================================================================
|
|
AgentInfo BBLPrinterAgent::get_agent_info_static()
|
|
{
|
|
return AgentInfo{BBL_PRINTER_AGENT_ID, "Bambu Lab", "", "Bambu Lab printer agent"};
|
|
}
|
|
|
|
// ============================================================================
|
|
// Print Job Operations
|
|
// ============================================================================
|
|
|
|
int BBLPrinterAgent::start_print(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_start_print();
|
|
if (func && agent) {
|
|
if (plugin.use_legacy_network()) {
|
|
auto legacy_func = reinterpret_cast<func_start_print_legacy>(func);
|
|
auto legacy_params = BBLNetworkPlugin::as_legacy(params);
|
|
return legacy_func(agent, legacy_params, update_fn, cancel_fn, wait_fn);
|
|
}
|
|
return func(agent, params, update_fn, cancel_fn, wait_fn);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int BBLPrinterAgent::start_local_print_with_record(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_start_local_print_with_record();
|
|
if (func && agent) {
|
|
if (plugin.use_legacy_network()) {
|
|
auto legacy_func = reinterpret_cast<func_start_local_print_with_record_legacy>(func);
|
|
auto legacy_params = BBLNetworkPlugin::as_legacy(params);
|
|
return legacy_func(agent, legacy_params, update_fn, cancel_fn, wait_fn);
|
|
}
|
|
return func(agent, params, update_fn, cancel_fn, wait_fn);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int BBLPrinterAgent::start_send_gcode_to_sdcard(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, OnWaitFn wait_fn)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_start_send_gcode_to_sdcard();
|
|
if (func && agent) {
|
|
if (plugin.use_legacy_network()) {
|
|
auto legacy_func = reinterpret_cast<func_start_send_gcode_to_sdcard_legacy>(func);
|
|
auto legacy_params = BBLNetworkPlugin::as_legacy(params);
|
|
return legacy_func(agent, legacy_params, update_fn, cancel_fn, wait_fn);
|
|
}
|
|
return func(agent, params, update_fn, cancel_fn, wait_fn);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int BBLPrinterAgent::start_local_print(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_start_local_print();
|
|
if (func && agent) {
|
|
if (plugin.use_legacy_network()) {
|
|
auto legacy_func = reinterpret_cast<func_start_local_print_legacy>(func);
|
|
auto legacy_params = BBLNetworkPlugin::as_legacy(params);
|
|
return legacy_func(agent, legacy_params, update_fn, cancel_fn);
|
|
}
|
|
return func(agent, params, update_fn, cancel_fn);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int BBLPrinterAgent::start_sdcard_print(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_start_sdcard_print();
|
|
if (func && agent) {
|
|
if (plugin.use_legacy_network()) {
|
|
auto legacy_func = reinterpret_cast<func_start_sdcard_print_legacy>(func);
|
|
auto legacy_params = BBLNetworkPlugin::as_legacy(params);
|
|
return legacy_func(agent, legacy_params, update_fn, cancel_fn);
|
|
}
|
|
return func(agent, params, update_fn, cancel_fn);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
// ============================================================================
|
|
// Callbacks
|
|
// ============================================================================
|
|
|
|
int BBLPrinterAgent::set_on_ssdp_msg_fn(OnMsgArrivedFn fn)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_set_on_ssdp_msg_fn();
|
|
if (func && agent) {
|
|
return func(agent, fn);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int BBLPrinterAgent::set_on_printer_connected_fn(OnPrinterConnectedFn fn)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_set_on_printer_connected_fn();
|
|
if (func && agent) {
|
|
return func(agent, fn);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int BBLPrinterAgent::set_on_subscribe_failure_fn(GetSubscribeFailureFn fn)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_set_on_subscribe_failure_fn();
|
|
if (func && agent) {
|
|
return func(agent, fn);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int BBLPrinterAgent::set_on_message_fn(OnMessageFn fn)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_set_on_message_fn();
|
|
if (func && agent) {
|
|
return func(agent, fn);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int BBLPrinterAgent::set_on_user_message_fn(OnMessageFn fn)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_set_on_user_message_fn();
|
|
if (func && agent) {
|
|
return func(agent, fn);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int BBLPrinterAgent::set_on_local_connect_fn(OnLocalConnectedFn fn)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_set_on_local_connect_fn();
|
|
if (func && agent) {
|
|
return func(agent, fn);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int BBLPrinterAgent::set_on_local_message_fn(OnMessageFn fn)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_set_on_local_message_fn();
|
|
if (func && agent) {
|
|
return func(agent, fn);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int BBLPrinterAgent::set_queue_on_main_fn(QueueOnMainFn fn)
|
|
{
|
|
auto& plugin = BBLNetworkPlugin::instance();
|
|
auto agent = plugin.get_agent();
|
|
auto func = plugin.get_set_queue_on_main_fn();
|
|
if (func && agent) {
|
|
return func(agent, fn);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
// ============================================================================
|
|
// Filament Operations
|
|
// ============================================================================
|
|
|
|
FilamentSyncMode BBLPrinterAgent::get_filament_sync_mode() const
|
|
{
|
|
// BBL uses MQTT subscription for real-time filament updates
|
|
return FilamentSyncMode::subscription;
|
|
}
|
|
|
|
} // namespace Slic3r
|