refactor
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user