From 2f7c4969dbb3f6de89260926e5460ea37986fbda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?= Date: Tue, 10 Sep 2019 15:42:18 -0700 Subject: [PATCH] bluetooth: Add mechanism to track profile's status Create pa_bluetooth_profile_status_t to represent all stages an external Bluetooth profile can go through: 0. Inactive: Initial state, no D-Bus object has been registered for this profile yet. 1. Active: an object implementing the org.bluez.Profile1 interface has been registered on the system bus. 2. Registering: RegisterProfile has been called. 3. Registered: RegisterProfile succeeded. This will be useful to handle RegisterProfile failures, as well as dynamically register and un-register a profile based on the current active seat. Part-of: --- src/modules/bluetooth/bluez5-util.c | 9 +++++++++ src/modules/bluetooth/bluez5-util.h | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/modules/bluetooth/bluez5-util.c b/src/modules/bluetooth/bluez5-util.c index 1f0ecfdc7..a2179644e 100644 --- a/src/modules/bluetooth/bluez5-util.c +++ b/src/modules/bluetooth/bluez5-util.c @@ -140,6 +140,7 @@ struct pa_bluetooth_discovery { pa_hashmap *adapters; pa_hashmap *devices; pa_hashmap *transports; + pa_bluetooth_profile_status_t profiles_status[PA_BLUETOOTH_PROFILE_COUNT]; int headset_backend; pa_bluetooth_backend *ofono_backend, *native_backend; @@ -191,6 +192,14 @@ static const char *check_variant_property(DBusMessageIter *i) { return key; } +pa_bluetooth_profile_status_t profile_status_get(pa_bluetooth_discovery *y, pa_bluetooth_profile_t profile) { + return y->profiles_status[profile]; +} + +void profile_status_set(pa_bluetooth_discovery *y, pa_bluetooth_profile_t profile, pa_bluetooth_profile_status_t status) { + y->profiles_status[profile] = status; +} + pa_bluetooth_transport *pa_bluetooth_transport_new(pa_bluetooth_device *d, const char *owner, const char *path, pa_bluetooth_profile_t p, const uint8_t *config, size_t size) { pa_bluetooth_transport *t; diff --git a/src/modules/bluetooth/bluez5-util.h b/src/modules/bluetooth/bluez5-util.h index 4885446f3..6ff4069e5 100644 --- a/src/modules/bluetooth/bluez5-util.h +++ b/src/modules/bluetooth/bluez5-util.h @@ -84,6 +84,13 @@ typedef enum profile { } pa_bluetooth_profile_t; #define PA_BLUETOOTH_PROFILE_COUNT PA_BLUETOOTH_PROFILE_OFF +typedef enum pa_bluetooth_profile_status { + PA_BLUETOOTH_PROFILE_STATUS_INACTIVE, + PA_BLUETOOTH_PROFILE_STATUS_ACTIVE, + PA_BLUETOOTH_PROFILE_STATUS_REGISTERING, + PA_BLUETOOTH_PROFILE_STATUS_REGISTERED +} pa_bluetooth_profile_status_t; + typedef enum pa_bluetooth_transport_state { PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED, PA_BLUETOOTH_TRANSPORT_STATE_IDLE, @@ -192,6 +199,9 @@ static inline void pa_bluetooth_native_backend_free(pa_bluetooth_backend *b) {} static inline void pa_bluetooth_native_backend_enable_shared_profiles(pa_bluetooth_backend *b, bool enable) {} #endif +pa_bluetooth_profile_status_t profile_status_get(pa_bluetooth_discovery *y, pa_bluetooth_profile_t profile); +void profile_status_set(pa_bluetooth_discovery *y, pa_bluetooth_profile_t profile, pa_bluetooth_profile_status_t status); + pa_bluetooth_transport *pa_bluetooth_transport_new(pa_bluetooth_device *d, const char *owner, const char *path, pa_bluetooth_profile_t p, const uint8_t *config, size_t size);