/* ----------------------------------------------------------------------------
 * 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>Class that represent one Pin.</summary> 
public class PTEID_Pin : PTEID_Crypto {
  private HandleRef swigCPtr;

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

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

  ~PTEID_Pin() {
    Dispose();
  }

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

  /// <summary>Get the index of the pin.</summary>
  public uint getIndex()
  {
    uint ret = pteidlib_dotNetPINVOKE.PTEID_Pin_getIndex(swigCPtr);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Get the type of the pin.</summary>
  public uint getType()
  {
    uint ret = pteidlib_dotNetPINVOKE.PTEID_Pin_getType(swigCPtr);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Get the id of the pin.</summary>
  public uint getId()
  {
    uint ret = pteidlib_dotNetPINVOKE.PTEID_Pin_getId(swigCPtr);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Get the usage code of the pin.</summary>
  public PTEID_PinUsage getUsageCode()
  {
    PTEID_PinUsage ret = (PTEID_PinUsage)pteidlib_dotNetPINVOKE.PTEID_Pin_getUsageCode(swigCPtr);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Get the flags of the pin.</summary>
  public uint getFlags()
  {
    uint ret = pteidlib_dotNetPINVOKE.PTEID_Pin_getFlags(swigCPtr);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Get the label of the pin.</summary>
  public string getLabel()
  {
    string ret = pteidlib_dotNetPINVOKE.PTEID_Pin_getLabel(swigCPtr);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Return the signature of the pin.</summary>
  public PTEID_ByteArray getSignature()
  {
    PTEID_ByteArray ret = new PTEID_ByteArray(pteidlib_dotNetPINVOKE.PTEID_Pin_getSignature(swigCPtr), false);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>
  /// Return the remaining tries for giving the good pin.
  /// This opperation is not supported by all card.
  /// </summary>
   /// <returns>
   /// -1 if not supported 
   /// the number of remaining tries in the other case
   /// </returns> 
  public int getTriesLeft()
  {
    int ret = pteidlib_dotNetPINVOKE.PTEID_Pin_getTriesLeft(swigCPtr);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>
  /// Ask the card to verify the pin.
  /// A popup will ask for the code.
  /// </summary>
  /// <returns>true if success and false if failed</returns>  
  public bool verifyPin() {
    bool ret = pteidlib_dotNetPINVOKE.PTEID_Pin_verifyPin__SWIG_0(swigCPtr);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>Ask the card to verify the pin.</summary>
  /// <param name="csPin">is the pin code to verify (if csPin is empty, a popup will ask for the code)</param>  
  /// <param name="ulRemaining">return the remaining tries (only if verifying failed)</param>  
  /// <returns>true if success and false if failed</returns> 
  public bool verifyPin(string csPin, ref uint ulRemaining)
  {
    bool ret = pteidlib_dotNetPINVOKE.PTEID_Pin_verifyPin__SWIG_1(swigCPtr, csPin, ref ulRemaining);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>
  /// Ask the card to change the pin.
  /// A popup will ask for the codes.
  /// </summary>
  /// <returns>true if success and false if failed</returns> 
  public bool changePin()
  {
    bool ret = pteidlib_dotNetPINVOKE.PTEID_Pin_changePin__SWIG_0(swigCPtr);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  /// <summary>
  /// Ask the card to change the pin.
  /// if csPin1 or csPin2 are empty, a popup will ask for the codes.
  /// </summary>
  /// <param name="csPin1">is the old pin code</param>  
  /// <param name="csPin2">is the new pin code</param>  
  /// <param name="ulRemaining">return the remaining tries (only when operation failed)</param>  
  /// <returns>true if success and false if failed</returns> 
  public bool changePin(string csPin1, string csPin2, ref uint ulRemaining)
  {
    bool ret = pteidlib_dotNetPINVOKE.PTEID_Pin_changePin__SWIG_1(swigCPtr, csPin1, csPin2, ref ulRemaining);
    if (pteidlib_dotNetPINVOKE.SWIGPendingException.Pending) throw pteidlib_dotNetPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

}

}
