summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorJonathon Jongsma <jjongsma@redhat.com>2015-06-03 16:50:04 -0500
committerFrediano Ziglio <fziglio@redhat.com>2015-09-24 16:15:34 +0100
commit94855dab3a457148cc4b9f7504693cd1a19ff3ee (patch)
tree44a9d28a3615efe62fbda0ef9927d6cf8a68b252 /server
parent2ff6793af8a64d8a7d6cd96007bae18ac32d19fc (diff)
Smartcard: store channel in device
Rather than having a single global channel for smartcard devices, store the channel as a private member of the device it is associated with.
Diffstat (limited to 'server')
-rw-r--r--server/smartcard.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/server/smartcard.c b/server/smartcard.c
index 703f080c..1574af1e 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -116,6 +116,7 @@ struct _RedCharDeviceSmartcardPrivate {
SmartCardChannelClient *scc; // client providing the remote card
int reader_added; // has reader_add been sent to the device
+ RedSmartcardChannel *channel;
};
typedef struct MsgItem {
@@ -137,7 +138,6 @@ static int smartcard_char_device_add_to_readers(RedsState *reds, SpiceCharDevice
static MsgItem *smartcard_char_device_on_message_from_device(
SmartCardDeviceState *state, VSCMsgHeader *header);
static SmartCardDeviceState *smartcard_device_state_new(RedsState *reds, SpiceCharDeviceInstance *sin);
-static void smartcard_init(RedsState *reds);
static void smartcard_read_buf_prepare(SmartCardDeviceState *state, VSCMsgHeader *vheader)
{
@@ -254,7 +254,7 @@ static int smartcard_char_device_add_to_readers(RedsState *reds, SpiceCharDevice
}
state->priv->reader_id = g_smartcard_readers.num;
g_smartcard_readers.sin[g_smartcard_readers.num++] = char_device;
- smartcard_init(reds);
+ state->priv->channel = red_smartcard_channel_new(reds);
return 0;
}
@@ -617,18 +617,16 @@ red_smartcard_channel_class_init(RedSmartcardChannelClass *klass)
}
-/* FIXME: remove global */
-RedSmartcardChannel *g_smartcard_channel;
-
-static void smartcard_init(RedsState *reds)
+static void
+red_char_device_smartcard_dispose(GObject *object)
{
- spice_assert(!g_smartcard_channel);
+ RedCharDeviceSmartcard *self = RED_CHAR_DEVICE_SMARTCARD(object);
- g_smartcard_channel = red_smartcard_channel_new(reds);
+ g_clear_object(&self->priv->channel);
+ G_OBJECT_CLASS(red_char_device_smartcard_parent_class)->dispose(object);
}
-
static void
red_char_device_smartcard_finalize(GObject *object)
{
@@ -647,6 +645,7 @@ red_char_device_smartcard_class_init(RedCharDeviceSmartcardClass *klass)
g_type_class_add_private(klass, sizeof (RedCharDeviceSmartcardPrivate));
+ object_class->dispose = red_char_device_smartcard_dispose;
object_class->finalize = red_char_device_smartcard_finalize;
char_dev_class->read_one_msg_from_device = smartcard_read_msg_from_device;