ENH: [STUDIO-4029] sync printer config with cloud

Change-Id: Icffee9d5987131e1d78d51ccfcafeefff18f26cb
Jira: STUDIO-4029
(cherry picked from commit 5b58e5f2658753efbf11037f0b6cbb023070c0ea)
This commit is contained in:
chunmao.guo 2023-08-16 15:38:16 +08:00 committed by Lane.Wei
parent 11f0fb6016
commit 042e6bf991
8 changed files with 186 additions and 15 deletions

View file

@ -470,6 +470,12 @@ PrinterArch MachineObject::get_printer_arch() const
return DeviceManager::get_printer_arch(printer_type);
}
void MachineObject::reload_printer_settings()
{
print_json.load_compatible_settings("", "");
parse_json("{}");
}
MachineObject::MachineObject(NetworkAgent* agent, std::string name, std::string id, std::string ip)
:dev_name(name),
dev_id(id),
@ -2592,10 +2598,8 @@ int MachineObject::parse_json(std::string payload)
if (j_pre["print"]["msg"].get<int>() == 0) { //all message
BOOST_LOG_TRIVIAL(trace) << "static: get push_all msg, dev_id=" << dev_id;
m_push_count++;
if (j_pre["print"].contains("printer_type")) {
printer_type = parse_printer_type(j_pre["print"]["printer_type"].get<std::string>());
}
print_json.load_compatible_settings(printer_type, "");
if (!printer_type.empty())
print_json.load_compatible_settings(printer_type, "");
print_json.diff2all_base_reset(j_pre);
} else if (j_pre["print"]["msg"].get<int>() == 1) { //diff message
if (print_json.diff2all(j_pre, j) == 0) {
@ -4764,6 +4768,12 @@ MachineObject* DeviceManager::get_local_selected_machine()
return get_local_machine(local_selected_machine);
}
void DeviceManager::reload_printer_settings()
{
for (auto obj : this->userMachineList)
obj.second->reload_printer_settings();
}
MachineObject* DeviceManager::get_default_machine() {
std::string dev_id;