+
     h#  c                   s8    R t ^ RIHt ^ RIHt  ! R R]4      tR# )a  The CardConnection abstract class manages connections with a card and
apdu transmission.

__author__ = "https://www.gemalto.com/"

Copyright 2001-2012 gemalto
Author: Jean-Daniel Aussel, mailto:jean-daniel.aussel@gemalto.com

This file is part of pyscard.

pyscard is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

pyscard is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with pyscard; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
)CardConnectionEvent)
Observablec                   s   a  ] tR t^t o Rt^t ^t Rt ^t R t	R t
R tR tR tRR	 ltRR
 ltR tR tR tR tR tR tR tRR ltR tRR ltR tR tR tR tR tRtV t R# )CardConnectionzCard connection abstract class.i   c                s    \         P                  ! V 4       Wn         RV n         \        P
                  \        P                  ,          V n        R# )zuConstruct a new card connection.

@param reader: name of the reader in which the smartcard to connect
to is located.
N)r   __init__readererrorcheckingchainr   T0_protocolT1_protocoldefaultprotocol)selfr      &&?/usr/lib64/python3.14/site-packages/smartcard/CardConnection.pyr   ZCardConnection.__init__-   sA     	D!"&,-99N<V<VV5    c                    R# )zConnect to card.N r	      &r   __del__ZCardConnection.__del__;       r   c                sj    V P                   e%   V P                   ^ ,          P                  V4       R# R# )zAdd a status word exception class to be filtered.

@param exClass: the class to filter, e.g.
L{smartcard.sw.SWExceptions.WarningProcessingException}

Filtered exceptions will not be raised when encountered in the
error checking chain.N)r   ZaddFilterException)r	   ZexClassr
   r   addSWExceptionToFilterZ%CardConnection.addSWExceptionToFilter?   s.     "".##A&99'B /r   c                2    \         P                  ! W4       R# )z!Add a L{CardConnection} observer.N)r   addObserverr	   Zobserverr
   r   r   ZCardConnection.addObserverJ   s    t.r   c                r   )z$Remove a L{CardConnection} observer.N)r   deleteObserverr   r
   r   r   ZCardConnection.deleteObserverN   s    !!$1r   Nc                r    \         P                  ! V 4       \         P                  ! V \        R4      4       R# )a  Connect to card.
@param protocol: a bit mask of the protocols to use, from
L{CardConnection.T0_protocol}, L{CardConnection.T1_protocol},
L{CardConnection.RAW_protocol}, L{CardConnection.T15_protocol}

@param mode: C{smartcard.scard.SCARD_SHARE_SHARED} (default),
C{smartcard.scard.SCARD_SHARE_EXCLUSIVE} or
C{smartcard.scard.SCARD_SHARE_DIRECT}

@param disposition: C{smartcard.scard.SCARD_LEAVE_CARD}
(default), C{smartcard.scard.SCARD_RESET_CARD},
C{smartcard.scard.SCARD_UNPOWER_CARD} or
C{smartcard.scard.SCARD_EJECT_CARD}
connectNr   
setChangednotifyObserversr    r	   protocolZmodeZdisposition   &&&&r   r   ZCardConnection.connectR   s(     	d#""4)<Y)GHr   c                r   )a  Reconnect to card.
@param protocol: a bit mask of the protocols to use, from
L{CardConnection.T0_protocol}, L{CardConnection.T1_protocol},
L{CardConnection.RAW_protocol}, L{CardConnection.T15_protocol}

@param mode: C{smartcard.scard.SCARD_SHARE_SHARED} (default),
C{smartcard.scard.SCARD_SHARE_EXCLUSIVE} or
C{smartcard.scard.SCARD_SHARE_DIRECT}

@param disposition: C{smartcard.scard.SCARD_LEAVE_CARD},
C{smartcard.scard.SCARD_RESET_CARD} (default),
C{smartcard.scard.SCARD_UNPOWER_CARD} or
C{smartcard.scard.SCARD_EJECT_CARD}
	reconnectNr   r   r   r   r    ZCardConnection.reconnectd   s(     	d#""4)<[)IJr   c                r   )zDisconnect from card.
disconnectNr   r   r   r   r!   ZCardConnection.disconnectv   s&    d#""4)<\)JKr   c                r   )zRelease the context.releaseNr   r   r   r   r"   ZCardConnection.release{   s&    d#""4)<Y)GHr   c                r   )zReturn card ATRNr   r   r   r   getATRZCardConnection.getATR   r   r   c                    V P                   # )zReturn bit mask for the protocol of connection, or None if no
protocol set.  The return value is a bit mask of
L{CardConnection.T0_protocol}, L{CardConnection.T1_protocol},
L{CardConnection.RAW_protocol}, L{CardConnection.T15_protocol}
r   r   r   r   getProtocolZCardConnection.getProtocol   s     ###r   c                r$   )zReturn card connection reader)r   r   r   r   	getReaderZCardConnection.getReader   s    {{r   c                    Wn         R# )a  Add an error checking chain.
@param errorcheckingchain: a L{smartcard.sw.ErrorCheckingChain}
object The error checking strategies in errorchecking chain will
be tested with each received response APDU, and a
L{smartcard.sw.SWExceptions.SWException} will be raised upon
error.N)r   )r	   r   r
   r   setErrorCheckingChainZ$CardConnection.setErrorCheckingChain   s
     #5r   c                r(   )a  Set protocol for card connection.
@param protocol: a bit mask of L{CardConnection.T0_protocol},
L{CardConnection.T1_protocol}, L{CardConnection.RAW_protocol},
L{CardConnection.T15_protocol}

>>> setProtocol(CardConnection.T1_protocol | CardConnection.T0_protocol)
Nr%   )r	   r   r
   r   setProtocolZCardConnection.setProtocol   s
      (r   c           	     sd   \         P                  ! V 4       \         P                  ! V \        RW.4      4       V P	                  W4      w  r4p\         P                  ! V 4       \         P                  ! V \        RW4V.4      4       V P
                  e   V P
                  ^ ,          ! W4V4       W4V3# )a  Transmit an apdu. Internally calls L{doTransmit()} class method
and notify observers upon command/response APDU events.
Subclasses must override the L{doTransmit()} class method.

@param command:    list of bytes to transmit

@param protocol:   the transmission protocol, from
            L{CardConnection.T0_protocol},
            L{CardConnection.T1_protocol}, or
            L{CardConnection.RAW_protocol}
commandresponse)r   r   r   r    
doTransmitr   )r	   r+   r   dataZsw1Zsw2s   &&&   r   transmitZCardConnection.transmit   s     	d#""%i'1DE	
 ;3d#""%j4c2BC	
 "".##A&t#6#~r   c                s    . ^ ^ 3# )zqPerforms the command APDU transmission.

Subclasses must override this method for implementing apdu
transmission.r   )r	   r+   r      &&&r   r-   ZCardConnection.doTransmit   s    
 1axr   c                s`   Vf   . p\         P                  ! V 4       \         P                  ! V \        RW.4      4       V P	                  W4      p\         P                  ! V 4       \         P                  ! V \        RV4      4       V P
                  e   V P
                  ^ ,          ! V4       V# )a  Send a control command and buffer.  Internally calls
L{doControl()} class method and notify observers upon
command/response events.  Subclasses must override the
L{doControl()} class method.

@param controlCode: command code

@param command:     list of bytes to transmit
r+   r,   )r   r   r   r    	doControlr   )r	   controlCoder+   r.   s   &&& r   controlZCardConnection.control   s     ?Gd#""%i+1GH	
 ~~k3d#""4)<Z)NO"".##A&t,r   c                    . # )z]Performs the command control.

Subclasses must override this method for implementing control.r   )r	   r2   r+   r0   r   r1   ZCardConnection.doControl   	     	r   c                s    \         P                  ! V 4       \         P                  ! V \        RV.4      4       V P	                  V4      pV P
                  e   V P
                  ^ ,          ! V4       V# )zmreturn the requested attribute

@param attribId: attribute id like
C{smartcard.scard.SCARD_ATTR_VENDOR_NAME}
Zattrib)r   r   r   r    doGetAttribr   )r	   attribIdr.   s   && r   	getAttribZCardConnection.getAttrib   s`     	d#""4)<Xz)RS)"".##A&t,r   c                r4   )zcPerforms the command get attrib.

Subclasses must override this method for implementing get attrib.r   )r	   r7   r
   r   r6   ZCardConnection.doGetAttrib   r5   r   c                s    V # )zEnter the runtime context.r   r   r   r   	__enter__ZCardConnection.__enter__   s    r   c                s&    V P                  4        R# )z.Exit the runtime context trying to disconnect.N)r!   )r	   ZtypeZvalueZ	tracebackr   r   __exit__ZCardConnection.__exit__   s    r   )r   r   r   )NNN)N)!Z__name__Z
__module__Z__qualname__Z__firstlineno____doc__r   r   ZRAW_protocolZT15_protocolr   r   r   r   r   r   r    r!   r"   r#   r&   r'   r)   r*   r/   r-   r3   r1   r8   r6   r9   r:   Z__static_attributes__Z__classdictcell__)Z__classdict__s   @r   r   r      s     )KKL6L6	C/2I$K$L
I
$5(2. r   r   N)r;   Zsmartcard.CardConnectionEventr    Zsmartcard.Observerr   r   r   r   r   <module>r<      s    2 > )[Z [r   