diff -ruN --exclude stamp-h1 --exclude Info.plist --exclude agmiiusb.spec --exclude t --exclude libtool --exclude autom4te.cache --exclude Makefile --exclude 'debug*' --exclude configure --exclude Makefile.in --exclude 'config*' --exclude aclocal.m4 agmiiusb-1.0.0/src/85-pcscd_agmiiusb.rules agmiiusb-1.0.0-hno/src/85-pcscd_agmiiusb.rules
--- agmiiusb-1.0.0/src/85-pcscd_agmiiusb.rules	1970-01-01 01:00:00.000000000 +0100
+++ agmiiusb-1.0.0-hno/src/85-pcscd_agmiiusb.rules	2007-12-25 03:03:01.000000000 +0100
@@ -0,0 +1,5 @@
+# udev rules for pcscd and CCID readers
+
+# non CCID generic (InterfaceClass: 0xFF)
+# Todos Argos Mini II USB
+BUS=="usb", SYSFS{idVendor}=="0b0c", SYSFS{idProduct}=="0009", ACTION=="add", RUN+="/usr/sbin/pcscd --hotplug"
diff -ruN --exclude stamp-h1 --exclude Info.plist --exclude agmiiusb.spec --exclude t --exclude libtool --exclude autom4te.cache --exclude Makefile --exclude 'debug*' --exclude configure --exclude Makefile.in --exclude 'config*' --exclude aclocal.m4 agmiiusb-1.0.0/src/AgmII.h agmiiusb-1.0.0-hno/src/AgmII.h
--- agmiiusb-1.0.0/src/AgmII.h	2007-12-25 03:53:36.000000000 +0100
+++ agmiiusb-1.0.0-hno/src/AgmII.h	2007-12-25 03:46:57.000000000 +0100
@@ -153,6 +153,9 @@
 typedef struct
 {
 	usb_dev_handle *handle;
+	uint8_t input_endpoint;
+	uint8_t output_endpoint;
+	uint8_t interface;
 	struct usb_device *dev;
 	char bus_device[BUS_DEVICE_STRSIZE];
 
diff -ruN --exclude stamp-h1 --exclude Info.plist --exclude agmiiusb.spec --exclude t --exclude libtool --exclude autom4te.cache --exclude Makefile --exclude 'debug*' --exclude configure --exclude Makefile.in --exclude 'config*' --exclude aclocal.m4 agmiiusb-1.0.0/src/ifdhandler.c agmiiusb-1.0.0-hno/src/ifdhandler.c
--- agmiiusb-1.0.0/src/ifdhandler.c	2005-05-23 11:30:08.000000000 +0200
+++ agmiiusb-1.0.0-hno/src/ifdhandler.c	2007-12-25 03:14:21.000000000 +0100
@@ -12,6 +12,8 @@
 #include <pcsclite.h>
 #include <stdio.h>
 #include <string.h>
+#include <errno.h>
+
 #include "AgmII.h"
 
 /*****************************************************************************
@@ -833,6 +835,12 @@
 	case 0:
 		//AgmLog1(AGM_LOG_DEBUG, "IFDHICCPresence returning IFD_ICC_NOT_PRESENT");
 		return IFD_ICC_NOT_PRESENT;
+	case -1:
+		if (errno == ENODEV) {
+			AgmLog1(AGM_LOG_DEBUG,
+					  "IFDHICCPresence returning IFD_NO_SUCH_DEVICE");
+			return IFD_NO_SUCH_DEVICE;
+		}
 	default:
 		AgmLog1(AGM_LOG_DEBUG,
 				  "IFDHICCPresence returning IFD_COMMUNICATION_ERROR");
diff -ruN --exclude stamp-h1 --exclude Info.plist --exclude agmiiusb.spec --exclude t --exclude libtool --exclude autom4te.cache --exclude Makefile --exclude 'debug*' --exclude configure --exclude Makefile.in --exclude 'config*' --exclude aclocal.m4 agmiiusb-1.0.0/src/ifdhandler.h agmiiusb-1.0.0-hno/src/ifdhandler.h
--- agmiiusb-1.0.0/src/ifdhandler.h	2005-05-12 09:33:02.000000000 +0200
+++ agmiiusb-1.0.0-hno/src/ifdhandler.h	2007-12-25 02:58:53.000000000 +0100
@@ -116,6 +116,8 @@
 #define IFD_NOT_SUPPORTED           614
 #define IFD_ICC_PRESENT             615
 #define IFD_ICC_NOT_PRESENT         616
+#define IFD_NO_SUCH_DEVICE               617
+
 
 	/* List of Defined Functions Available to IFD_Handler */
 
diff -ruN --exclude stamp-h1 --exclude Info.plist --exclude agmiiusb.spec --exclude t --exclude libtool --exclude autom4te.cache --exclude Makefile --exclude 'debug*' --exclude configure --exclude Makefile.in --exclude 'config*' --exclude aclocal.m4 agmiiusb-1.0.0/src/Info.plist.in agmiiusb-1.0.0-hno/src/Info.plist.in
--- agmiiusb-1.0.0/src/Info.plist.in	2005-06-02 11:58:24.000000000 +0200
+++ agmiiusb-1.0.0-hno/src/Info.plist.in	2007-12-25 03:58:08.000000000 +0100
@@ -15,7 +15,7 @@
 	<key>CFBundleVersion</key>
 	<string>@PACKAGE_VERSION@</string>
 	<key>ifdCapabilities</key>
-	<string>0x00000000</string>
+	<string>0x00000001</string>
 	<key>ifdFriendlyName</key>
 	<string>Argos Mini II</string>
 	<key>ifdManufacturerString</key>
diff -ruN --exclude stamp-h1 --exclude Info.plist --exclude agmiiusb.spec --exclude t --exclude libtool --exclude autom4te.cache --exclude Makefile --exclude 'debug*' --exclude configure --exclude Makefile.in --exclude 'config*' --exclude aclocal.m4 agmiiusb-1.0.0/src/Makefile.am agmiiusb-1.0.0-hno/src/Makefile.am
--- agmiiusb-1.0.0/src/Makefile.am	2005-06-03 14:42:17.000000000 +0200
+++ agmiiusb-1.0.0-hno/src/Makefile.am	2007-12-25 04:03:15.000000000 +0100
@@ -24,6 +24,8 @@
 	$(mkinstalldirs) $(DESTDIR)$(usbdropdir)/$(AGMII_BUNDLE)/Contents/$(BUNDLE_HOST)/
 	cp $(top_builddir)/src/Info.plist $(DESTDIR)$(usbdropdir)/$(AGMII_BUNDLE)/Contents/Info.plist
 	cp $(top_builddir)/src/.libs/$(AGMII_LIB) $(DESTDIR)$(usbdropdir)/$(AGMII_BUNDLE)/Contents/$(BUNDLE_HOST)/$(AGMII_LIB).$(PACKAGE_VERSION)
+	$(mkinstalldirs) $(DESTDIR)/etc/udev/rules.d/
+	cp $(top_builddir)/src/85-pcscd_agmiiusb.rules $(DESTDIR)/etc/udev/rules.d/
 
 uninstall: uninstall_libAgmIIusb
 
diff -ruN --exclude stamp-h1 --exclude Info.plist --exclude agmiiusb.spec --exclude t --exclude libtool --exclude autom4te.cache --exclude Makefile --exclude 'debug*' --exclude configure --exclude Makefile.in --exclude 'config*' --exclude aclocal.m4 agmiiusb-1.0.0/src/usb.c agmiiusb-1.0.0-hno/src/usb.c
--- agmiiusb-1.0.0/src/usb.c	2005-05-27 11:59:19.000000000 +0200
+++ agmiiusb-1.0.0-hno/src/usb.c	2007-12-25 03:51:15.000000000 +0100
@@ -170,7 +170,9 @@
 							globalData->io.curPos = globalData->io.lastPos =
 								globalData->io.stopReading = 0;
 							globalData->io.handle = dev_handle;
-							globalData->io.dev = dev;
+							globalData->io.interface = dev->config[0].interface[0].altsetting[0].bInterfaceNumber;
+							globalData->io.input_endpoint = dev->config[0].interface[0].altsetting[0].endpoint[USB_INEP].bEndpointAddress;
+							globalData->io.output_endpoint = dev->config[0].interface[0].altsetting[0].endpoint[USB_OUTEP].bEndpointAddress,
 							strncpy(globalData->io.bus_device, bus_device,
 									  BUS_DEVICE_STRSIZE);
 							return TRUE;
@@ -211,9 +213,7 @@
 #endif
 
 	int writesize = usb_bulk_write(globalData->io.handle,
-											 globalData->io.dev->config[0].interface[0].
-											 altsetting[0].endpoint[USB_OUTEP].
-											 bEndpointAddress,
+											 globalData->io.output_endpoint,
 											 (char *) data, ARGMINIUSB_FIFO_LEN,
 											 timeOut);
 
@@ -242,8 +242,7 @@
 	int readsize;
 
 	readsize = usb_bulk_read(globalData->io.handle,
-									 globalData->io.dev->config[0].interface[0].
-									 altsetting[0].endpoint[USB_INEP].bEndpointAddress,
+									 globalData->io.input_endpoint,
 									 (char *) buf, ARGMINIUSB_FIFO_LEN, timeOut);
 
 	if (readsize < 0)
@@ -253,8 +252,7 @@
 #endif
 
 		readsize = usb_bulk_read(globalData->io.handle,
-										 globalData->io.dev->config[0].interface[0].
-										 altsetting[0].endpoint[USB_INEP].bEndpointAddress,
+										 globalData->io.input_endpoint,
 										 (char *) buf, ARGMINIUSB_FIFO_LEN, timeOut);
 
 		if (readsize < 0)
@@ -277,7 +275,7 @@
 //    unsigned char temp[700];
 //
 //    usb_bulk_read(globalData->io.handle,
-//                  globalData->io.dev->config[0].interface[0].altsetting[0].endpoint[USB_INEP].bEndpointAddress,
+//                  globalData->io.input_endoint,
 //                  temp, 300, 1000 /* 1 sec */);
 
 	globalData->io.curPos = globalData->io.lastPos = 0;
@@ -294,14 +292,12 @@
 #endif
 
 	usb_release_interface(globalData->io.handle,
-								 globalData->io.dev->config[0].interface[0].
-								 altsetting[0].bInterfaceNumber);
+								 globalData->io.interface);
 	usb_reset(globalData->io.handle);
 	usb_close(globalData->io.handle);
 
 	/* mark the resource unused */
 	globalData->io.handle = NULL;
-	globalData->io.dev = NULL;
 	globalData->io.bus_device[0] = '\0';
 	globalData->io.stopReading = 1;
 
--- agmiiusb-1.0.0/agmiiusb.spec.in.orig	2007-12-25 04:20:33.000000000 +0100
+++ agmiiusb-1.0.0/agmiiusb.spec.in	2007-12-25 04:28:26.000000000 +0100
@@ -1,7 +1,7 @@
 # $Id: agmiiusb.spec.in,v 1.1 2005/06/03 08:02:40 kath Exp $
 Name:           agmiiusb
 Version:        @PACKAGE_VERSION@
-Release:        2
+Release:        3
 Summary:        USB smart card reader driver for Argos Mini II USB
 
 Group:          System Environment/Libraries
@@ -9,6 +9,7 @@
 URL:            http://www.todos.se/Todos/products/products_ArgosMini.html
 Source0:        http://www.todos.se/Todos/downloads/files/agmiiusb-1.0.0.tar.gz
 Patch0:		agmiiusb-1.0.0-log_msg.patch
+Patch1:		agmiiusb-1.0.0-hotplug.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 BuildRequires:  pkgconfig autoconf automake
@@ -23,6 +24,7 @@
 %prep
 %setup -q
 %patch0 -p1
+%patch1 -p1
 autoreconf -i
 
 
@@ -54,9 +56,12 @@
 %defattr(-,root,root,-)
 %doc AUTHORS ChangeLog COPYING README
 %{_libdir}/pcsc/drivers/*
+/etc/udev/rules.d/
 
 
 %changelog
+* Mon Dec 25 2008 Henrik Nordström <henrik at henriknordstrom.net> - 1.0.0-3
+- Hotplug support
 * Mon Nov 13 2006 Henrik Nordström <henrik at henriknordstrom.net> - 1.0.0-2
 - Fixed some minor build environment issues
 * Fri May 27 2005 Karl Dahlén <karl at todos.se> - 1.0.0-1
