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
00018 typedef struct LC_DEVICE LC_DEVICE;
00019 typedef struct LC_DEVSCANNER LC_DEVSCANNER;
00020 typedef struct LC_DEVMONITOR LC_DEVMONITOR;
00021
00022
00023 #include <gwenhywfar/idlist.h>
00024 #include <gwenhywfar/misc.h>
00025 #include <gwenhywfar/inherit.h>
00026 #include <gwenhywfar/buffer.h>
00027
00028
00029 typedef enum {
00030 LC_Device_BusType_Unknown=-1,
00031 LC_Device_BusType_Any=0,
00032 LC_Device_BusType_UsbRaw,
00033 LC_Device_BusType_Tty,
00034 LC_Device_BusType_Pci,
00035 LC_Device_BusType_Pcmcia,
00036 LC_Device_BusType_Serial
00037 } LC_DEVICE_BUSTYPE;
00038
00039 LC_DEVICE_BUSTYPE LC_Device_BusType_fromString(const char *s);
00040 const char *LC_Device_BusType_toString(LC_DEVICE_BUSTYPE i);
00041
00042
00043 GWEN_LIST_FUNCTION_DEFS(LC_DEVICE, LC_Device)
00044 GWEN_INHERIT_FUNCTION_DEFS(LC_DEVSCANNER)
00045 GWEN_LIST_FUNCTION_DEFS(LC_DEVSCANNER, LC_DevScanner)
00046
00047
00048 typedef int (*LC_DEVSCANNER_READ_DEVS_FN)(LC_DEVSCANNER *um,
00049 LC_DEVICE_LIST *dl);
00050
00051
00052 LC_DEVSCANNER *LC_DevScanner_new();
00053 void LC_DevScanner_SetReadDevsFn(LC_DEVSCANNER *um,
00054 LC_DEVSCANNER_READ_DEVS_FN fn);
00055
00056 void LC_DevScanner_free(LC_DEVSCANNER *um);
00057
00058 int LC_DevScanner_Scan(LC_DEVSCANNER *um,
00059 LC_DEVICE_LIST *devList);
00060
00061
00062 LC_DEVMONITOR *LC_DevMonitor_new();
00063 void LC_DevMonitor_free(LC_DEVMONITOR *um);
00064
00065 void LC_DevMonitor_AddScanner(LC_DEVMONITOR *um, LC_DEVSCANNER *sc);
00066
00067 int LC_DevMonitor_Scan(LC_DEVMONITOR *um);
00068
00069 LC_DEVICE_LIST *LC_DevMonitor_GetNewDevices(const LC_DEVMONITOR *um);
00070 LC_DEVICE_LIST *LC_DevMonitor_GetLostDevices(const LC_DEVMONITOR *um);
00071 LC_DEVICE_LIST *LC_DevMonitor_GetCurrentDevices(const LC_DEVMONITOR *um);
00072
00073
00074
00075
00076 LC_DEVICE *LC_Device_new(LC_DEVICE_BUSTYPE busType,
00077 uint32_t busId,
00078 uint32_t deviceId,
00079 uint32_t vendorId,
00080 uint32_t productId);
00081 void LC_Device_free(LC_DEVICE *ud);
00082 LC_DEVICE *LC_Device_dup(const LC_DEVICE *od);
00083
00084
00085 LC_DEVICE *LC_Device_List_Find(LC_DEVICE_LIST *dl,
00086 LC_DEVICE_BUSTYPE busType,
00087 uint32_t busId,
00088 uint32_t deviceId,
00089 uint32_t vendorId,
00090 uint32_t productId,
00091 int usbClass);
00092
00093 LC_DEVICE *LC_Device_Get(LC_DEVICE_LIST *dl,
00094 LC_DEVICE_BUSTYPE busType,
00095 uint32_t dpos);
00096
00097
00098 uint32_t LC_Device_GetDevicePos(const LC_DEVICE *ud);
00099 void LC_Device_SetDevicePos(LC_DEVICE *ud, uint32_t i);
00100
00101 const char *LC_Device_GetPath(const LC_DEVICE *ud);
00102 void LC_Device_SetPath(LC_DEVICE *ud, const char *s);
00103
00104 LC_DEVICE_BUSTYPE LC_Device_GetBusType(const LC_DEVICE *ud);
00105 uint32_t LC_Device_GetBusId(const LC_DEVICE *ud);
00106 uint32_t LC_Device_GetDeviceId(const LC_DEVICE *ud);
00107 uint32_t LC_Device_GetVendorId(const LC_DEVICE *ud);
00108 uint32_t LC_Device_GetProductId(const LC_DEVICE *ud);
00109
00110 int LC_Device_GetUsbClass(const LC_DEVICE *ud);
00111 void LC_Device_SetUsbClass(LC_DEVICE *ud, int i);
00112
00113 const char *LC_Device_GetBusName(const LC_DEVICE *ud);
00114 void LC_Device_SetBusName(LC_DEVICE *ud, const char *s);
00115
00116 const char *LC_Device_GetDeviceName(const LC_DEVICE *ud);
00117 void LC_Device_SetDeviceName(LC_DEVICE *ud, const char *s);
00118
00119 const char *LC_Device_GetDriverType(const LC_DEVICE *ud);
00120 void LC_Device_SetDriverType(LC_DEVICE *ud, const char *s);
00121
00122 const char *LC_Device_GetReaderType(const LC_DEVICE *ud);
00123 void LC_Device_SetReaderType(LC_DEVICE *ud, const char *s);
00124
00125 const char *LC_Device_GetHalPath(const LC_DEVICE *ud);
00126 void LC_Device_SetHalPath(LC_DEVICE *ud, const char *s);
00127
00128 int LC_Device_ReplaceVars(const LC_DEVICE *d, const char *tmpl,
00129 GWEN_BUFFER *buf);
00130
00131
00132 #endif