/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 1.3.35
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

namespace be.portugal.eid {

using System;
using System.Runtime.InteropServices;

/// <summary>
/// This class represents a Portugal EID card.
/// To get such an object you have to ask it from the ReaderContext.
/// </summary>
public class PTEID_EIDCard : PTEID_SmartCard {
  private HandleRef swigCPtr;

  internal PTEID_EIDCard(IntPtr cPtr, bool cMemoryOwn) : base(pteidlib_dotNetPINVOKE.PTEID_EIDCardUpcast(cPtr), cMemoryOwn) {
    swigCPtr = new HandleRef(this, cPtr);
  }

  internal static HandleRef getCPtr(PTEID_EIDCard obj) {
    return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
  }

  ~PTEID_EIDCard() {
    Dispose();
  }

  public override void Dispose() {
    lock(this) {
      if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
        swigCMemOwn = false;
        pteidlib_dotNetPINVOKE.delete_PTEID_EIDCard(swigCPtr);
      }
      swigCPtr = new HandleRef(null, IntPtr.Zero);
      GC.SuppressFinalize(this);
      base.Dispose();
    }
  }

  /// <summary>Return true if the user allow the application.</summary>
  public static bool isApplicationAllowed()
  {
    bool ret = pteidlib_dotNetPINVOKE.PTEID_EIDCard_isApplicationAllowed();
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Return true this is a test card.</summary>
  public virtual bool isTestCard()
  {
    bool ret = pteidlib_dotNetPINVOKE.PTEID_EIDCard_isTestCard(swigCPtr);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Return true if test card are allowed.</summary>
  public virtual bool getAllowTestCard()
  {
    bool ret = pteidlib_dotNetPINVOKE.PTEID_EIDCard_getAllowTestCard(swigCPtr);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Set the flag to allow the test cards.</summary>
  public virtual void setAllowTestCard(bool allow)
  {
    pteidlib_dotNetPINVOKE.PTEID_EIDCard_setAllowTestCard(swigCPtr, allow);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
  }

  /// <summary>
  /// Return the status of the data (RRN certificate validity).
  /// </summary>
  public virtual PTEID_CertifStatus getDataStatus()
  {
    PTEID_CertifStatus ret = (PTEID_CertifStatus)pteidlib_dotNetPINVOKE.PTEID_EIDCard_getDataStatus(swigCPtr);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>
  /// Return a document from the card.
  /// </summary>
  /// <remarks>
  /// Throw PTEID_ExDocTypeUnknown exception if the document doesn't exist for this card.
  /// </remarks>
  public override PTEID_XMLDoc getDocument(PTEID_DocumentType type)
  {
	switch(type)
	{
	case PTEID_DocumentType.PTEID_DOCTYPE_FULL:
		return getFullDoc();
	case PTEID_DocumentType.PTEID_DOCTYPE_ID:
		return getID();
	case PTEID_DocumentType.PTEID_DOCTYPE_PICTURE:
		return getPicture();
	case PTEID_DocumentType.PTEID_DOCTYPE_INFO:
		return getVersionInfo();
	case PTEID_DocumentType.PTEID_DOCTYPE_PINS:
		return getPins();
	case PTEID_DocumentType.PTEID_DOCTYPE_CERTIFICATES:
		return getCertificates();
	default:
		throw new PTEID_ExDocTypeUnknown();
	}
}
  /// <summary>Get the full document.</summary>
  public PTEID_EIdFullDoc getFullDoc() {
    PTEID_EIdFullDoc ret = new PTEID_EIdFullDoc(pteidlib_dotNetPINVOKE.PTEID_EIDCard_getFullDoc(swigCPtr), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Get the id document.</summary>
  public PTEID_EId getID() {
    PTEID_EId ret = new PTEID_EId(pteidlib_dotNetPINVOKE.PTEID_EIDCard_getID(swigCPtr), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Get the picture document.</summary>
  public PTEID_Picture getPicture() {
    PTEID_Picture ret = new PTEID_Picture(pteidlib_dotNetPINVOKE.PTEID_EIDCard_getPicture(swigCPtr), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Get the info document.</summary>
  public PTEID_CardVersionInfo getVersionInfo() {
    PTEID_CardVersionInfo ret = new PTEID_CardVersionInfo(pteidlib_dotNetPINVOKE.PTEID_EIDCard_getVersionInfo(swigCPtr), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Return certificate by type from the card.</summary>
  public PTEID_Certificate getCert(PTEID_CertifType type) {
    PTEID_Certificate ret = new PTEID_Certificate(pteidlib_dotNetPINVOKE.PTEID_EIDCard_getCert(swigCPtr, (int)type), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Return the RRN certificate from the card.</summary>
  public PTEID_Certificate getRrn() {
    PTEID_Certificate ret = new PTEID_Certificate(pteidlib_dotNetPINVOKE.PTEID_EIDCard_getRrn(swigCPtr), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Return the root certificate from the card.</summary>
  public PTEID_Certificate getRoot() {
    PTEID_Certificate ret = new PTEID_Certificate(pteidlib_dotNetPINVOKE.PTEID_EIDCard_getRoot(swigCPtr), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Return the ca certificate from the card.</summary>
  public PTEID_Certificate getCA() {
    PTEID_Certificate ret = new PTEID_Certificate(pteidlib_dotNetPINVOKE.PTEID_EIDCard_getCA(swigCPtr), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Return the signature certificate from the card.</summary>
  public PTEID_Certificate getSignature()
  {
    PTEID_Certificate ret = new PTEID_Certificate(pteidlib_dotNetPINVOKE.PTEID_EIDCard_getSignature(swigCPtr), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Return the authentication certificate from the card.</summary>
  public PTEID_Certificate getAuthentication()
  {
    PTEID_Certificate ret = new PTEID_Certificate(pteidlib_dotNetPINVOKE.PTEID_EIDCard_getAuthentication(swigCPtr), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>
  /// Return a raw data from the card.
  /// </summary>
  /// <remarks>
  /// Throw PTEID_ExFileTypeUnknown exception if the document doesn't exist for this card. 
  /// </remarks>
  public override PTEID_ByteArray getRawData(PTEID_RawDataType type)
  {
    PTEID_ByteArray ret = new PTEID_ByteArray(pteidlib_dotNetPINVOKE.PTEID_EIDCard_getRawData(swigCPtr, (int)type), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Get the Id RawData.</summary>
  public PTEID_ByteArray getRawData_Id()
  {
    PTEID_ByteArray ret = new PTEID_ByteArray(pteidlib_dotNetPINVOKE.PTEID_EIDCard_getRawData_Id(swigCPtr), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Get the IdSig RawData.</summary>
  public PTEID_ByteArray getRawData_IdSig()
  {
    PTEID_ByteArray ret = new PTEID_ByteArray(pteidlib_dotNetPINVOKE.PTEID_EIDCard_getRawData_IdSig(swigCPtr), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Get the Addr RawData.</summary>
  public PTEID_ByteArray getRawData_Addr()
  {
    PTEID_ByteArray ret = new PTEID_ByteArray(pteidlib_dotNetPINVOKE.PTEID_EIDCard_getRawData_Addr(swigCPtr), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Get the AddrSig RawData.</summary>
  public PTEID_ByteArray getRawData_AddrSig()
  {
    PTEID_ByteArray ret = new PTEID_ByteArray(pteidlib_dotNetPINVOKE.PTEID_EIDCard_getRawData_AddrSig(swigCPtr), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Get the picture RawData.</summary>
  public PTEID_ByteArray getRawData_Picture()
  {
    PTEID_ByteArray ret = new PTEID_ByteArray(pteidlib_dotNetPINVOKE.PTEID_EIDCard_getRawData_Picture(swigCPtr), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Get the Card Info RawData.</summary>
  public PTEID_ByteArray getRawData_CardInfo()
  {
    PTEID_ByteArray ret = new PTEID_ByteArray(pteidlib_dotNetPINVOKE.PTEID_EIDCard_getRawData_CardInfo(swigCPtr), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Get the Token Info RawData.</summary>
  public PTEID_ByteArray getRawData_TokenInfo()
  {
    PTEID_ByteArray ret = new PTEID_ByteArray(pteidlib_dotNetPINVOKE.PTEID_EIDCard_getRawData_TokenInfo(swigCPtr), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Get the Cert RRN RawData.</summary>
  public PTEID_ByteArray getRawData_CertRRN()
  {
    PTEID_ByteArray ret = new PTEID_ByteArray(pteidlib_dotNetPINVOKE.PTEID_EIDCard_getRawData_CertRRN(swigCPtr), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Get the challenge RawData.</summary>
  public PTEID_ByteArray getRawData_Challenge()
  {
    PTEID_ByteArray ret = new PTEID_ByteArray(pteidlib_dotNetPINVOKE.PTEID_EIDCard_getRawData_Challenge(swigCPtr), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Get the response RawData.</summary>
  public PTEID_ByteArray getRawData_Response()
  {
    PTEID_ByteArray ret = new PTEID_ByteArray(pteidlib_dotNetPINVOKE.PTEID_EIDCard_getRawData_Response(swigCPtr), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

}

}
