00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef CHIPCARD_SERVER_DEVMONITOR_H
00015 #define CHIPCARD_SERVER_DEVMONITOR_H
00016
00017 #define LC__DEVICE_FILE "/var/run/chipcard2/dev.state"
00018
00019
00020 typedef struct LC_DEVICE LC_DEVICE;
00021 typedef struct LC_DEVSCANNER LC_DEVSCANNER;
00022 typedef struct LC_DEVMONITOR LC_DEVMONITOR;
00023
00024
00025 #include <gwenhywfar/idlist.h>
00026 #include <gwenhywfar/misc.h>
00027 #include <gwenhywfar/inherit.h>
00028
00029
00030 typedef enum {
00031 LC_Device_BusType_Unknown=-1,
00032 LC_Device_BusType_Any=0,
00033 LC_Device_BusType_UsbRaw,
00034 LC_Device_BusType_UsbTty,
00035 LC_Device_BusType_Pci,
00036 LC_Device_BusType_Pcmcia,
00037 LC_Device_BusType_Serial
00038 } LC_DEVICE_BUSTYPE;
00039
00040 LC_DEVICE_BUSTYPE LC_Device_BusType_fromString(const char *s);
00041 const char *LC_Device_BusType_toString(LC_DEVICE_BUSTYPE i);
00042
00043
00044 GWEN_LIST_FUNCTION_DEFS(LC_DEVICE, LC_Device)
00045 GWEN_INHERIT_FUNCTION_DEFS(LC_DEVSCANNER)
00046 GWEN_LIST_FUNCTION_DEFS(LC_DEVSCANNER, LC_DevScanner)
00047
00048
00049 typedef int (*LC_DEVSCANNER_READ_DEVS_FN)(LC_DEVSCANNER *um,
00050 LC_DEVICE_LIST *dl);
00051
00052
00053 LC_DEVSCANNER *LC_DevScanner_new();
00054 void LC_DevScanner_SetReadDevsFn(LC_DEVSCANNER *um,
00055 LC_DEVSCANNER_READ_DEVS_FN fn);
00056
00057 void LC_DevScanner_free(LC_DEVSCANNER *um);
00058
00059 int LC_DevScanner_Scan(LC_DEVSCANNER *um,
00060 LC_DEVICE_LIST *devList);
00061
00062
00063 LC_DEVMONITOR *LC_DevMonitor_new();
00064 void LC_DevMonitor_free(LC_DEVMONITOR *um);
00065
00066 void LC_DevMonitor_AddScanner(LC_DEVMONITOR *um, LC_DEVSCANNER *sc);
00067
00068 int LC_DevMonitor_Scan(LC_DEVMONITOR *um);
00069
00070 LC_DEVICE_LIST *LC_DevMonitor_GetNewDevices(const LC_DEVMONITOR *um);
00071 LC_DEVICE_LIST *LC_DevMonitor_GetLostDevices(const LC_DEVMONITOR *um);
00072 LC_DEVICE_LIST *LC_DevMonitor_GetCurrentDevices(const LC_DEVMONITOR *um);
00073
00074
00075
00076
00077 LC_DEVICE *LC_Device_new(LC_DEVICE_BUSTYPE busType,
00078 GWEN_TYPE_UINT32 busId,
00079 GWEN_TYPE_UINT32 deviceId,
00080 GWEN_TYPE_UINT32 vendorId,
00081 GWEN_TYPE_UINT32 productId);
00082 void LC_Device_free(LC_DEVICE *ud);
00083
00084
00085 LC_DEVICE *LC_Device_List_Find(LC_DEVICE_LIST *dl,
00086 LC_DEVICE_BUSTYPE busType,
00087 GWEN_TYPE_UINT32 busId,
00088 GWEN_TYPE_UINT32 deviceId,
00089 GWEN_TYPE_UINT32 vendorId,
00090 GWEN_TYPE_UINT32 productId);
00091
00092 LC_DEVICE *LC_Device_Get(LC_DEVICE_LIST *dl,
00093 LC_DEVICE_BUSTYPE busType,
00094 GWEN_TYPE_UINT32 dpos);
00095
00096
00097 GWEN_TYPE_UINT32 LC_Device_GetDevicePos(const LC_DEVICE *ud);
00098 void LC_Device_SetDevicePos(LC_DEVICE *ud, GWEN_TYPE_UINT32 i);
00099
00100 const char *LC_Device_GetPath(const LC_DEVICE *ud);
00101 void LC_Device_SetPath(LC_DEVICE *ud, const char *s);
00102
00103 LC_DEVICE_BUSTYPE LC_Device_GetBusType(const LC_DEVICE *ud);
00104 GWEN_TYPE_UINT32 LC_Device_GetBusId(const LC_DEVICE *ud);
00105 GWEN_TYPE_UINT32 LC_Device_GetDeviceId(const LC_DEVICE *ud);
00106 GWEN_TYPE_UINT32 LC_Device_GetVendorId(const LC_DEVICE *ud);
00107 GWEN_TYPE_UINT32 LC_Device_GetProductId(const LC_DEVICE *ud);
00108
00109 const char *LC_Device_GetDriverType(const LC_DEVICE *ud);
00110 void LC_Device_SetDriverType(LC_DEVICE *ud, const char *s);
00111
00112 const char *LC_Device_GetReaderType(const LC_DEVICE *ud);
00113 void LC_Device_SetReaderType(LC_DEVICE *ud, const char *s);
00114
00115
00116 #endif