fix timer
This commit is contained in:
@@ -484,28 +484,28 @@ void BluetoothController::registerAgent() {
|
||||
return;
|
||||
|
||||
try {
|
||||
auto node_info = Gio::DBus::NodeInfo::create_for_xml(agent_introspection_xml);
|
||||
auto interface_info = node_info->lookup_interface("org.bluez.Agent1");
|
||||
m_node_info = Gio::DBus::NodeInfo::create_for_xml(agent_introspection_xml);
|
||||
auto interface_info = m_node_info->lookup_interface("org.bluez.Agent1");
|
||||
|
||||
Gio::DBus::InterfaceVTable vtable(
|
||||
m_interface_vtable = std::make_shared<Gio::DBus::InterfaceVTable>(
|
||||
sigc::mem_fun(*this, &BluetoothController::on_agent_method_call));
|
||||
|
||||
m_agent_id = connection->register_object("/org/bluez/agent", interface_info, vtable);
|
||||
m_agent_id = connection->register_object("/org/bluez/bar_agent", interface_info, *m_interface_vtable);
|
||||
|
||||
auto agent_manager = Gio::DBus::Proxy::create_sync(
|
||||
connection, "org.bluez", "/org/bluez", "org.bluez.AgentManager1");
|
||||
|
||||
if (agent_manager) {
|
||||
agent_manager->call(
|
||||
agent_manager->call_sync(
|
||||
"RegisterAgent",
|
||||
Glib::VariantContainerBase::create_tuple(
|
||||
{Glib::Variant<Glib::ustring>::create("/org/bluez/agent"),
|
||||
Glib::Variant<Glib::ustring>::create("KeyboardDisplay")})); // Using KeyboardDisplay capacity
|
||||
{Glib::Variant<Glib::DBusObjectPathString>::create("/org/bluez/bar_agent"),
|
||||
Glib::Variant<Glib::ustring>::create("DisplayYesNo")}));
|
||||
|
||||
agent_manager->call(
|
||||
agent_manager->call_sync(
|
||||
"RequestDefaultAgent",
|
||||
Glib::VariantContainerBase::create_tuple(
|
||||
{Glib::Variant<Glib::ustring>::create("/org/bluez/agent")}));
|
||||
{Glib::Variant<Glib::DBusObjectPathString>::create("/org/bluez/bar_agent")}));
|
||||
|
||||
spdlog::info("Bluetooth Agent registered successfully");
|
||||
}
|
||||
@@ -523,6 +523,8 @@ void BluetoothController::on_agent_method_call(
|
||||
const Glib::VariantContainerBase ¶meters,
|
||||
const Glib::RefPtr<Gio::DBus::MethodInvocation> &invocation) {
|
||||
|
||||
spdlog::info("Bluetooth Agent method called: {}", method_name.c_str());
|
||||
|
||||
if (method_name == "RequestConfirmation") {
|
||||
// Signature: (ou)
|
||||
std::string device_path = static_cast<std::string>(
|
||||
@@ -547,7 +549,7 @@ void BluetoothController::on_agent_method_call(
|
||||
msg.summary = "Bluetooth Pairing Request";
|
||||
msg.body = "Device '" + device_name + "' wants to pair.\nPasskey: " + passkey_str;
|
||||
msg.app_name = "Bar";
|
||||
msg.actions = {"Confirm", "Cancel"};
|
||||
msg.actions = {"Confirm", "Confirm", "Cancel", "Cancel"};
|
||||
msg.urgency = NotificationUrgency::CRITICAL;
|
||||
msg.expire_timeout = -1; // No timeout, requires user interaction
|
||||
|
||||
@@ -580,8 +582,8 @@ void BluetoothController::on_agent_method_call(
|
||||
msg.summary = "Bluetooth Authorization Request";
|
||||
msg.body = "Device '" + device_name + "' requests authorization to connect.";
|
||||
msg.app_name = "Bar";
|
||||
msg.actions = {"Allow", "Deny"};
|
||||
msg.urgency = NotificationUrgency::CRITICAL;
|
||||
msg.actions = {"Allow", "Allow", "Deny", "Deny"};
|
||||
msg.urgency = NotificationUrgency::LOW;
|
||||
msg.expire_timeout = -1;
|
||||
|
||||
msg.on_action = [invocation](const std::string &action) {
|
||||
@@ -614,7 +616,7 @@ void BluetoothController::on_agent_method_call(
|
||||
msg.summary = "Bluetooth Service Authorization";
|
||||
msg.body = "Device '" + device_name + "' wants to access service: " + uuid;
|
||||
msg.app_name = "Bar";
|
||||
msg.actions = {"Allow", "Deny"};
|
||||
msg.actions = {"Allow", "Allow", "Deny", "Deny"};
|
||||
msg.urgency = NotificationUrgency::CRITICAL;
|
||||
msg.expire_timeout = -1;
|
||||
|
||||
@@ -762,4 +764,5 @@ void BluetoothController::on_agent_method_call(
|
||||
// Not implemented
|
||||
invocation->return_dbus_error("org.bluez.Error.Rejected", "Not implemented");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user