using System;
namespace GemCard
{
///
/// This interface gives access to the basic card functions. It must be implemented by a class.
///
public interface ICard
{
///
/// Wraps the PCSC funciton
/// LONG SCardListReaders(SCARDCONTEXT hContext,
/// LPCTSTR mszGroups,
/// LPTSTR mszReaders,
/// LPDWORD pcchReaders
/// );
///
/// A string array of the readers
string[] ListReaders();
///
/// Wraps the PCSC function
/// LONG SCardConnect(
/// IN SCARDCONTEXT hContext,
/// IN LPCTSTR szReader,
/// IN DWORD dwShareMode,
/// IN DWORD dwPreferredProtocols,
/// OUT LPSCARDHANDLE phCard,
/// OUT LPDWORD pdwActiveProtocol
/// );
///
///
///
///
void Connect(string Reader, SHARE ShareMode, PROTOCOL PreferredProtocols);
///
/// Wraps the PCSC function
/// LONG SCardDisconnect(
/// IN SCARDHANDLE hCard,
/// IN DWORD dwDisposition
/// );
///
///
void Disconnect(DISCONNECT Disposition);
///
/// Wraps the PCSC function
/// LONG SCardTransmit(
/// SCARDHANDLE hCard,
/// LPCSCARD_I0_REQUEST pioSendPci,
/// LPCBYTE pbSendBuffer,
/// DWORD cbSendLength,
/// LPSCARD_IO_REQUEST pioRecvPci,
/// LPBYTE pbRecvBuffer,
/// LPDWORD pcbRecvLength
/// );
///
/// APDUCommand object with the APDU to send to the card
/// An APDUResponse object with the response from the card
APDUResponse Transmit(APDUCommand ApduCmd);
///
/// Wraps the PSCS function
/// LONG SCardBeginTransaction(
/// SCARDHANDLE hCard
// );
///
void BeginTransaction();
///
/// Wraps the PCSC function
/// LONG SCardEndTransaction(
/// SCARDHANDLE hCard,
/// DWORD dwDisposition
/// );
///
void EndTransaction(DISCONNECT Disposition);
///
/// Gets the attributes of the card
///
/// Identifier for the Attribute to get
/// Attribute content
byte[] GetAttribute(UInt32 AttribId);
}
///
/// SCOPE context
///
public enum SCOPE
{
///
/// The context is a user context, and any database operations are performed within the
/// domain of the user.
///
User,
///
/// The context is that of the current terminal, and any database operations are performed
/// within the domain of that terminal. (The calling application must have appropriate
/// access permissions for any database actions.)
///
Terminal,
///
/// The context is the system context, and any database operations are performed within the
/// domain of the system. (The calling application must have appropriate access
/// permissions for any database actions.)
///
System
}
///
/// SHARE mode enumeration
///
public enum SHARE
{
Exclusive = 1, /// This app. is not willing to share this card with other applications.
Shared, /// This app. is willing to share this card with other applications.
Direct, /// This app. demands direct control of the reader, so it is not available to other applications.
}
///
/// PROTOCOL enumeration
///
public enum PROTOCOL
{
Undefined = 0x00000000, /// There is no active protocol.
T0 = 0x00000001, /// T=0 is the active protocol.
T1 = 0x00000002, /// T=1 is the active protocol.
T0orT1 = T0 | T1, /// T=1 or T=0 can be the active protocol
Raw = 0x00010000, /// Raw is the active protocol.
Default = unchecked ((int) 0x80000000), /// Use implicit PTS.
}
///
/// DISCONNECT action enumeration
///
public enum DISCONNECT
{
Leave, /// Don't do anything special on close
Reset, /// Reset the card on close
Unpower, /// Power down the card on close
Eject, /// Eject(!) the card on close
}
}