示例#1
0
static void smartcard_remove_reader(SmartCardChannel *smartcard_channel, reader_id_t reader_id)
{
    SpiceCharDeviceInstance *char_device = smartcard_readers_get(reader_id);
    SmartCardDeviceState *state;

    if (char_device == NULL) {
        smartcard_push_error(smartcard_channel, reader_id,
            VSC_GENERAL_ERROR);
        return;
    }

    state = SPICE_CONTAINEROF(char_device->st, SmartCardDeviceState, base);
    if (state->attached == FALSE) {
        smartcard_push_error(smartcard_channel, reader_id,
            VSC_GENERAL_ERROR);
        return;
    }
    smartcard_char_device_detach(char_device, smartcard_channel);
}
示例#2
0
static void smartcard_remove_reader(SmartCardChannelClient *scc, uint32_t reader_id)
{
    SpiceCharDeviceInstance *char_device = smartcard_readers_get(reader_id);
    SmartCardDeviceState *state;

    if (char_device == NULL) {
        smartcard_push_error(&scc->base, reader_id,
            VSC_GENERAL_ERROR);
        return;
    }

    state = spice_char_device_state_opaque_get(char_device->st);
    if (state->reader_added == FALSE) {
        smartcard_push_error(&scc->base, reader_id,
            VSC_GENERAL_ERROR);
        return;
    }
    spice_assert(scc->smartcard_state == state);
    smartcard_char_device_notify_reader_remove(state);
}
示例#3
0
static void smartcard_add_reader(SmartCardChannel *smartcard_channel, uint8_t *name)
{
    // TODO - save name somewhere
    SpiceCharDeviceInstance *char_device =
            smartcard_readers_get_unattached();
    SmartCardDeviceState *state;

    if (char_device != NULL) {
        state = SPICE_CONTAINEROF(char_device->st, SmartCardDeviceState, base);
        smartcard_char_device_attach(char_device, smartcard_channel);
        smartcard_push_reader_add_response(smartcard_channel, state->reader_id);
    } else {
        smartcard_push_error(smartcard_channel, VSCARD_UNDEFINED_READER_ID,
            VSC_CANNOT_ADD_MORE_READERS);
    }
}
示例#4
0
static void smartcard_add_reader(SmartCardChannelClient *scc, uint8_t *name)
{
    if (!scc->smartcard_state) { /* we already tried to attach a reader to the client
                                    when it connected */
        SpiceCharDeviceInstance *char_device = smartcard_readers_get_unattached();

        if (!char_device) {
            smartcard_push_error(&scc->base, VSCARD_UNDEFINED_READER_ID,
                                VSC_CANNOT_ADD_MORE_READERS);
            return;
        }
        smartcard_char_device_attach_client(char_device, scc);
    }
    smartcard_char_device_notify_reader_add(scc->smartcard_state);
    // The device sends a VSC_Error message, we will let it through, no
    // need to send our own. We already set the correct reader_id, from
    // our SmartCardDeviceState.
}