1818 * Authored by: Corentin Noël <[email protected] > 1919 */
2020
21- [DBus (name = " org.bluez.AgentManager1" )]
22- public interface Bluetooth.Services.AgentManager : Object {
23- public abstract void register_agent (ObjectPath agent , string capability ) throws Error ;
24- public abstract void request_default_agent (ObjectPath agent ) throws Error ;
25- public abstract void unregister_agent (ObjectPath agent ) throws Error ;
26- }
27-
2821public class Bluetooth.Services.ObjectManager : Object {
2922 private const string SCHEMA = " io.elementary.desktop.wingpanel.bluetooth" ;
3023 public signal void adapter_added (Bluetooth .Services .Adapter adapter );
@@ -40,12 +33,8 @@ public class Bluetooth.Services.ObjectManager : Object {
4033 public bool is_powered {get ; private set ; default = false ; }
4134 public bool is_connected {get ; private set ; default = false ; }
4235
43- private bool is_registered = false ;
44-
4536 private Settings ? settings = null ;
4637 private GLib . DBusObjectManagerClient object_manager;
47- private Bluetooth . Services . AgentManager agent_manager;
48- private Bluetooth . Services . Agent agent;
4938
5039 construct {
5140 var settings_schema = SettingsSchemaSource . get_default (). lookup (SCHEMA , true );
@@ -239,54 +228,6 @@ public class Bluetooth.Services.ObjectManager : Object {
239228 return null ;
240229 }
241230
242- private async void create_agent (Gtk .Window ? window ) {
243- if (object_manager == null ) {
244- return ;
245- }
246- GLib . DBusObject ? bluez_object = object_manager. get_object (" /org/bluez" );
247- if (bluez_object != null ) {
248- agent_manager = (Bluetooth . Services . AgentManager ) bluez_object. get_interface (" org.bluez.AgentManager1" );
249- }
250-
251- agent = new Bluetooth .Services .Agent (window);
252- agent. notify[" ready" ]. connect (() = > {
253- if (is_registered) {
254- register_agent. begin (window);
255- }
256- });
257-
258- agent. unregistered. connect (() = > {
259- is_registered = false ;
260- });
261- }
262-
263- public async void register_agent (Gtk .Window ? window ) {
264- is_registered = true ;
265- if (agent_manager == null ) {
266- yield create_agent (window);
267- }
268-
269- if (agent_manager != null && agent. ready) {
270- try {
271- agent_manager. register_agent (agent. get_path (), " DisplayYesNo" );
272- agent_manager. request_default_agent (agent. get_path ());
273- } catch (Error e) {
274- critical (e. message);
275- }
276- }
277- }
278-
279- public async void unregister_agent () {
280- is_registered = false ;
281- if (agent_manager != null && agent. ready) {
282- try {
283- agent_manager. unregister_agent (agent. get_path ());
284- } catch (Error e) {
285- critical (e. message);
286- }
287- }
288- }
289-
290231 public void check_global_state () {
291232 /* As this is called within a signal handler and emits a signal
292233 * it should be in a Idle loop else races occur */
0 commit comments