This commit is contained in:
SoftFever
2026-01-26 20:12:55 +08:00
parent 3ed07d5f9b
commit e93f50702e
9 changed files with 24 additions and 234 deletions

View File

@@ -114,16 +114,10 @@ NetworkAgent::NetworkAgent(std::string log_dir)
plugin.create_agent(log_dir);
}
// Create BBL sub-agents that will use the singleton
m_cloud_agent = std::make_shared<BBLCloudServiceAgent>();
m_printer_agent = std::make_shared<BBLPrinterAgent>();
m_printer_agent->set_cloud_agent(m_cloud_agent);
m_printer_agent_id = m_printer_agent->get_agent_info().id;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", this %1%, agent=%2%, log_dir=%3%")
% this % plugin.get_agent() % log_dir;
} else {
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ": BBL network plugin not loaded";
}
}
@@ -132,17 +126,12 @@ NetworkAgent::NetworkAgent(std::shared_ptr<ICloudServiceAgent> cloud_agent,
: m_cloud_agent(std::move(cloud_agent))
, m_printer_agent(std::move(printer_agent))
{
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(
", sub-agent composition mode: cloud=%1%, printer=%2%")
% (m_cloud_agent ? "yes" : "no")
% (m_printer_agent ? "yes" : "no (will be set when printer selected)");
}
NetworkAgent::~NetworkAgent()
{
// Note: We don't destroy the agent here anymore since it's managed by BBLNetworkPlugin singleton
// The singleton manages the agent lifecycle
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", this %1%") % this;
}
void NetworkAgent::set_printer_agent(std::shared_ptr<IPrinterAgent> printer_agent)
@@ -158,7 +147,6 @@ void NetworkAgent::set_printer_agent(std::shared_ptr<IPrinterAgent> printer_agen
std::lock_guard<std::mutex> lock(m_agent_mutex);
if (!printer_agent) {
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ": null printer agent provided";
return;
}
@@ -180,8 +168,6 @@ void NetworkAgent::set_printer_agent(std::shared_ptr<IPrinterAgent> printer_agen
// critical section duration. The local shared_ptr copy ensures the agent
// cannot be destroyed while we're using it.
apply_printer_callbacks(new_printer_agent, callbacks);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": agent switched successfully";
}
void* NetworkAgent::get_network_agent()