## Spice Smartcard Manager Spice Smartcard Manager — smartcard management |

## Stability Level

Stable, unless otherwise indicated

## Synopsis

    #include <smartcard-manager.h>

    struct              SpiceSmartcardManager;
    struct              SpiceSmartcardManagerClass;
                        SpiceSmartcardReader;

    SpiceSmartcardManager * spice_smartcard_manager_get     (void);
    GList *             spice_smartcard_manager_get_readers (SpiceSmartcardManager *manager);
    gboolean            spice_smartcard_manager_insert_card (SpiceSmartcardManager *manager);
    gboolean            spice_smartcard_manager_remove_card (SpiceSmartcardManager *manager);

    gboolean            spice_smartcard_reader_is_software  (SpiceSmartcardReader *reader);
    gboolean            spice_smartcard_reader_insert_card  (SpiceSmartcardReader *reader);
    gboolean            spice_smartcard_reader_remove_card  (SpiceSmartcardReader *reader);

## Object Hierarchy

      GObject
       +----SpiceSmartcardManager

## Signals

      "card-inserted"                                  : Run First
      "card-removed"                                   : Run First
      "reader-added"                                   : Run First
      "reader-removed"                                 : Run First

## 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).

## Details

### struct SpiceSmartcardManager

    struct SpiceSmartcardManager;

### 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 );
    };

### SpiceSmartcardReader

    typedef struct _SpiceSmartcardReader SpiceSmartcardReader;

### 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);

manager: a SpiceSmartcardManager

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

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.

`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.

`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.

`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.

`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.

`reader` : | a SpiceSmartcardReader
Returns : | TRUE if removal of a card was successfully simulated, FALSE otherwise

## Signal Details

### The `"card-inserted"` signal

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

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

`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.

### The `"card-removed"` signal

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

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

`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.

### The `"reader-added"` signal

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

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

`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.

### The `"reader-removed"` signal

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

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

`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.