## Spice Smartcard Manager

Spice Smartcard Manager — smartcard management

## Stability Level

Stable, unless otherwise indicated

## Functions

SpiceSmartcardManager * | spice_smartcard_manager_get ()
GList * | spice_smartcard_manager_get_readers ()
gboolean | spice_smartcard_manager_insert_card ()
gboolean | spice_smartcard_manager_remove_card ()
gboolean | spice_smartcard_reader_is_software ()
gboolean | spice_smartcard_reader_insert_card ()
gboolean | spice_smartcard_reader_remove_card ()

## Signals

void | card-inserted | Run First
void | card-removed | Run First
void | reader-added | Run First
void | reader-removed | Run First

## Types and Values

struct | SpiceSmartcardManager
struct | SpiceSmartcardManagerClass
| SpiceSmartcardReader

## Object Hierarchy

        GObject
        ╰── SpiceSmartcardManager

## Includes

    #include <spice-client.h>

## Description

SpiceSmartcardManager monitors smartcard reader plugging/unplugging, and smartcard insertions/removals. It also provides methods to handle software smartcards (to emulate a smartcard reader/smartcard on the guest using 3 certificates available to the client).

## Functions

### spice_smartcard_manager_get ()

    SpiceSmartcardManager *
    spice_smartcard_manager_get (void);

SpiceSmartcardManager is a singleton, use this function to get a pointer to it. A new SpiceSmartcardManager instance will be created the first time this function is called

#### Returns

a weak reference to the SpiceSmartcardManager.

[transfer none]

### spice_smartcard_manager_get_readers ()

    GList *
    spice_smartcard_manager_get_readers (SpiceSmartcardManager *manager);

Gets the list of smartcard readers that are currently available, they can be either software (emulated) readers, or hardware ones.

#### Parameters

manager | a SpiceSmartcardManager |

#### Returns

a newly allocated list of SpiceSmartcardReader instances, or NULL if none were found. When no longer needed, the list must be freed after unreferencing its elements with `g_boxed_free()`.

[element-type SpiceSmartcardReader][transfer full]

Since: 0.20

### spice_smartcard_manager_insert_card ()

    gboolean
    spice_smartcard_manager_insert_card (SpiceSmartcardManager *manager);

Simulates the insertion of a smartcard in the guest. Valid certificates must have been set in “smartcard-certificates” for software smartcard support to work. At the moment, only one software smartcard reader is supported, that's why there is no parameter to indicate which reader to insert the card in.

#### Parameters

manager | a SpiceSmartcardManager |

#### Returns

TRUE if smartcard insertion was successfully simulated, FALSE if this failed, or if software smartcard support isn't enabled.

Since: 0.20

### spice_smartcard_manager_remove_card ()

    gboolean
    spice_smartcard_manager_remove_card (SpiceSmartcardManager *manager);

Simulates the removal of a smartcard in the guest. At the moment, only one software smartcard reader is supported, that's why there is no parameter to indicate which reader to insert the card in.

#### Parameters

manager | a SpiceSmartcardManager |

#### Returns

TRUE if smartcard removal was successfully simulated, FALSE if this failed, or if software smartcard support isn't enabled.

Since: 0.20

### spice_smartcard_reader_is_software ()

    gboolean
    spice_smartcard_reader_is_software (SpiceSmartcardReader *reader);

Tests if `reader` is a software (emulated) smartcard reader.

#### Parameters

reader | a SpiceSmartcardReader |

#### Returns

TRUE if `reader` is a software (emulated) smartcard reader, FALSE otherwise

### spice_smartcard_reader_insert_card ()

    gboolean
    spice_smartcard_reader_insert_card (SpiceSmartcardReader *reader);

Simulates insertion of a smartcard in the software smartcard reader `reader` . If `reader` is not a software smartcard reader, FALSE will be returned.

#### Parameters

reader | a SpiceSmartcardReader |

#### Returns

TRUE if insertion of a card was successfully simulated, FALSE otherwise

### spice_smartcard_reader_remove_card ()

    gboolean
    spice_smartcard_reader_remove_card (SpiceSmartcardReader *reader);

Simulates removal of a smartcard from the software smartcard reader `reader` . If `reader` is not a software smartcard reader, FALSE will be returned.

#### Parameters

reader | a SpiceSmartcardReader |

#### Returns

TRUE if removal of a card was successfully simulated, FALSE otherwise

## Types and Values

### struct SpiceSmartcardManager

    struct SpiceSmartcardManager;

The SpiceSmartcardManager struct is opaque and should not be accessed directly.

### struct SpiceSmartcardManagerClass

    struct SpiceSmartcardManagerClass {
        GObjectClass parent_class;
        /* signals */
        void (*reader_added)(SpiceSmartcardManager *manager, SpiceSmartcardReader *reader);
        void (*reader_removed)(SpiceSmartcardManager *manager, SpiceSmartcardReader *reader);
        void (*card_inserted)(SpiceSmartcardManager *manager, SpiceSmartcardReader *reader);
        void (*card_removed)(SpiceSmartcardManager *manager, SpiceSmartcardReader *reader );
    };

Class structure for SpiceSmartcardManager.

#### Members

`reader_added` () | Signal class handler for the “reader_added” signal. |
`reader_removed` () | Signal class handler for the “reader_removed” signal. |
`card_inserted` () | Signal class handler for the “card_inserted” signal. |
`card_removed` () | Signal class handler for the “card_removed” signal. |

### SpiceSmartcardReader

    typedef struct _SpiceSmartcardReader SpiceSmartcardReader;

The SpiceSmartcardReader struct is opaque and cannot be accessed directly.

## Signal Details

### The `“card-inserted”` signal

    void
    user_function (SpiceSmartcardManager *manager,
                   VReader               *vreader,
                   gpointer               user_data)

The “card-inserted” signal is emitted whenever a smartcard is inserted in a reader

#### Parameters

manager | the SpiceSmartcardManager that emitted the signal |
vreader | VReader boxed object corresponding to the reader a new card was inserted in |
user_data | user data set when the signal handler was connected. |

Flags: Run First

### The `“card-removed”` signal

    void
    user_function (SpiceSmartcardManager *manager,
                   VReader               *vreader,
                   gpointer               user_data)

The “card-removed” signal is emitted whenever a smartcard was removed from a reader.

#### Parameters

manager | the SpiceSmartcardManager that emitted the signal |
vreader | VReader boxed object corresponding to the reader a card was removed from |
user_data | user data set when the signal handler was connected. |

Flags: Run First

### The `“reader-added”` signal

    void
    user_function (SpiceSmartcardManager *manager,
                   VReader               *vreader,
                   gpointer               user_data)

The “reader-added” signal is emitted whenever a new smartcard reader (software or hardware) has been plugged in.

#### Parameters

manager | the SpiceSmartcardManager that emitted the signal |
vreader | VReader boxed object corresponding to the added reader |
user_data | user data set when the signal handler was connected. |

Flags: Run First

### The `“reader-removed”` signal

    void
    user_function (SpiceSmartcardManager *manager,
                   VReader               *vreader,
                   gpointer               user_data)

The “reader-removed” signal is emitted whenever a smartcard reader (software or hardware) has been removed.

#### Parameters

manager | the SpiceSmartcardManager that emitted the signal |
vreader | VReader boxed object corresponding to the removed reader |
user_data | user data set when the signal handler was connected. |

Flags: Run First