bluez: pass NMBluetoothCapabilities to nm_bluez_device
Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
@@ -45,6 +45,7 @@ typedef struct {
|
||||
|
||||
gboolean initialized;
|
||||
gboolean usable;
|
||||
NMBluetoothCapabilities connection_bt_type;
|
||||
|
||||
char *address;
|
||||
guint8 bin_address[ETH_ALEN];
|
||||
@@ -252,14 +253,16 @@ cp_connections_loaded (NMConnectionProvider *provider, NMBluezDevice *self)
|
||||
/***********************************************************/
|
||||
|
||||
void
|
||||
nm_bluez_device_call_disconnect (NMBluezDevice *self, gboolean dun)
|
||||
nm_bluez_device_call_disconnect (NMBluezDevice *self)
|
||||
{
|
||||
NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self);
|
||||
|
||||
g_return_if_fail (priv->connection_bt_type == NM_BT_CAPABILITY_NAP || priv->connection_bt_type == NM_BT_CAPABILITY_DUN);
|
||||
|
||||
if (!priv->type_proxy)
|
||||
return;
|
||||
|
||||
if (dun) {
|
||||
if (priv->connection_bt_type == NM_BT_CAPABILITY_DUN) {
|
||||
/* Don't ever pass NULL through dbus; rfcomm_iface
|
||||
* might happen to be NULL for some reason.
|
||||
*/
|
||||
@@ -273,6 +276,7 @@ nm_bluez_device_call_disconnect (NMBluezDevice *self, gboolean dun)
|
||||
}
|
||||
|
||||
g_clear_object (&priv->type_proxy);
|
||||
priv->connection_bt_type = NM_BT_CAPABILITY_NONE;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -306,7 +310,7 @@ bluez_connect_cb (DBusGProxy *proxy,
|
||||
|
||||
void
|
||||
nm_bluez_device_connect_async (NMBluezDevice *self,
|
||||
gboolean dun,
|
||||
NMBluetoothCapabilities connection_bt_type,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
@@ -314,6 +318,8 @@ nm_bluez_device_connect_async (NMBluezDevice *self,
|
||||
NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self);
|
||||
DBusGConnection *connection;
|
||||
|
||||
g_return_if_fail (connection_bt_type == NM_BT_CAPABILITY_NAP || connection_bt_type == NM_BT_CAPABILITY_DUN);
|
||||
|
||||
connection = nm_dbus_manager_get_connection (nm_dbus_manager_get ());
|
||||
|
||||
simple = g_simple_async_result_new (G_OBJECT (self),
|
||||
@@ -324,7 +330,7 @@ nm_bluez_device_connect_async (NMBluezDevice *self,
|
||||
priv->type_proxy = dbus_g_proxy_new_for_name (connection,
|
||||
BLUEZ_SERVICE,
|
||||
priv->path,
|
||||
dun ? BLUEZ_SERIAL_INTERFACE : BLUEZ_NETWORK_INTERFACE);
|
||||
connection_bt_type == NM_BT_CAPABILITY_DUN ? BLUEZ_SERIAL_INTERFACE : BLUEZ_NETWORK_INTERFACE);
|
||||
if (!priv->type_proxy)
|
||||
g_simple_async_report_error_in_idle (G_OBJECT (self),
|
||||
callback,
|
||||
@@ -332,14 +338,17 @@ nm_bluez_device_connect_async (NMBluezDevice *self,
|
||||
G_IO_ERROR,
|
||||
G_IO_ERROR_FAILED,
|
||||
"Unable to create proxy");
|
||||
else
|
||||
else {
|
||||
dbus_g_proxy_begin_call_with_timeout (priv->type_proxy, "Connect",
|
||||
bluez_connect_cb,
|
||||
simple,
|
||||
NULL,
|
||||
20000,
|
||||
G_TYPE_STRING, dun ? BLUETOOTH_CONNECT_DUN : BLUETOOTH_CONNECT_NAP,
|
||||
G_TYPE_STRING,
|
||||
connection_bt_type == NM_BT_CAPABILITY_DUN ? BLUETOOTH_CONNECT_DUN : BLUETOOTH_CONNECT_NAP,
|
||||
G_TYPE_INVALID);
|
||||
priv->connection_bt_type = connection_bt_type;
|
||||
}
|
||||
}
|
||||
|
||||
const char *
|
||||
|
@@ -80,7 +80,7 @@ gboolean nm_bluez_device_get_connected (NMBluezDevice *self);
|
||||
|
||||
void
|
||||
nm_bluez_device_connect_async (NMBluezDevice *self,
|
||||
gboolean dun,
|
||||
NMBluetoothCapabilities connection_bt_type,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
@@ -90,8 +90,7 @@ nm_bluez_device_connect_finish (NMBluezDevice *self,
|
||||
GError **error);
|
||||
|
||||
void
|
||||
nm_bluez_device_call_disconnect (NMBluezDevice *self,
|
||||
gboolean dun);
|
||||
nm_bluez_device_call_disconnect (NMBluezDevice *self);
|
||||
|
||||
#endif /* NM_BLUEZ_DEVICE_H */
|
||||
|
||||
|
@@ -808,7 +808,6 @@ static NMActStageReturn
|
||||
act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
|
||||
{
|
||||
NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device);
|
||||
gboolean dun = FALSE;
|
||||
NMConnection *connection;
|
||||
|
||||
connection = nm_device_get_connection (device);
|
||||
@@ -824,18 +823,13 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
|
||||
return NM_ACT_STAGE_RETURN_FAILURE;
|
||||
}
|
||||
|
||||
if (priv->bt_type == NM_BT_CAPABILITY_DUN)
|
||||
dun = TRUE;
|
||||
else if (priv->bt_type == NM_BT_CAPABILITY_NAP)
|
||||
dun = FALSE;
|
||||
else
|
||||
g_assert_not_reached ();
|
||||
|
||||
nm_log_dbg (LOGD_BT, "(%s): requesting connection to the device",
|
||||
nm_device_get_iface (device));
|
||||
|
||||
/* Connect to the BT device */
|
||||
nm_bluez_device_connect_async (priv->bt_device, dun, bluez_connect_cb, device);
|
||||
nm_bluez_device_connect_async (priv->bt_device,
|
||||
priv->bt_type & (NM_BT_CAPABILITY_DUN | NM_BT_CAPABILITY_NAP),
|
||||
bluez_connect_cb, device);
|
||||
|
||||
if (priv->timeout_id)
|
||||
g_source_remove (priv->timeout_id);
|
||||
@@ -910,7 +904,7 @@ deactivate (NMDevice *device)
|
||||
}
|
||||
}
|
||||
|
||||
nm_bluez_device_call_disconnect (priv->bt_device, dun);
|
||||
nm_bluez_device_call_disconnect (priv->bt_device);
|
||||
|
||||
if (priv->timeout_id) {
|
||||
g_source_remove (priv->timeout_id);
|
||||
|
Reference in New Issue
Block a user