summaryrefslogtreecommitdiff
path: root/gtk/channel-smartcard.c
diff options
context:
space:
mode:
authorYonit Halperin <yhalperi@redhat.com>2012-08-25 23:20:24 +0300
committerMarc-André Lureau <marcandre.lureau@redhat.com>2012-08-28 18:36:28 +0200
commit8c9834390435058760446e635a969518da0175f8 (patch)
treec74b4302f63d6e97ee1205c7974cef5f5c8bc3ff /gtk/channel-smartcard.c
parent156ef301a0b65a843f648217b90f0dd10d7cb39e (diff)
channel-smartcard: do not attach temporary migration channel to smartcard
During migration, the smartcard channel that belongs to the temporary copied session shouldn't be active.
Diffstat (limited to 'gtk/channel-smartcard.c')
-rw-r--r--gtk/channel-smartcard.c55
1 files changed, 36 insertions, 19 deletions
diff --git a/gtk/channel-smartcard.c b/gtk/channel-smartcard.c
index 6fa4435..41d9554 100644
--- a/gtk/channel-smartcard.c
+++ b/gtk/channel-smartcard.c
@@ -27,6 +27,7 @@
#include "spice-channel-priv.h"
#include "smartcard-manager.h"
#include "smartcard-manager-priv.h"
+#include "spice-session-priv.h"
/**
* SECTION:channel-smartcard
@@ -120,28 +121,39 @@ static void spice_smartcard_channel_init(SpiceSmartcardChannel *channel)
priv->message_queue = g_queue_new();
#ifdef USE_SMARTCARD
- SpiceSmartcardManager *manager;
-
- manager = spice_smartcard_manager_get();
-
priv->pending_card_insertions =
g_hash_table_new_full(g_direct_hash, g_direct_equal,
(GDestroyNotify)vreader_free, NULL);
priv->pending_reader_removals =
g_hash_table_new_full(g_direct_hash, g_direct_equal,
(GDestroyNotify)vreader_free, NULL);
-
- 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);
#endif
}
+static void spice_smartcard_channel_constructed(GObject *object)
+{
+ SpiceSession *s = spice_channel_get_session(SPICE_CHANNEL(object));
+ SpiceSmartcardChannel *channel = SPICE_SMARTCARD_CHANNEL(object);
+ SpiceSmartcardManager *manager = spice_smartcard_manager_get();
+
+
+ g_return_if_fail(s != NULL);
+ if (!s->priv->migration_copy) {
+ 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);
+ }
+
+ if (G_OBJECT_CLASS(spice_smartcard_channel_parent_class)->constructed)
+ G_OBJECT_CLASS(spice_smartcard_channel_parent_class)->constructed(object);
+
+}
+
static void spice_smartcard_channel_finalize(GObject *obj)
{
SpiceSmartcardChannelPrivate *c = SPICE_SMARTCARD_CHANNEL_GET_PRIVATE(obj);
@@ -200,6 +212,8 @@ static void spice_smartcard_channel_class_init(SpiceSmartcardChannelClass *klass
SpiceChannelClass *channel_class = SPICE_CHANNEL_CLASS(klass);
gobject_class->finalize = spice_smartcard_channel_finalize;
+ gobject_class->constructed = spice_smartcard_channel_constructed;
+
channel_class->handle_msg = spice_smartcard_handle_msg;
channel_class->channel_up = spice_smartcard_channel_up;
channel_class->channel_reset = spice_smartcard_channel_reset;
@@ -448,16 +462,19 @@ static void spice_smartcard_channel_up_cb(GObject *source_object,
gpointer user_data)
{
SpiceChannel *channel = SPICE_CHANNEL(user_data);
- GError *error = NULL;
g_return_if_fail(channel != NULL);
g_return_if_fail(SPICE_IS_SESSION(source_object));
- spice_smartcard_manager_init_finish(SPICE_SESSION(source_object),
- res, &error);
- if (error)
- g_warning("%s", error->message);
- g_clear_error(&error);
+ if (!spice_channel_get_session(SPICE_CHANNEL(channel))->priv->migration_copy) {
+ GError *error = NULL;
+
+ spice_smartcard_manager_init_finish(SPICE_SESSION(source_object),
+ res, &error);
+ if (error)
+ g_warning("%s", error->message);
+ g_clear_error(&error);
+ }
}
static void spice_smartcard_channel_up(SpiceChannel *channel)