Skip to content

Commit b414525

Browse files
authored
PairDialog: send ACCEPT when paired (#240)
1 parent b935a3e commit b414525

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/PairDialog.vala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ public class PairDialog : Granite.MessageDialog {
8585
device = Bus.get_proxy_sync (BusType.SYSTEM, "org.bluez", object_path, DBusProxyFlags.GET_INVALIDATED_PROPERTIES);
8686
image_icon = new ThemedIcon (device.icon ?? "bluetooth");
8787
device_name = device.name ?? device.address;
88+
89+
// Close when pins or passkeys are accepted for example
90+
((DBusProxy)device).g_properties_changed.connect ((changed, invalid) => {
91+
var paired = changed.lookup_value ("Paired", new VariantType ("b"));
92+
if (paired != null && device.paired) {
93+
response (Gtk.ResponseType.ACCEPT);
94+
}
95+
});
8896
} catch (IOError e) {
8997
image_icon = new ThemedIcon ("bluetooth");
9098
critical (e.message);

src/Services/Agent.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public class Bluetooth.Services.Agent : Object {
7070
// instantly
7171
public async void display_pin_code (ObjectPath device, string pincode) throws Error, BluezError {
7272
pair_dialog = new PairDialog.display_pin_code (device, pincode, main_window);
73-
pair_dialog.present ();
73+
yield check_pairing_response (pair_dialog);
7474
}
7575

7676
public async uint32 request_passkey (ObjectPath device) throws Error, BluezError {
@@ -81,7 +81,7 @@ public class Bluetooth.Services.Agent : Object {
8181
// instantly
8282
public async void display_passkey (ObjectPath device, uint32 passkey, uint16 entered) throws Error {
8383
pair_dialog = new PairDialog.display_passkey (device, passkey, entered, main_window);
84-
pair_dialog.present ();
84+
yield check_pairing_response (pair_dialog);
8585
}
8686

8787
// Called to request confirmation from the user that they want to pair with the given device and that

0 commit comments

Comments
 (0)