[Spice-devel] [PATCH 10/13] smartcard: client: add keyboard shortcuts for remove/insert virtual card

Alon Levy alevy at redhat.com
Mon Dec 6 08:16:03 PST 2010


---
 client/application.cpp       |   20 ++++++++++++++++++++
 client/smartcard_channel.cpp |   32 ++++++++++++++++++++++++++++++++
 client/smartcard_channel.h   |    2 ++
 3 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/client/application.cpp b/client/application.cpp
index ae19785..a484bbc 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 d585c9a..994671f 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 ee0d0d0..60c6db5 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();
-- 
1.7.3.2



More information about the Spice-devel mailing list