mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
bluez5: backend-native: Add a property to select the modem to use
By default no modem is allowed. Property "bluez5.hfphsp-backend-native-modem" can be 'none', 'any' or the modem device string has found in 'Device' property of org.freedesktop.ModemManager1.Modem interface, e.g. for PinePhone "/sys/devices/platform/soc/1c1b000.usb/usb2/2-1".
This commit is contained in:
parent
c4addb102b
commit
fd508d395b
3 changed files with 52 additions and 4 deletions
|
|
@ -2758,7 +2758,7 @@ struct spa_bt_backend *backend_native_new(struct spa_bt_monitor *monitor,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
backend->modemmanager = mm_register(backend->log, backend->conn, &mm_ops, backend);
|
backend->modemmanager = mm_register(backend->log, backend->conn, info, &mm_ops, backend);
|
||||||
backend->upower = upower_register(backend->log, backend->conn, set_battery_level, backend);
|
backend->upower = upower_register(backend->log, backend->conn, set_battery_level, backend);
|
||||||
|
|
||||||
return &backend->this;
|
return &backend->this;
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ struct impl {
|
||||||
struct spa_log *log;
|
struct spa_log *log;
|
||||||
DBusConnection *conn;
|
DBusConnection *conn;
|
||||||
|
|
||||||
|
char *allowed_modem_device;
|
||||||
bool filters_added;
|
bool filters_added;
|
||||||
DBusPendingCall *pending;
|
DBusPendingCall *pending;
|
||||||
DBusPendingCall *voice_pending;
|
DBusPendingCall *voice_pending;
|
||||||
|
|
@ -382,6 +383,32 @@ static DBusHandlerResult mm_parse_interfaces(struct impl *this, DBusMessageIter
|
||||||
if (spa_streq(interface, MM_DBUS_INTERFACE_MODEM)) {
|
if (spa_streq(interface, MM_DBUS_INTERFACE_MODEM)) {
|
||||||
spa_log_debug(this->log, "Found Modem interface %s, path %s", interface, path);
|
spa_log_debug(this->log, "Found Modem interface %s, path %s", interface, path);
|
||||||
if (this->modem.path == NULL) {
|
if (this->modem.path == NULL) {
|
||||||
|
if (this->allowed_modem_device) {
|
||||||
|
DBusMessageIter i;
|
||||||
|
|
||||||
|
dbus_message_iter_recurse(&iface_i, &i);
|
||||||
|
while (dbus_message_iter_get_arg_type(&i) != DBUS_TYPE_INVALID) {
|
||||||
|
DBusMessageIter key_i, value_i;
|
||||||
|
const char *key;
|
||||||
|
|
||||||
|
dbus_message_iter_recurse(&i, &key_i);
|
||||||
|
|
||||||
|
dbus_message_iter_get_basic(&key_i, &key);
|
||||||
|
dbus_message_iter_next(&key_i);
|
||||||
|
dbus_message_iter_recurse(&key_i, &value_i);
|
||||||
|
|
||||||
|
if (spa_streq(key, MM_MODEM_PROPERTY_DEVICE)) {
|
||||||
|
char *device;
|
||||||
|
|
||||||
|
dbus_message_iter_get_basic(&value_i, &device);
|
||||||
|
if (!spa_streq(this->allowed_modem_device, device)) {
|
||||||
|
spa_log_debug(this->log, "Modem not allowed: %s", device);
|
||||||
|
goto next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dbus_message_iter_next(&i);
|
||||||
|
}
|
||||||
|
}
|
||||||
this->modem.path = strdup(path);
|
this->modem.path = strdup(path);
|
||||||
} else if (!spa_streq(this->modem.path, path)) {
|
} else if (!spa_streq(this->modem.path, path)) {
|
||||||
spa_log_debug(this->log, "A modem is already registered");
|
spa_log_debug(this->log, "A modem is already registered");
|
||||||
|
|
@ -1148,13 +1175,27 @@ struct spa_list *mm_get_calls(void *modemmanager)
|
||||||
return &this->call_list;
|
return &this->call_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *mm_register(struct spa_log *log, void *dbus_connection, const struct mm_ops *ops, void *user_data)
|
void *mm_register(struct spa_log *log, void *dbus_connection, const struct spa_dict *info,
|
||||||
|
const struct mm_ops *ops, void *user_data)
|
||||||
{
|
{
|
||||||
struct impl *this;
|
struct impl *this;
|
||||||
|
const char *modem_device_str = NULL;
|
||||||
|
bool modem_device_found = false;
|
||||||
|
|
||||||
spa_assert(log);
|
spa_assert(log);
|
||||||
spa_assert(dbus_connection);
|
spa_assert(dbus_connection);
|
||||||
|
|
||||||
|
if (info) {
|
||||||
|
if ((modem_device_str = spa_dict_lookup(info, "bluez5.hfphsp-backend-native-modem")) != NULL) {
|
||||||
|
if (!spa_streq(modem_device_str, "none"))
|
||||||
|
modem_device_found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!modem_device_found) {
|
||||||
|
spa_log_info(log, "No modem allowed, doesn't link to ModemManager");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
this = calloc(1, sizeof(struct impl));
|
this = calloc(1, sizeof(struct impl));
|
||||||
if (this == NULL)
|
if (this == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -1163,6 +1204,8 @@ void *mm_register(struct spa_log *log, void *dbus_connection, const struct mm_op
|
||||||
this->conn = dbus_connection;
|
this->conn = dbus_connection;
|
||||||
this->ops = ops;
|
this->ops = ops;
|
||||||
this->user_data = user_data;
|
this->user_data = user_data;
|
||||||
|
if (modem_device_str && !spa_streq(modem_device_str, "any"))
|
||||||
|
this->allowed_modem_device = strdup(modem_device_str);
|
||||||
spa_list_init(&this->call_list);
|
spa_list_init(&this->call_list);
|
||||||
|
|
||||||
if (add_filters(this) < 0) {
|
if (add_filters(this) < 0) {
|
||||||
|
|
@ -1209,5 +1252,8 @@ void mm_unregister(void *data)
|
||||||
this->filters_added = false;
|
this->filters_added = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this->allowed_modem_device)
|
||||||
|
free(this->allowed_modem_device);
|
||||||
|
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,8 @@ struct mm_ops {
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef HAVE_BLUEZ_5_BACKEND_NATIVE_MM
|
#ifdef HAVE_BLUEZ_5_BACKEND_NATIVE_MM
|
||||||
void *mm_register(struct spa_log *log, void *dbus_connection, const struct mm_ops *ops, void *user_data);
|
void *mm_register(struct spa_log *log, void *dbus_connection, const struct spa_dict *info,
|
||||||
|
const struct mm_ops *ops, void *user_data);
|
||||||
void mm_unregister(void *data);
|
void mm_unregister(void *data);
|
||||||
bool mm_is_available(void *modemmanager);
|
bool mm_is_available(void *modemmanager);
|
||||||
unsigned int mm_supported_features();
|
unsigned int mm_supported_features();
|
||||||
|
|
@ -98,7 +99,8 @@ bool mm_send_dtmf(void *modemmanager, const char *dtmf, void *user_data, enum cm
|
||||||
const char *mm_get_incoming_call_number(void *modemmanager);
|
const char *mm_get_incoming_call_number(void *modemmanager);
|
||||||
struct spa_list *mm_get_calls(void *modemmanager);
|
struct spa_list *mm_get_calls(void *modemmanager);
|
||||||
#else
|
#else
|
||||||
void *mm_register(struct spa_log *log, void *dbus_connection, const struct mm_ops *ops, void *user_data)
|
void *mm_register(struct spa_log *log, void *dbus_connection, const struct spa_dict *info,
|
||||||
|
const struct mm_ops *ops, void *user_data)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue