[Spice-devel] [PATCH 4/9] Smartcard: store channel in device
Jonathon Jongsma
jjongsma at redhat.com
Fri Oct 28 17:06:24 UTC 2016
Rather than having a single global channel for smartcard devices, store
the channel as a private member of the device it is associated with.
---
server/smartcard.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/server/smartcard.c b/server/smartcard.c
index 53919c0..b37abb2 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -115,6 +115,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 RedMsgItem {
@@ -136,7 +137,6 @@ static int smartcard_char_device_add_to_readers(RedsState *reds, SpiceCharDevice
static RedMsgItem *smartcard_char_device_on_message_from_device(
RedCharDeviceSmartcard *dev, VSCMsgHeader *header);
static RedCharDeviceSmartcard *smartcard_device_new(RedsState *reds, SpiceCharDeviceInstance *sin);
-static void smartcard_init(RedsState *reds);
static void smartcard_read_buf_prepare(RedCharDeviceSmartcard *dev, VSCMsgHeader *vheader)
{
@@ -254,7 +254,7 @@ static int smartcard_char_device_add_to_readers(RedsState *reds, SpiceCharDevice
}
dev->priv->reader_id = g_smartcard_readers.num;
g_smartcard_readers.sin[g_smartcard_readers.num++] = char_device;
- smartcard_init(reds);
+ dev->priv->channel = red_smartcard_channel_new(reds);
return 0;
}
@@ -602,13 +602,15 @@ red_smartcard_channel_class_init(RedSmartcardChannelClass *klass)
}
-static void smartcard_init(RedsState *reds)
+static void
+red_char_device_smartcard_dispose(GObject *object)
{
- spice_assert(!reds_find_channel(reds, SPICE_CHANNEL_SMARTCARD, 0));
+ RedCharDeviceSmartcard *self = RED_CHAR_DEVICE_SMARTCARD(object);
- 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)
@@ -628,6 +630,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;
--
2.7.4
More information about the Spice-devel
mailing list