SpiceClientGLib.UsbDeviceManager

g GObject.GInterface GObject.GInterface Gio.Initable Gio.Initable GObject.GInterface->Gio.Initable GObject.Object GObject.Object SpiceClientGLib.UsbDeviceManager SpiceClientGLib.UsbDeviceManager GObject.Object->SpiceClientGLib.UsbDeviceManager Gio.Initable->SpiceClientGLib.UsbDeviceManager

Subclasses:

None

Methods

Inherited:

GObject.Object (37), Gio.Initable (2)

Structs:

GObject.ObjectClass (5)

class

get (session)

allocate_device_for_file_descriptor (file_descriptor)

can_redirect_device (device)

connect_device_async (device, cancellable, callback, *user_data)

connect_device_finish (res)

create_shared_cd_device (filename)

disconnect_device (device)

disconnect_device_async (device, cancellable, callback, *user_data)

disconnect_device_finish (res)

get_devices ()

get_devices_with_filter (filter)

is_device_connected (device)

is_device_shared_cd (device)

is_redirecting ()

Virtual Methods

Inherited:

GObject.Object (7), Gio.Initable (1)

do_auto_connect_failed (device, error)

do_device_added (device)

do_device_error (device, error)

do_device_removed (device)

Properties

Name

Type

Flags

Short Description

auto-connect

bool

r/w

Auto connect plugged in USB devices

auto-connect-filter

str

r/w/c

Filter determining which USB devices to auto connect

free-channels

int

r

The number of available channels for redirecting USB devices

redirect-on-connect

str

r/w

Filter selecting USB devices to redirect on connect

session

SpiceClientGLib.Session

r/w/co

SpiceClientGLib.Session

Signals

Inherited:

GObject.Object (1)

Name

Short Description

auto-connect-failed

The SpiceClientGLib.UsbDeviceManager ::auto-connect-failed signal is emitted whenever the auto-connect property is true, and a newly plugged in device could not be auto-connected.

device-added

The SpiceClientGLib.UsbDeviceManager ::device-added signal is emitted whenever a new USB device has been plugged in.

device-error

The SpiceClientGLib.UsbDeviceManager ::device-error signal is emitted whenever an error happens which causes a device to no longer be available to the guest.

device-removed

The SpiceClientGLib.UsbDeviceManager ::device-removed signal is emitted whenever an USB device has been removed.

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

Class Details

class SpiceClientGLib.UsbDeviceManager(**kwargs)
Bases:

GObject.Object, Gio.Initable

Abstract:

No

Structure:

SpiceClientGLib.UsbDeviceManagerClass

The SpiceClientGLib.UsbDeviceManager struct is opaque and should not be accessed directly.

classmethod get(session)
Parameters:

session (SpiceClientGLib.Session) – SpiceClientGLib.Session for which to get the SpiceClientGLib.UsbDeviceManager

Raises:

GLib.Error

Returns:

a weak reference to the SpiceClientGLib.UsbDeviceManager associated with the passed in SpiceClientGLib.Session

Return type:

SpiceClientGLib.UsbDeviceManager

Gets the SpiceClientGLib.UsbDeviceManager associated with the passed in SpiceClientGLib.Session. A new SpiceClientGLib.UsbDeviceManager instance will be created the first time this function is called for a certain SpiceClientGLib.Session.

Note that this function returns a weak reference, which should not be used after the SpiceClientGLib.Session itself has been unref-ed by the caller.

allocate_device_for_file_descriptor(file_descriptor)
Parameters:

file_descriptor (int) – an open file descriptor for the USB device.

Raises:

GLib.Error

Returns:

an allocated SpiceClientGLib.UsbDevice instance or None in case of failure.

Return type:

SpiceClientGLib.UsbDevice or None

Allocates a SpiceClientGLib.UsbDevice instance for the specified file descriptor.

New in version 0.40.

can_redirect_device(device)
Parameters:

device (SpiceClientGLib.UsbDevice) – a SpiceClientGLib.UsbDevice to disconnect

Raises:

GLib.Error

Returns:

True if device can be redirected

Return type:

bool

Checks whether it is possible to redirect the device.

connect_device_async(device, cancellable, callback, *user_data)
Parameters:

Asynchronously connects the device. When completed, callback will be called. Then it is possible to call SpiceClientGLib.UsbDeviceManager.connect_device_finish() to get the result of the operation.

connect_device_finish(res)
Parameters:

res (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

True if connection is successful

Return type:

bool

Finishes an async operation. See SpiceClientGLib.UsbDeviceManager.connect_device_async().

create_shared_cd_device(filename)
Parameters:

filename (str) – image or device path

Raises:

GLib.Error

Returns:

True if device created successfully

Return type:

bool

Creates a new shared CD device based on a disk image file or a physical CD device.

disconnect_device(device)
Parameters:

device (SpiceClientGLib.UsbDevice) – a SpiceClientGLib.UsbDevice to disconnect

Disconnects the device.

disconnect_device_async(device, cancellable, callback, *user_data)
Parameters:

Asynchronously disconnects the device. When completed, callback will be called. Then it is possible to call SpiceClientGLib.UsbDeviceManager.disconnect_device_finish() to get the result of the operation.

New in version 0.32.

disconnect_device_finish(res)
Parameters:

res (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

True if disconnection is successful

Return type:

bool

Finishes an async operation. See SpiceClientGLib.UsbDeviceManager.disconnect_device_async().

get_devices()
Returns:

a GLib.PtrArray array of SpiceClientGLib.UsbDevice

Return type:

[SpiceClientGLib.UsbDevice]

Finds devices associated with the self

get_devices_with_filter(filter)
Parameters:

filter (str or None) – filter string for selecting which devices to return, see SpiceClientGLib.UsbDeviceManager :auto-connect-filter for the filter string format

Returns:

a GLib.PtrArray array of SpiceClientGLib.UsbDevice

Return type:

[SpiceClientGLib.UsbDevice]

Finds devices associated with the self complying with the filter

New in version 0.20.

is_device_connected(device)
Parameters:

device (SpiceClientGLib.UsbDevice) – a SpiceClientGLib.UsbDevice

Returns:

True if device has an associated USB redirection channel

Return type:

bool

Finds if the device is connected.

is_device_shared_cd(device)
Parameters:

device (SpiceClientGLib.UsbDevice) – a SpiceClientGLib.UsbDevice to query

Returns:

True if the device is shared CD

Return type:

bool

Checks whether a device is shared CD.

is_redirecting()
Returns:

True if device redirection negotiation flow is in progress

Return type:

bool

Checks whether a device is being redirected

New in version 0.32.

do_auto_connect_failed(device, error) virtual
Parameters:
do_device_added(device) virtual
Parameters:

device (SpiceClientGLib.UsbDevice) –

do_device_error(device, error) virtual
Parameters:
do_device_removed(device) virtual
Parameters:

device (SpiceClientGLib.UsbDevice) –

Signal Details

SpiceClientGLib.UsbDeviceManager.signals.auto_connect_failed(usb_device_manager, device, error)
Signal Name:

auto-connect-failed

Flags:

RUN_FIRST

Parameters:

The SpiceClientGLib.UsbDeviceManager ::auto-connect-failed signal is emitted whenever the auto-connect property is true, and a newly plugged in device could not be auto-connected.

SpiceClientGLib.UsbDeviceManager.signals.device_added(usb_device_manager, device)
Signal Name:

device-added

Flags:

RUN_FIRST

Parameters:

The SpiceClientGLib.UsbDeviceManager ::device-added signal is emitted whenever a new USB device has been plugged in.

SpiceClientGLib.UsbDeviceManager.signals.device_error(usb_device_manager, device, error)
Signal Name:

device-error

Flags:

RUN_FIRST

Parameters:

The SpiceClientGLib.UsbDeviceManager ::device-error signal is emitted whenever an error happens which causes a device to no longer be available to the guest.

SpiceClientGLib.UsbDeviceManager.signals.device_removed(usb_device_manager, device)
Signal Name:

device-removed

Flags:

RUN_FIRST

Parameters:

The SpiceClientGLib.UsbDeviceManager ::device-removed signal is emitted whenever an USB device has been removed.

Property Details

SpiceClientGLib.UsbDeviceManager.props.auto_connect
Name:

auto-connect

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Set this to True to automatically redirect newly plugged in device.

Note when #SpiceGtkSession’s auto-usbredir property is True, this property is controlled by #SpiceGtkSession.

SpiceClientGLib.UsbDeviceManager.props.auto_connect_filter
Name:

auto-connect-filter

Type:

str

Default Value:

'0x00,-1,-1,-1,0|-1,-1,-1,-1,1'

Flags:

READABLE, WRITABLE, CONSTRUCT

Set a string specifying a filter to use to determine which USB devices to autoconnect when plugged in, a filter consists of one or more rules. Where each rule has the form of:

class,`vendor`,`product`,`version`,`allow`

Use -1 for class/vendor/product/version to accept any value.

And the rules themselves are concatenated like this:

rule1|`rule2`|`rule3`

The default setting filters out HID (class 0x03) USB devices from auto connect and auto connects anything else. Note the explicit allow rule at the end, this is necessary since by default all devices without a matching filter rule will not auto-connect.

Filter strings in this format can be easily created with the RHEV-M USB filter editor tool.

SpiceClientGLib.UsbDeviceManager.props.free_channels
Name:

free-channels

Type:

int

Default Value:

0

Flags:

READABLE

Get the number of available channels for redirecting USB devices.

New in version 0.31.

SpiceClientGLib.UsbDeviceManager.props.redirect_on_connect
Name:

redirect-on-connect

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

Set a string specifying a filter selecting USB devices to automatically redirect after a Spice connection has been established.

See SpiceClientGLib.UsbDeviceManager :auto-connect-filter for the filter string format.

SpiceClientGLib.UsbDeviceManager.props.session
Name:

session

Type:

SpiceClientGLib.Session

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

SpiceClientGLib.Session this SpiceClientGLib.UsbDeviceManager is associated with