[Spice-devel] [spice-gtk 3/4] Add spice_smartcard_manager_get_readers()
Christophe Fergeau
cfergeau at redhat.com
Wed Jun 19 08:33:26 PDT 2013
This returns the list of smartcard readers known to a given
SpiceSmartcardManager. This is useful to check whether a software
smartcard reader is available or not.
---
gtk/map-file | 1 +
gtk/smartcard-manager.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
gtk/smartcard-manager.h | 1 +
gtk/spice-glib-sym-file | 1 +
4 files changed, 47 insertions(+)
diff --git a/gtk/map-file b/gtk/map-file
index 0419ecb..a0b7330 100644
--- a/gtk/map-file
+++ b/gtk/map-file
@@ -91,6 +91,7 @@ spice_session_verify_get_type;
spice_set_session_option;
spice_smartcard_channel_get_type;
spice_smartcard_manager_get;
+spice_smartcard_manager_get_readers;
spice_smartcard_manager_get_type;
spice_smartcard_manager_insert_card;
spice_smartcard_manager_remove_card;
diff --git a/gtk/smartcard-manager.c b/gtk/smartcard-manager.c
index 366e2dd..6709d56 100644
--- a/gtk/smartcard-manager.c
+++ b/gtk/smartcard-manager.c
@@ -580,6 +580,45 @@ gboolean spice_smartcard_reader_remove_card(SpiceSmartcardReader *reader)
}
/**
+ * spice_smartcard_manager_get_readers:
+ *
+ * manager: a #SpiceSmartcardManager
+ *
+ * Gets the list of smartcard readers that are currently available, they
+ * can be either software (emulated) readers, or hardware ones.
+ *
+ * Returns: (element-type SpiceSmartcardReader) (transfer full): a newly
+ * allocated list of SpiceSmartcardReader instances, or NULL if none were
+ * found. When no longer needed, the list must be freed after unreferencing
+ * its elements with g_boxed_free()
+ */
+GList *spice_smartcard_manager_get_readers(SpiceSmartcardManager *manager)
+{
+
+ GList *readers = NULL;
+ VReaderList *vreader_list;
+ VReaderListEntry *entry;
+
+ vreader_list = vreader_get_reader_list();
+
+ if (vreader_list == NULL)
+ return NULL;
+
+ for (entry = vreader_list_get_first(vreader_list);
+ entry != NULL;
+ entry = vreader_list_get_next(entry)) {
+ VReader *reader;
+
+ reader = vreader_list_get_reader(entry);
+ g_warn_if_fail(reader != NULL);
+ readers = g_list_prepend(readers, vreader_reference(reader));
+ }
+ vreader_list_delete(vreader_list);
+
+ return g_list_reverse(readers);
+}
+
+/**
* spice_smartcard_manager_insert_card:
* @manager: a #SpiceSmartcardManager
*
@@ -669,4 +708,9 @@ gboolean spice_smartcard_reader_remove_card(SpiceSmartcardReader *reader)
return FALSE;
}
+GList *spice_smartcard_manager_get_readers(SpiceSmartcardManager *manager)
+{
+ return NULL;
+}
+
#endif /* USE_SMARTCARD */
diff --git a/gtk/smartcard-manager.h b/gtk/smartcard-manager.h
index ac00be8..698357b 100644
--- a/gtk/smartcard-manager.h
+++ b/gtk/smartcard-manager.h
@@ -73,6 +73,7 @@ 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);
+GList *spice_smartcard_manager_get_readers(SpiceSmartcardManager *manager);
G_END_DECLS
diff --git a/gtk/spice-glib-sym-file b/gtk/spice-glib-sym-file
index 3db6a0c..2b172d0 100644
--- a/gtk/spice-glib-sym-file
+++ b/gtk/spice-glib-sym-file
@@ -67,6 +67,7 @@ spice_session_verify_get_type
spice_set_session_option
spice_smartcard_channel_get_type
spice_smartcard_manager_get
+spice_smartcard_manager_get_readers
spice_smartcard_manager_get_type
spice_smartcard_manager_insert_card
spice_smartcard_manager_remove_card
--
1.8.2.1
More information about the Spice-devel
mailing list