laatzen/TBF_V2/Sources/TBF/GemCard/ICard.cs
2021-10-01 11:12:07 +02:00

150 lines
4.4 KiB
C#

using System;
namespace GemCard
{
/// <summary>
/// This interface gives access to the basic card functions. It must be implemented by a class.
/// </summary>
public interface ICard
{
/// <summary>
/// Wraps the PCSC funciton
/// LONG SCardListReaders(SCARDCONTEXT hContext,
/// LPCTSTR mszGroups,
/// LPTSTR mszReaders,
/// LPDWORD pcchReaders
/// );
/// </summary>
/// <returns>A string array of the readers</returns>
string[] ListReaders();
/// <summary>
/// Wraps the PCSC function
/// LONG SCardConnect(
/// IN SCARDCONTEXT hContext,
/// IN LPCTSTR szReader,
/// IN DWORD dwShareMode,
/// IN DWORD dwPreferredProtocols,
/// OUT LPSCARDHANDLE phCard,
/// OUT LPDWORD pdwActiveProtocol
/// );
/// </summary>
/// <param name="Reader"></param>
/// <param name="ShareMode"></param>
/// <param name="PreferredProtocols"></param>
void Connect(string Reader, SHARE ShareMode, PROTOCOL PreferredProtocols);
/// <summary>
/// Wraps the PCSC function
/// LONG SCardDisconnect(
/// IN SCARDHANDLE hCard,
/// IN DWORD dwDisposition
/// );
/// </summary>
/// <param name="Disposition"></param>
void Disconnect(DISCONNECT Disposition);
/// <summary>
/// Wraps the PCSC function
/// LONG SCardTransmit(
/// SCARDHANDLE hCard,
/// LPCSCARD_I0_REQUEST pioSendPci,
/// LPCBYTE pbSendBuffer,
/// DWORD cbSendLength,
/// LPSCARD_IO_REQUEST pioRecvPci,
/// LPBYTE pbRecvBuffer,
/// LPDWORD pcbRecvLength
/// );
/// </summary>
/// <param name="ApduCmd">APDUCommand object with the APDU to send to the card</param>
/// <returns>An APDUResponse object with the response from the card</returns>
APDUResponse Transmit(APDUCommand ApduCmd);
/// <summary>
/// Wraps the PSCS function
/// LONG SCardBeginTransaction(
/// SCARDHANDLE hCard
// );
/// </summary>
void BeginTransaction();
/// <summary>
/// Wraps the PCSC function
/// LONG SCardEndTransaction(
/// SCARDHANDLE hCard,
/// DWORD dwDisposition
/// );
/// </summary>
void EndTransaction(DISCONNECT Disposition);
/// <summary>
/// Gets the attributes of the card
/// </summary>
/// <param name="AttribId">Identifier for the Attribute to get</param>
/// <returns>Attribute content</returns>
byte[] GetAttribute(UInt32 AttribId);
}
/// <summary>
/// SCOPE context
/// </summary>
public enum SCOPE
{
/// <summary>
/// The context is a user context, and any database operations are performed within the
/// domain of the user.
/// </summary>
User,
/// <summary>
/// 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.)
/// </summary>
Terminal,
/// <summary>
/// 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.)
/// </summary>
System
}
/// <summary>
/// SHARE mode enumeration
/// </summary>
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.
}
/// <summary>
/// PROTOCOL enumeration
/// </summary>
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.
}
/// <summary>
/// DISCONNECT action enumeration
/// </summary>
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
}
}