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");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,9 +29,8 @@ BluetoothSettingsRow::BluetoothSettingsRow(const BluetoothDevice &device)
|
||||
deviceInfoBox.set_spacing(2);
|
||||
append(deviceInfoBox);
|
||||
|
||||
std::string shortName = StringHelper::trimToSize(device.name.empty() ? "Unknown Device" : device.name, 14);
|
||||
|
||||
nameLabel.set_text(shortName);
|
||||
nameLabel.set_ellipsize(Pango::EllipsizeMode::END);
|
||||
nameLabel.set_text(device.name.empty() ? "Unknown Device" : device.name );
|
||||
nameLabel.set_halign(Gtk::Align::START);
|
||||
nameLabel.set_valign(Gtk::Align::CENTER);
|
||||
deviceInfoBox.append(nameLabel);
|
||||
@@ -41,6 +40,7 @@ BluetoothSettingsRow::BluetoothSettingsRow(const BluetoothDevice &device)
|
||||
addressLabel.set_valign(Gtk::Align::CENTER);
|
||||
addressLabel.add_css_class("bluetooth-device-address");
|
||||
deviceInfoBox.append(addressLabel);
|
||||
deviceInfoBox.set_size_request(140, -1);
|
||||
|
||||
auto buttonBox = Gtk::Box(Gtk::Orientation::HORIZONTAL);
|
||||
buttonBox.set_hexpand(true);
|
||||
@@ -80,9 +80,7 @@ void BluetoothSettingsRow::updateDevice(const BluetoothDevice &device) {
|
||||
|
||||
spdlog::info("Updating device {}: paired={}, connected={}, trusted={}", device.name, device.paired, device.connected, device.trusted);
|
||||
|
||||
std::string shortName = StringHelper::trimToSize(device.name.empty() ? "Unknown Device" : device.name, 14);
|
||||
|
||||
nameLabel.set_text(shortName);
|
||||
nameLabel.set_text(device.name.empty() ? "Unknown Device" : device.name);
|
||||
addressLabel.set_text(device.address);
|
||||
pairButton.setIcon(device.paired ? Icon::BLUETOOTH_CONNECTED : Icon::BLUETOOTH);
|
||||
connectButton.setIcon(device.connected ? Icon::LINK : Icon::LINK_OFF);
|
||||
|
||||
@@ -86,8 +86,12 @@ TimerWidget::TimerWidget() {
|
||||
if (rawDigits.empty()) {
|
||||
return;
|
||||
}
|
||||
spdlog::info("Timer set for {} seconds", rawDigits);
|
||||
this->timerService->addTimer(std::stoul(rawDigits));
|
||||
|
||||
uint64_t rawValue = std::stoull(rawDigits);
|
||||
uint64_t seconds = (rawValue / 10000) * 3600 + ((rawValue / 100) % 100) * 60 + (rawValue % 100);
|
||||
|
||||
spdlog::info("Timer set for {} seconds", seconds);
|
||||
this->timerService->addTimer(seconds);
|
||||
rawDigits.clear();
|
||||
this->updatingText = true;
|
||||
entry->set_text("");
|
||||
|
||||
@@ -78,6 +78,7 @@ NotificationWindow::NotificationWindow(uint64_t notificationId, std::shared_ptr<
|
||||
entry->set_hexpand(true);
|
||||
entry->add_css_class("notification-entry");
|
||||
vbox->append(*entry);
|
||||
entry->grab_focus_without_selecting();
|
||||
|
||||
entry->signal_activate().connect([this, entry, cb = notify.on_input]() {
|
||||
if (cb) {
|
||||
|
||||
Reference in New Issue
Block a user