diff options
author | Alon Levy <alevy@redhat.com> | 2011-06-29 14:13:16 +0200 |
---|---|---|
committer | Alon Levy <alevy@redhat.com> | 2011-07-05 14:04:36 +0200 |
commit | 4efa6c16c243ca8f26b1745b0ebdb392cb248cd6 (patch) | |
tree | bafd369d39483001c46351ce36e617816a7c598b | |
parent | ce1d98d3c9697f77f986c875016a2fede006c9dc (diff) |
server/smartcard: register channel only when hardware is available
-rw-r--r-- | server/reds.c | 4 | ||||
-rw-r--r-- | server/smartcard.c | 11 |
2 files changed, 9 insertions, 6 deletions
diff --git a/server/reds.c b/server/reds.c index d01c104..eb9c32a 100644 --- a/server/reds.c +++ b/server/reds.c @@ -3522,10 +3522,6 @@ static int do_spice_init(SpiceCoreInterface *core_interface) reds->main_channel = NULL; inputs_init(); -#ifdef USE_SMARTCARD - smartcard_channel_init(); -#endif - reds->mouse_mode = SPICE_MOUSE_MODE_SERVER; atexit(reds_exit); return 0; diff --git a/server/smartcard.c b/server/smartcard.c index f948e5b..49bf3cb 100644 --- a/server/smartcard.c +++ b/server/smartcard.c @@ -81,6 +81,7 @@ static void smartcard_on_message_from_device( SmartCardChannel *smartcard_channel, VSCMsgHeader *vheader); static SmartCardDeviceState* smartcard_device_state_new(); static void smartcard_device_state_free(SmartCardDeviceState* st); +static void smartcard_register_channel(void); void smartcard_char_device_wakeup(SpiceCharDeviceInstance *sin) { @@ -166,6 +167,7 @@ static int smartcard_char_device_add_to_readers(SpiceCharDeviceInstance *char_de } state->reader_id = g_smartcard_readers.num; g_smartcard_readers.sin[g_smartcard_readers.num++] = char_device; + smartcard_register_channel(); return 0; } @@ -534,10 +536,16 @@ static void smartcard_migrate(Channel *channel) { } -void smartcard_channel_init(void) +static void smartcard_register_channel(void) { Channel *channel; + static int registered = 0; + if (registered) { + return; + } + red_printf("registering smartcard channel"); + registered = 1; channel = spice_new0(Channel, 1); channel->type = SPICE_CHANNEL_SMARTCARD; channel->link = smartcard_link; @@ -545,4 +553,3 @@ void smartcard_channel_init(void) channel->migrate = smartcard_migrate; reds_register_channel(channel); } - |