summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2012-03-22 13:25:47 +0200
committerAlon Levy <alevy@redhat.com>2012-03-22 20:11:46 +0200
commit956b7043f815720719fe9183d5dc853c9fedc424 (patch)
tree5540c5c5c4aef1afe3c4d5d03065a3fa05d3f559 /src
parent69198899e170ec8764ad54a3b33301f3b6082097 (diff)
SlotList::waitForSlotEvent: use \\?PnP?\Notification
Diffstat (limited to 'src')
-rw-r--r--src/coolkey/slot.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/coolkey/slot.cpp b/src/coolkey/slot.cpp
index a5f550b..d0fa41d 100644
--- a/src/coolkey/slot.cpp
+++ b/src/coolkey/slot.cpp
@@ -1228,22 +1228,23 @@ SlotList::waitForSlotEvent(CK_FLAGS flag, CK_SLOT_ID_PTR slotp, CK_VOID_PTR res)
throw;
}
- if (myNumReaders != numReaders) {
+ if (myNumReaders != numReaders + 1) {
if (myReaderStates) {
delete [] myReaderStates;
}
- myReaderStates = new SCARD_READERSTATE [numReaders];
+ myReaderStates = new SCARD_READERSTATE [numReaders + 1];
+ myNumReaders = numReaders + 1;
}
- memcpy(myReaderStates, readerStates,
- sizeof(SCARD_READERSTATE)*numReaders);
- myNumReaders = numReaders;
+ memcpy(myReaderStates, readerStates,
+ sizeof(SCARD_READERSTATE) * numReaders);
+ myReaderStates[numReaders].szReader = "\\\\?PnP?\\Notification";
+ myReaderStates[numReaders].dwCurrentState = SCARD_STATE_UNAWARE;
readerListLock.releaseLock();
status = CKYCardContext_WaitForStatusChange(context,
myReaderStates, myNumReaders, timeout);
if (status == CKYSUCCESS) {
- for (i=0; i < myNumReaders; i++) {
- SCARD_READERSTATE *rsp = &myReaderStates[i];
- unsigned long eventState = CKYReader_GetEventState(rsp);
+ for (i=0; i < myNumReaders - 1; i++) {
+ unsigned long eventState = CKYReader_GetEventState(&myReaderStates[i]);
if (eventState & SCARD_STATE_CHANGED) {
readerListLock.getLock();
CKYReader_SetKnownState(&readerStates[i], eventState & ~SCARD_STATE_CHANGED);
@@ -1253,6 +1254,12 @@ SlotList::waitForSlotEvent(CK_FLAGS flag, CK_SLOT_ID_PTR slotp, CK_VOID_PTR res)
break;
}
}
+ /* No real need to check for an additional card, we already update the
+ * list when we iterate. */
+ if (CKYReader_GetEventState(&myReaderStates[myNumReaders - 1])
+ & SCARD_STATE_CHANGED) {
+ log->log("Reader insertion/removal detected\n");
+ }
}
if (found || (flag == CKF_DONT_BLOCK) || shuttingDown) {