This commit is contained in:
SoftFever
2026-01-26 19:34:14 +08:00
parent 1a696173c0
commit 978e3b79b5
17 changed files with 276 additions and 568 deletions

View File

@@ -363,6 +363,30 @@ std::string MachineObject::get_ftp_folder()
return DevPrinterConfigUtil::get_ftp_folder(printer_type);
}
std::string MachineObject::dev_id_from_address(const std::string& host, const std::string& port)
{
std::string result = host;
// Normalize host: strip protocol and path
if (result.find("http://") == 0)
result = result.substr(7);
else if (result.find("https://") == 0)
result = result.substr(8);
auto slash = result.find('/');
if (slash != std::string::npos)
result = result.substr(0, slash);
// Build full address (host:port)
if (!port.empty()) {
// Strip inline port if present (port comes from printhost_port)
auto colon = result.find(':');
if (colon != std::string::npos)
result = result.substr(0, colon);
result += ":" + port;
}
return result;
}
bool MachineObject::HasRecentCloudMessage()
{
auto curr_time = std::chrono::system_clock::now();