diff options
author | Christophe Fergeau <cfergeau@redhat.com> | 2013-06-13 13:13:29 +0200 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2013-06-24 17:18:28 +0200 |
commit | ddc3314466f8450449f92f8eca612271a1d43a57 (patch) | |
tree | 068c97bab9caaad7c0ebd0e372a8ae8cc08bf4a9 | |
parent | 6885473bf49e7c81cd807983e5d178bd972e8d0c (diff) |
Add spice_smartcard_manager_get_readers()
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.
-rw-r--r-- | gtk/map-file | 1 | ||||
-rw-r--r-- | gtk/smartcard-manager.c | 44 | ||||
-rw-r--r-- | gtk/smartcard-manager.h | 1 | ||||
-rw-r--r-- | gtk/spice-glib-sym-file | 1 |
4 files changed, 47 insertions, 0 deletions
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 |