summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2010-10-23 18:29:45 +0200
committerAlon Levy <alevy@redhat.com>2010-12-07 13:31:31 +0200
commit757686384fc47746891b6280b9f27404420c8dea (patch)
tree5361af542a1c49ae34860c6e721d1998e1c26131
parenta2afcde061a488713119e03774915ea752757824 (diff)
downloadspice-757686384fc47746891b6280b9f27404420c8dea.tar.gz
spice-757686384fc47746891b6280b9f27404420c8dea.tar.xz
spice-757686384fc47746891b6280b9f27404420c8dea.zip
smartcard: client: add keyboard shortcuts for remove/insert virtual card
-rw-r--r--client/application.cpp20
-rw-r--r--client/smartcard_channel.cpp32
-rw-r--r--client/smartcard_channel.h2
3 files changed, 54 insertions, 0 deletions
diff --git a/client/application.cpp b/client/application.cpp
index ae197857..a484bbc7 100644
--- a/client/application.cpp
+++ b/client/application.cpp
@@ -339,6 +339,10 @@ enum AppCommands {
#ifdef USE_GUI
APP_CMD_SHOW_GUI,
#endif // USE_GUI
+#ifdef USE_SMARTCARD
+ APP_CMD_SMARTCARD_INSERT,
+ APP_CMD_SMARTCARD_REMOVE,
+#endif
APP_CMD_EXTERNAL_BEGIN = 0x400,
APP_CMD_EXTERNAL_END = 0x800,
};
@@ -391,6 +395,10 @@ Application::Application()
#ifdef USE_GUI
_commands_map["show-gui"] = APP_CMD_SHOW_GUI;
#endif // USE_GUI
+#ifdef USE_SMARTCARD
+ _commands_map["smartcard-insert"] = APP_CMD_SMARTCARD_INSERT;
+ _commands_map["smartcard-remove"] = APP_CMD_SMARTCARD_REMOVE;
+#endif
_canvas_types.resize(1);
#ifdef WIN32
@@ -413,6 +421,10 @@ Application::Application()
#ifdef USE_GUI
",show-gui=shift+f7"
#endif // USE_GUI
+#ifdef USE_SMARTCARD
+ ",smartcard-insert=shift+f8"
+ ",smartcard-remove=shift+f9"
+#endif
, _commands_map));
_hot_keys = parser->get();
@@ -1007,6 +1019,14 @@ void Application::do_command(int command)
show_gui();
break;
#endif // USE_GUI
+#ifdef USE_SMARTCARD
+ case APP_CMD_SMARTCARD_INSERT:
+ virtual_card_insert();
+ break;
+ case APP_CMD_SMARTCARD_REMOVE:
+ virtual_card_remove();
+ break;
+#endif
default:
AppMenuItemMap::iterator iter = _app_menu_items.find(command);
ASSERT(iter != _app_menu_items.end());
diff --git a/client/smartcard_channel.cpp b/client/smartcard_channel.cpp
index d585c9a5..994671f8 100644
--- a/client/smartcard_channel.cpp
+++ b/client/smartcard_channel.cpp
@@ -228,6 +228,38 @@ void SmartCardChannel::cac_card_events_thread_main()
}
}
+void virtual_card_insert()
+{
+ if (g_smartcard_channel == NULL) {
+ return;
+ }
+ g_smartcard_channel->virtual_card_insert();
+}
+
+void SmartCardChannel::virtual_card_insert()
+{
+ if (_readers_by_id.size() == 0) {
+ return;
+ }
+ vcard_emul_force_card_insert(_readers_by_id.begin()->second->vreader);
+}
+
+void virtual_card_remove()
+{
+ if (g_smartcard_channel == NULL) {
+ return;
+ }
+ g_smartcard_channel->virtual_card_remove();
+}
+
+void SmartCardChannel::virtual_card_remove()
+{
+ if (_readers_by_id.size() == 0) {
+ return;
+ }
+ vcard_emul_force_card_remove(_readers_by_id.begin()->second->vreader);
+}
+
#define CERTIFICATES_DEFAULT_DB "/etc/pki/nssdb"
#define CERTIFICATES_ARGS_TEMPLATE "db=\"%s\" use_hw=no soft=(,Virtual Card,CAC,,%s,%s,%s)"
diff --git a/client/smartcard_channel.h b/client/smartcard_channel.h
index ee0d0d08..60c6db5c 100644
--- a/client/smartcard_channel.h
+++ b/client/smartcard_channel.h
@@ -92,6 +92,8 @@ public:
SmartCardChannel(RedClient& client, uint32_t id);
void handle_smartcard_data(RedPeer::InMessage* message);
+ void virtual_card_remove();
+ void virtual_card_insert();
static ChannelFactory& Factory();
protected:
virtual void on_connect();