summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2013-06-12 22:40:01 +0200
committerChristophe Fergeau <cfergeau@redhat.com>2013-06-24 17:18:28 +0200
commit6885473bf49e7c81cd807983e5d178bd972e8d0c (patch)
tree120ddd5ad3dddb61d7f3eb0131917211e96027d1
parent579be67f26e7569a78c5dace9adbc771182198df (diff)
smartcard: Add methods to act on software readers
Currently, the methods to insert/remove smartcards from a software smartcard reader are global to the SpiceSmartcardManager singleton rather than acting on a SpiceSmartcardreader object. This commit adds insert/remove methods acting on such objects.
-rw-r--r--gtk/map-file2
-rw-r--r--gtk/smartcard-manager.c73
-rw-r--r--gtk/smartcard-manager.h2
-rw-r--r--gtk/spice-glib-sym-file2
4 files changed, 69 insertions, 10 deletions
diff --git a/gtk/map-file b/gtk/map-file
index 558a4d7..0419ecb 100644
--- a/gtk/map-file
+++ b/gtk/map-file
@@ -95,7 +95,9 @@ spice_smartcard_manager_get_type;
spice_smartcard_manager_insert_card;
spice_smartcard_manager_remove_card;
spice_smartcard_reader_get_type;
+spice_smartcard_reader_insert_card;
spice_smartcard_reader_is_software;
+spice_smartcard_reader_remove_card;
spice_usb_device_get_description;
spice_usb_device_get_type;
spice_usb_device_manager_can_redirect_device;
diff --git a/gtk/smartcard-manager.c b/gtk/smartcard-manager.c
index 3b86dfb..366e2dd 100644
--- a/gtk/smartcard-manager.c
+++ b/gtk/smartcard-manager.c
@@ -536,6 +536,50 @@ gboolean spice_smartcard_manager_init_finish(SpiceSession *session,
}
/**
+ * spice_smartcard_reader_insert_card:
+ * @reader: a #SpiceSmartcardReader
+ *
+ * Simulates insertion of a smartcard in the software smartcard reader
+ * @reader. If @reader is not a software smartcard reader, FALSE will be
+ * returned.
+ *
+ * Returns: TRUE if insertion of a card was successfully simulated, FALSE
+ * otherwise
+ */
+gboolean spice_smartcard_reader_insert_card(SpiceSmartcardReader *reader)
+{
+ VCardEmulError status;
+
+ g_return_val_if_fail(spice_smartcard_reader_is_software(reader), FALSE);
+
+ status = vcard_emul_force_card_insert((VReader *)reader);
+
+ return (status == VCARD_EMUL_OK);
+}
+
+/**
+ * spice_smartcard_reader_remove_card:
+ * @reader: a #SpiceSmartcardReader
+ *
+ * Simulates removal of a smartcard from the software smartcard reader
+ * @reader. If @reader is not a software smartcard reader, FALSE will be
+ * returned.
+ *
+ * Returns: TRUE if removal of a card was successfully simulated, FALSE
+ * otherwise
+ */
+gboolean spice_smartcard_reader_remove_card(SpiceSmartcardReader *reader)
+{
+ VCardEmulError status;
+
+ g_return_val_if_fail(spice_smartcard_reader_is_software(reader), FALSE);
+
+ status = vcard_emul_force_card_remove((VReader *)reader);
+
+ return (status == VCARD_EMUL_OK);
+}
+
+/**
* spice_smartcard_manager_insert_card:
* @manager: a #SpiceSmartcardManager
*
@@ -550,14 +594,13 @@ gboolean spice_smartcard_manager_init_finish(SpiceSession *session,
*/
gboolean spice_smartcard_manager_insert_card(SpiceSmartcardManager *manager)
{
- VCardEmulError status;
+ SpiceSmartcardReader *reader;
- if (manager->priv->software_reader != NULL)
- return FALSE;
+ g_return_val_if_fail (manager->priv->software_reader != NULL, FALSE);
- status = vcard_emul_force_card_insert(manager->priv->software_reader);
+ reader = (SpiceSmartcardReader *)manager->priv->software_reader;
- return (status == VCARD_EMUL_OK);
+ return spice_smartcard_reader_insert_card(reader);
}
/**
@@ -573,14 +616,13 @@ gboolean spice_smartcard_manager_insert_card(SpiceSmartcardManager *manager)
*/
gboolean spice_smartcard_manager_remove_card(SpiceSmartcardManager *manager)
{
- VCardEmulError status;
+ SpiceSmartcardReader *reader;
- if (manager->priv->software_reader != NULL)
- return FALSE;
+ g_return_val_if_fail (manager->priv->software_reader != NULL, FALSE);
- status = vcard_emul_force_card_remove(manager->priv->software_reader);
+ reader = (SpiceSmartcardReader *)manager->priv->software_reader;
- return (status == VCARD_EMUL_OK);
+ return spice_smartcard_reader_remove_card(reader);
}
#else
gboolean spice_smartcard_reader_is_software(SpiceSmartcardReader *reader)
@@ -616,4 +658,15 @@ gboolean spice_smartcard_manager_remove_card(SpiceSmartcardManager *manager)
{
return FALSE;
}
+
+gboolean spice_smartcard_reader_insert_card(SpiceSmartcardReader *reader)
+{
+ return FALSE;
+}
+
+gboolean spice_smartcard_reader_remove_card(SpiceSmartcardReader *reader)
+{
+ return FALSE;
+}
+
#endif /* USE_SMARTCARD */
diff --git a/gtk/smartcard-manager.h b/gtk/smartcard-manager.h
index 65c6934..ac00be8 100644
--- a/gtk/smartcard-manager.h
+++ b/gtk/smartcard-manager.h
@@ -71,6 +71,8 @@ SpiceSmartcardManager *spice_smartcard_manager_get(void);
gboolean spice_smartcard_manager_insert_card(SpiceSmartcardManager *manager);
gboolean spice_smartcard_manager_remove_card(SpiceSmartcardManager *manager);
gboolean spice_smartcard_reader_is_software(SpiceSmartcardReader *reader);
+gboolean spice_smartcard_reader_insert_card(SpiceSmartcardReader *reader);
+gboolean spice_smartcard_reader_remove_card(SpiceSmartcardReader *reader);
G_END_DECLS
diff --git a/gtk/spice-glib-sym-file b/gtk/spice-glib-sym-file
index 5a580d6..3db6a0c 100644
--- a/gtk/spice-glib-sym-file
+++ b/gtk/spice-glib-sym-file
@@ -71,7 +71,9 @@ spice_smartcard_manager_get_type
spice_smartcard_manager_insert_card
spice_smartcard_manager_remove_card
spice_smartcard_reader_get_type
+spice_smartcard_reader_insert_card
spice_smartcard_reader_is_software
+spice_smartcard_reader_remove_card
spice_usb_device_get_description
spice_usb_device_get_type
spice_usb_device_manager_can_redirect_device