[Pcsclite-cvs-commit] r2310 - trunk/PCSC/src

Ludovic Rousseau rousseau at alioth.debian.org
Sat Jan 6 22:14:57 CET 2007


Author: rousseau
Date: 2007-01-06 22:14:56 +0100 (Sat, 06 Jan 2007)
New Revision: 2310

Modified:
   trunk/PCSC/src/hotplug.h
   trunk/PCSC/src/hotplug_libusb.c
Log:
add support for IFD_GENERATE_HOTPLUG bit in driver Info.plist ifdCapabilities


Modified: trunk/PCSC/src/hotplug.h
===================================================================
--- trunk/PCSC/src/hotplug.h	2007-01-06 20:30:33 UTC (rev 2309)
+++ trunk/PCSC/src/hotplug.h	2007-01-06 21:14:56 UTC (rev 2310)
@@ -28,6 +28,7 @@
 #define PCSCLITE_HP_PRODKEY_NAME	"ifdProductID"
 #define PCSCLITE_HP_NAMEKEY_NAME	"ifdFriendlyName"
 #define PCSCLITE_HP_LIBRKEY_NAME	"CFBundleExecutable"
+#define PCSCLITE_HP_CPCTKEY_NAME	"ifdCapabilities"
 
 #define PCSCLITE_HP_BASE_PORT		0x200000
 

Modified: trunk/PCSC/src/hotplug_libusb.c
===================================================================
--- trunk/PCSC/src/hotplug_libusb.c	2007-01-06 20:30:33 UTC (rev 2309)
+++ trunk/PCSC/src/hotplug_libusb.c	2007-01-06 21:14:56 UTC (rev 2310)
@@ -56,6 +56,9 @@
 static int driverSize = -1;
 static char AraKiriHotPlug = FALSE;
 
+/* values of ifdCapabilities bits */
+#define IFD_GENERATE_HOTPLUG 1
+
 /*
  * keep track of drivers in a dynamically allocated array
  */
@@ -67,6 +70,7 @@
 	char *bundleName;
 	char *libraryPath;
 	char *readerName;
+	int ifdCapabilities;
 } *driverTracker = NULL;
 #define DRIVER_TRACKER_SIZE_STEP 8
 
@@ -166,6 +170,12 @@
 					driverTracker[listCount].libraryPath = strdup(fullLibPath);
 				}
 
+				/* Get ifdCapabilities */
+				rv = LTPBundleFindValueWithKey(fullPath, PCSCLITE_HP_CPCTKEY_NAME,
+					keyValue, 0);
+				if (rv == 0)
+					driverTracker[listCount].ifdCapabilities = strtol(keyValue, 0, 16);
+
 #ifdef DEBUG_HOTPLUG
 					Log2(PCSC_LOG_INFO, "Found driver for: %s",
 						driverTracker[listCount].readerName);
@@ -201,6 +211,7 @@
 						driverTracker[i].bundleName = NULL;
 						driverTracker[i].libraryPath = NULL;
 						driverTracker[i].readerName = NULL;
+						driverTracker[i].ifdCapabilities = 0;
 					}
 				}
 			}
@@ -360,6 +371,8 @@
 
 void HPEstablishUSBNotifications(void)
 {
+	int i, do_polling;
+
 	/* libusb default is /dev/bus/usb but the devices are not yet visible there
 	 * when a hotplug is requested */
 	setenv("USB_DEVFS_PATH", "/proc/bus/usb", 0);
@@ -369,14 +382,24 @@
 	/* scan the USB bus for devices at startup */
 	HPRescanUsbBus();
 
-#define USB_POLLING
-#ifdef USB_POLLING
-	while (1)
+	/* if at least one driver do not have IFD_GENERATE_HOTPLUG */
+	do_polling = FALSE;
+	for (i=0; i<driverSize; i++)
+		if (driverTracker[i].libraryPath)
+			if ((driverTracker[i].ifdCapabilities & IFD_GENERATE_HOTPLUG) == 0)
+			{
+				Log2(PCSC_LOG_INFO,
+					"Driver %s does not support IFD_GENERATE_HOTPLUG",
+					driverTracker[i].bundleName);
+				do_polling = TRUE;
+				break;
+			}
+
+	while (do_polling)
 	{
 		SYS_Sleep(1);
 		HPRescanUsbBus();
 	}
-#endif
 }
 
 LONG HPSearchHotPluggables(void)




More information about the Pcsclite-cvs-commit mailing list