diff options
author | Christophe Fergeau <cfergeau@redhat.com> | 2011-05-04 17:36:05 +0200 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@gmail.com> | 2011-06-22 15:11:38 +0200 |
commit | 902c45df27f53d63b2093202e34e19e192c236aa (patch) | |
tree | b91ebac4e563a2526d746aaf71bc3cc13ede239d | |
parent | 0b9356317cee4b30635969be4e7e5aacb7153bbc (diff) |
add signals for smartcard events
Add signals which will be emitted when a reader appears/disappears,
or when a smartcard is inserted/removed.
-rw-r--r-- | gtk/smartcard-manager.c | 85 | ||||
-rw-r--r-- | gtk/smartcard-manager.h | 6 | ||||
-rw-r--r-- | gtk/spice-marshal.txt | 1 |
3 files changed, 91 insertions, 1 deletions
diff --git a/gtk/smartcard-manager.c b/gtk/smartcard-manager.c index e812a5d..f151100 100644 --- a/gtk/smartcard-manager.c +++ b/gtk/smartcard-manager.c @@ -18,8 +18,10 @@ #include <glib-object.h> #include <vevent.h> +#include <vreader.h> #include "smartcard-manager.h" +#include "spice-marshal.h" /** * SECTION:spice-smartcard-manager @@ -55,11 +57,15 @@ enum { /* Signals */ enum { + SPICE_SMARTCARD_MANAGER_READER_ADDED, + SPICE_SMARTCARD_MANAGER_READER_REMOVED, + SPICE_SMARTCARD_MANAGER_CARD_INSERTED, + SPICE_SMARTCARD_MANAGER_CARD_REMOVED, SPICE_SMARTCARD_MANAGER_LAST_SIGNAL, }; -G_GNUC_UNUSED static guint signals[SPICE_SMARTCARD_MANAGER_LAST_SIGNAL]; +static guint signals[SPICE_SMARTCARD_MANAGER_LAST_SIGNAL]; typedef gboolean (*SmartCardSourceFunc)(VEvent *event, gpointer user_data); static guint smartcard_monitor_add(SmartCardSourceFunc callback, @@ -104,6 +110,83 @@ static void spice_smartcard_manager_class_init(SpiceSmartCardManagerClass *klass { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + /** + * SpiceSmartCardManager::reader-added: + * @manager: the #SpiceSmartCardManager that emitted the signal + * @vreader: #VReader boxed object corresponding to the added reader + * + * The #SpiceSmartCardManager::reader-added signal is emitted whenever + * a new smartcard reader (software or hardware) has been plugged in. + **/ + signals[SPICE_SMARTCARD_MANAGER_READER_ADDED] = + g_signal_new("reader-added", + G_OBJECT_CLASS_TYPE(gobject_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET(SpiceSmartCardManagerClass, reader_added), + NULL, NULL, + g_cclosure_user_marshal_VOID__BOXED, + G_TYPE_NONE, + 1, + SPICE_TYPE_SMARTCARD_READER); + + /** + * SpiceSmartCardManager::reader-removed: + * @manager: the #SpiceSmartCardManager that emitted the signal + * @vreader: #VReader boxed object corresponding to the removed reader + * + * The #SpiceSmartCardManager::reader-removed signal is emitted whenever + * a smartcard reader (software or hardware) has been removed. + **/ + signals[SPICE_SMARTCARD_MANAGER_READER_REMOVED] = + g_signal_new("reader-removed", + G_OBJECT_CLASS_TYPE(gobject_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET(SpiceSmartCardManagerClass, reader_removed), + NULL, NULL, + g_cclosure_user_marshal_VOID__BOXED, + G_TYPE_NONE, + 1, + SPICE_TYPE_SMARTCARD_READER); + + /** + * SpiceSmartCardManager::card-inserted: + * @manager: the #SpiceSmartCardManager that emitted the signal + * @vreader: #VReader boxed object corresponding to the reader a new + * card was inserted in + * + * The #SpiceSmartCardManager::card-inserted signal is emitted whenever + * a smartcard is inserted in a reader + **/ + signals[SPICE_SMARTCARD_MANAGER_CARD_INSERTED] = + g_signal_new("card-inserted", + G_OBJECT_CLASS_TYPE(gobject_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET(SpiceSmartCardManagerClass, card_inserted), + NULL, NULL, + g_cclosure_user_marshal_VOID__BOXED, + G_TYPE_NONE, + 1, + SPICE_TYPE_SMARTCARD_READER); + + /** + * SpiceSmartCardManager::card-removed: + * @manager: the #SpiceSmartCardManager that emitted the signal + * @vreader: #VReader boxed object corresponding to the reader a card + * was removed from + * + * The #SpiceSmartCardManager::card-removed signal is emitted whenever + * a smartcard was removed from a reader. + **/ + signals[SPICE_SMARTCARD_MANAGER_CARD_REMOVED] = + g_signal_new("card-removed", + G_OBJECT_CLASS_TYPE(gobject_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET(SpiceSmartCardManagerClass, card_removed), + NULL, NULL, + g_cclosure_user_marshal_VOID__BOXED, + G_TYPE_NONE, + 1, + SPICE_TYPE_SMARTCARD_READER); gobject_class->dispose = spice_smartcard_manager_dispose; gobject_class->finalize = spice_smartcard_manager_finalize; diff --git a/gtk/smartcard-manager.h b/gtk/smartcard-manager.h index ceaa9c0..1f8b1dd 100644 --- a/gtk/smartcard-manager.h +++ b/gtk/smartcard-manager.h @@ -47,6 +47,12 @@ struct _SpiceSmartCardManager struct _SpiceSmartCardManagerClass { GObjectClass parent_class; + /*< public >*/ + /* signals */ + void (*reader_added)(SpiceSmartCardManager *manager, VReader *reader); + void (*reader_removed)(SpiceSmartCardManager *manager, VReader *reader); + void (*card_inserted)(SpiceSmartCardManager *manager, VReader *reader); + void (*card_removed)(SpiceSmartCardManager *manager, VReader *reader ); /* * If adding fields to this struct, remove corresponding * amount of padding to avoid changing overall struct size diff --git a/gtk/spice-marshal.txt b/gtk/spice-marshal.txt index b99a5f5..8e56394 100644 --- a/gtk/spice-marshal.txt +++ b/gtk/spice-marshal.txt @@ -6,6 +6,7 @@ VOID:INT,INT,INT,INT,INT,POINTER VOID:POINTER,INT BOOLEAN:POINTER,UINT BOOLEAN:UINT +VOID:BOXED VOID:UINT,POINTER,UINT VOID:UINT,UINT,POINTER,UINT BOOLEAN:UINT,POINTER,UINT |