This commit is contained in:
SoftFever
2026-01-23 17:05:56 +08:00
parent 12f51f906e
commit 9703a6b4d7
60 changed files with 13396 additions and 1785 deletions

View File

@@ -300,6 +300,13 @@ void AppConfig::set_defaults()
if (get("allow_abnormal_storage").empty()) {
set_bool("allow_abnormal_storage", false);
}
#ifdef __linux__
if (get(SETTING_USE_ENCRYPTED_TOKEN_FILE).empty())
set_bool(SETTING_USE_ENCRYPTED_TOKEN_FILE, true);
#else
if (get(SETTING_USE_ENCRYPTED_TOKEN_FILE).empty())
set_bool(SETTING_USE_ENCRYPTED_TOKEN_FILE, false);
#endif
if(get("check_stable_update_only").empty()) {
set_bool("check_stable_update_only", false);

View File

@@ -28,6 +28,7 @@ using namespace nlohmann;
#define SETTING_NETWORK_PLUGIN_SKIPPED_VERSIONS "network_plugin_skipped_versions"
#define SETTING_NETWORK_PLUGIN_UPDATE_DISABLED "network_plugin_update_prompts_disabled"
#define SETTING_NETWORK_PLUGIN_REMIND_LATER "network_plugin_remind_later"
#define SETTING_USE_ENCRYPTED_TOKEN_FILE "use_encrypted_token_file"
#define BAMBU_NETWORK_AGENT_VERSION_LEGACY "01.10.01.01"
#define SUPPORT_DARK_MODE

View File

@@ -1017,7 +1017,7 @@ static std::vector<std::string> s_Preset_printer_options {
"scan_first_layer", "enable_power_loss_recovery", "wrapping_detection_layers", "wrapping_exclude_area", "machine_load_filament_time", "machine_unload_filament_time", "machine_tool_change_time", "time_cost", "machine_pause_gcode", "template_custom_gcode",
"nozzle_type", "nozzle_hrc","auxiliary_fan", "nozzle_volume","upward_compatible_machine", "z_hop_types", "travel_slope", "retract_lift_enforce","support_chamber_temp_control","support_air_filtration","printer_structure",
"best_object_pos", "head_wrap_detect_zone",
"host_type", "print_host", "printhost_apikey", "bbl_use_printhost",
"host_type", "print_host", "printhost_apikey", "bbl_use_printhost", "printer_agent",
"print_host_webui",
"printhost_cafile","printhost_port","printhost_authorization_type",
"printhost_user", "printhost_password", "printhost_ssl_ignore_revoke", "thumbnails", "thumbnails_format",
@@ -1502,7 +1502,7 @@ int PresetCollection::get_differed_values_to_update(Preset& preset, std::map<std
}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " uploading user preset name is: " << preset.name << "and create filament_id is: " << preset.filament_id
<< " and base_id is: " << preset.base_id;
key_values[BBL_JSON_KEY_UPDATE_TIME] = std::to_string(preset.updated_time);
key_values[ORCA_JSON_KEY_UPDATE_TIME] = std::to_string(preset.updated_time);
key_values[BBL_JSON_KEY_TYPE] = Preset::get_iot_type_string(preset.type);
return 0;
}
@@ -1802,8 +1802,8 @@ bool PresetCollection::load_user_preset(std::string name, std::map<std::string,
//update_time
long long cloud_update_time = 0;
if (preset_values.find(BBL_JSON_KEY_UPDATE_TIME) != preset_values.end()) {
cloud_update_time = std::atoll(preset_values[BBL_JSON_KEY_UPDATE_TIME].c_str());
if (preset_values.find(ORCA_JSON_KEY_UPDATE_TIME) != preset_values.end()) {
cloud_update_time = std::atoll(preset_values[ORCA_JSON_KEY_UPDATE_TIME].c_str());
}
//user_id
@@ -3395,6 +3395,7 @@ static std::vector<std::string> s_PhysicalPrinter_opts {
"printer_technology",
"bbl_use_printhost",
"host_type",
"printer_agent",
"print_host",
"print_host_webui",
"printhost_apikey",

View File

@@ -52,7 +52,8 @@
#define BBL_JSON_KEY_BASE_ID "base_id"
#define BBL_JSON_KEY_USER_ID "user_id"
#define BBL_JSON_KEY_FILAMENT_ID "filament_id"
#define BBL_JSON_KEY_UPDATE_TIME "updated_time"
#define ORCA_JSON_KEY_UPDATE_TIME "updated_time"
#define ORCA_JSON_KEY_CREATED_TIME "created_time"
#define BBL_JSON_KEY_INHERITS "inherits"
#define BBL_JSON_KEY_INSTANTIATION "instantiation"
#define BBL_JSON_KEY_NOZZLE_DIAMETER "nozzle_diameter"

View File

@@ -740,6 +740,13 @@ void PrintConfigDef::init_common_params()
def->cli = ConfigOptionDef::nocli;
def->set_default_value(new ConfigOptionBool(false));
def = this->add("printer_agent", coString);
def->label = L("Printer Agent");
def->tooltip = L("Select the network agent implementation for printer communication.");
def->mode = comAdvanced;
def->cli = ConfigOptionDef::nocli;
def->set_default_value(new ConfigOptionString(""));
def = this->add("print_host", coString);
def->label = L("Hostname, IP or URL");
def->tooltip = L("Orca Slicer can upload G-code files to a printer host. This field should contain "

View File

@@ -6,6 +6,7 @@
#include <cassert>
#include <ctime>
#include <cstdio>
#include <cctype>
#ifdef _MSC_VER
#include <map>
@@ -230,5 +231,76 @@ time_t str2time(const std::string &str, TimeZone zone, TimeFormat fmt)
return str2time(ss, zone, fmtstr.c_str());
}
// /////////////////////////////////////////////////////////////////////////////
// Millisecond timestamps for cloud sync protocol
std::string millis_to_iso8601(long long unix_millis)
{
time_t seconds = static_cast<time_t>(unix_millis / 1000);
int millis = static_cast<int>(unix_millis % 1000);
std::tm tms = {};
_gmtime_r(&seconds, &tms);
char buf[32];
std::snprintf(buf, sizeof(buf), "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ",
tms.tm_year + 1900,
tms.tm_mon + 1,
tms.tm_mday,
tms.tm_hour,
tms.tm_min,
tms.tm_sec,
millis);
return std::string(buf);
}
long long iso8601_to_millis(const std::string& iso_time)
{
if (iso_time.empty()) return -1;
int y, M, d, h, m, s, ms = 0;
// Try parsing with milliseconds: "2025-11-28T14:30:00.123Z"
int parsed = sscanf(iso_time.c_str(), "%d-%d-%dT%d:%d:%d.%dZ",
&y, &M, &d, &h, &m, &s, &ms);
if (parsed < 6) {
// Try without milliseconds: "2025-11-28T14:30:00Z"
parsed = sscanf(iso_time.c_str(), "%d-%d-%dT%d:%d:%dZ",
&y, &M, &d, &h, &m, &s);
ms = 0;
}
if (parsed < 6) return -1;
// Normalize milliseconds (handle .1, .12, .123, .1234, etc.)
if (parsed >= 7) {
// Count digits in the fractional part to normalize
const char* dot = strchr(iso_time.c_str(), '.');
if (dot) {
int digits = 0;
for (const char* p = dot + 1; *p && *p != 'Z' && std::isdigit(*p); ++p)
digits++;
// Normalize to 3 digits (milliseconds)
while (digits < 3) { ms *= 10; digits++; }
while (digits > 3) { ms /= 10; digits--; }
}
}
std::tm tms = {};
tms.tm_year = y - 1900;
tms.tm_mon = M - 1;
tms.tm_mday = d;
tms.tm_hour = h;
tms.tm_min = m;
tms.tm_sec = s;
time_t seconds = _timegm(&tms);
if (seconds == time_t(-1)) return -1;
return static_cast<long long>(seconds) * 1000 + ms;
}
}; // namespace Utils
}; // namespace Slic3r

View File

@@ -63,6 +63,15 @@ inline time_t parse_iso_utc_timestamp(const std::string &str)
return str2time(str, TimeZone::utc, TimeFormat::iso8601Z);
}
// /////////////////////////////////////////////////////////////////////////////
// Millisecond timestamps for cloud sync protocol
// Format: "2025-11-28T14:30:00.123Z" (ISO 8601 with milliseconds)
// Lossless conversion: Unix milliseconds <-> ISO 8601
// Format: "YYYY-MM-DDTHH:MM:SS.sssZ" (always 3 decimal places for milliseconds)
std::string millis_to_iso8601(long long unix_millis);
long long iso8601_to_millis(const std::string& iso_time); // Returns -1 on parse error
// /////////////////////////////////////////////////////////////////////////////
} // namespace Utils