diff --git a/src/PairDialog.vala b/src/PairDialog.vala index e12a163b..080d18e5 100644 --- a/src/PairDialog.vala +++ b/src/PairDialog.vala @@ -85,6 +85,14 @@ public class PairDialog : Granite.MessageDialog { device = Bus.get_proxy_sync (BusType.SYSTEM, "org.bluez", object_path, DBusProxyFlags.GET_INVALIDATED_PROPERTIES); image_icon = new ThemedIcon (device.icon ?? "bluetooth"); device_name = device.name ?? device.address; + + // Close when pins or passkeys are accepted for example + ((DBusProxy)device).g_properties_changed.connect ((changed, invalid) => { + var paired = changed.lookup_value ("Paired", new VariantType ("b")); + if (paired != null && device.paired) { + response (Gtk.ResponseType.ACCEPT); + } + }); } catch (IOError e) { image_icon = new ThemedIcon ("bluetooth"); critical (e.message); diff --git a/src/Services/Agent.vala b/src/Services/Agent.vala index 17762432..6f5d0a06 100644 --- a/src/Services/Agent.vala +++ b/src/Services/Agent.vala @@ -70,7 +70,7 @@ public class Bluetooth.Services.Agent : Object { // instantly public async void display_pin_code (ObjectPath device, string pincode) throws Error, BluezError { pair_dialog = new PairDialog.display_pin_code (device, pincode, main_window); - pair_dialog.present (); + yield check_pairing_response (pair_dialog); } public async uint32 request_passkey (ObjectPath device) throws Error, BluezError { @@ -81,7 +81,7 @@ public class Bluetooth.Services.Agent : Object { // instantly public async void display_passkey (ObjectPath device, uint32 passkey, uint16 entered) throws Error { pair_dialog = new PairDialog.display_passkey (device, passkey, entered, main_window); - pair_dialog.present (); + yield check_pairing_response (pair_dialog); } // Called to request confirmation from the user that they want to pair with the given device and that