[Spice-commits] 2 commits - gtk/channel-smartcard.c
Marc-André Lureau
elmarco at kemper.freedesktop.org
Wed Mar 25 03:58:05 PDT 2015
gtk/channel-smartcard.c | 40 +++++++++++++++++++++++++++++++---------
1 file changed, 31 insertions(+), 9 deletions(-)
New commits:
commit f047ffdd174ad076f981a96d40099cec3a2e302d
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Wed Mar 25 00:06:33 2015 +0100
smartcard: add reader and cards on channel up
The smartcard manager reports reader/card events on insertion and
removal. If a smartcard channel is created after those events, the
channel state will not be in sync with the current reader/card state.
Sync the state when the channel is up.
Fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=1205171
diff --git a/gtk/channel-smartcard.c b/gtk/channel-smartcard.c
index cc3ae3b..0ab7213 100644
--- a/gtk/channel-smartcard.c
+++ b/gtk/channel-smartcard.c
@@ -400,6 +400,10 @@ static void reader_added_cb(SpiceSmartcardManager *manager, VReader *reader,
SpiceSmartcardChannel *channel = SPICE_SMARTCARD_CHANNEL(user_data);
const char *reader_name = vreader_get_name(reader);
+ if (vreader_get_id(reader) != -1 ||
+ g_list_find(channel->priv->pending_reader_additions, reader))
+ return;
+
channel->priv->pending_reader_additions =
g_list_append(channel->priv->pending_reader_additions, reader);
@@ -452,6 +456,8 @@ static void spice_smartcard_channel_up_cb(GObject *source_object,
gpointer user_data)
{
SpiceChannel *channel = SPICE_CHANNEL(user_data);
+ SpiceSmartcardManager *manager = spice_smartcard_manager_get();
+ GList *l, *list = NULL;
GError *error = NULL;
g_return_if_fail(channel != NULL);
@@ -459,9 +465,25 @@ static void spice_smartcard_channel_up_cb(GObject *source_object,
spice_smartcard_manager_init_finish(SPICE_SESSION(source_object),
res, &error);
- if (error)
+ if (error) {
g_warning("%s", error->message);
+ goto end;
+ }
+
+ list = spice_smartcard_manager_get_readers(manager);
+ for (l = list; l != NULL; l = l->next) {
+ VReader *reader = l->data;
+ gboolean has_card = vreader_card_is_present(reader) == VREADER_OK;
+
+ reader_added_cb(manager, reader, channel);
+ if (has_card)
+ card_inserted_cb(manager, reader, channel);
+
+ g_boxed_free(SPICE_TYPE_SMARTCARD_READER, reader);
+ }
+end:
+ g_list_free(list);
g_clear_error(&error);
}
commit 9acea56987506f1d47d5bc933e824dc5b2f7654e
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date: Tue Mar 24 18:57:53 2015 +0100
smartcard: connect object signal handlers with spice helper
The smartcard manager may outlive the smartcard channels. Make sure the
channel handlers are disconnected when the channel is free by using
spice_g_signal_connect_object() helper. This fixes crashes when
dispatching smartcard events on deleted channels.
Related bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1205171
diff --git a/gtk/channel-smartcard.c b/gtk/channel-smartcard.c
index 8588ae0..cc3ae3b 100644
--- a/gtk/channel-smartcard.c
+++ b/gtk/channel-smartcard.c
@@ -140,14 +140,14 @@ static void spice_smartcard_channel_constructed(GObject *object)
SpiceSmartcardChannel *channel = SPICE_SMARTCARD_CHANNEL(object);
SpiceSmartcardManager *manager = spice_smartcard_manager_get();
- g_signal_connect(G_OBJECT(manager), "reader-added",
- (GCallback)reader_added_cb, channel);
- g_signal_connect(G_OBJECT(manager), "reader-removed",
- (GCallback)reader_removed_cb, channel);
- g_signal_connect(G_OBJECT(manager), "card-inserted",
- (GCallback)card_inserted_cb, channel);
- g_signal_connect(G_OBJECT(manager), "card-removed",
- (GCallback)card_removed_cb, channel);
+ spice_g_signal_connect_object(G_OBJECT(manager), "reader-added",
+ (GCallback)reader_added_cb, channel, 0);
+ spice_g_signal_connect_object(G_OBJECT(manager), "reader-removed",
+ (GCallback)reader_removed_cb, channel, 0);
+ spice_g_signal_connect_object(G_OBJECT(manager), "card-inserted",
+ (GCallback)card_inserted_cb, channel, 0);
+ spice_g_signal_connect_object(G_OBJECT(manager), "card-removed",
+ (GCallback)card_removed_cb, channel, 0);
}
#endif
More information about the Spice-commits
mailing list