§
    Étºf%  ã                   óÚ   — d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z	 ddl
mZ ddlmZ ddlmZmZ  G d	„ d
¦  «        Z G d„ d¦  «        Z G d„ d¦  «        Z G d„ de	j        ¦  «        ZdS )zyInstance Messenger base classes for protocol support.

You will find these useful if you're adding a new protocol to IM.
é    )ÚType)Úerror)ÚProtocolÚconnectionDone)Ústyles)ÚFailure©ÚprefixedMethods)ÚOFFLINEÚOfflineErrorc                   óD   — e Zd Zd„ Zd„ Zd„ Zd„ Zd„ Zdefd„Z	defd„Z
d	S )
ÚAbstractGroupc                 ó"   — || _         || _        d S ©N)ÚnameÚaccount)Úselfr   r   s      ú[/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/words/im/basesupport.pyÚ__init__zAbstractGroup.__init__   s   € ØˆŒ	ØˆŒˆˆó    c                 ó"   — t          | d¦  «        S )z‹finds group commands

        these commands are methods on me that start with imgroup_; they are
        called with no arguments
        Úimgroup_r	   ©r   s    r   ÚgetGroupCommandszAbstractGroup.getGroupCommands   s   € õ ˜t ZÑ0Ô0Ð0r   c                 ó"   — t          | d¦  «        S )a(  finds group commands

        these commands are methods on me that start with imgroup_; they are
        called with a user present within this room as an argument

        you may want to override this in your group in order to filter for
        appropriate commands on the given user
        Ú	imtarget_r	   )r   Útargets     r   ÚgetTargetCommandszAbstractGroup.getTargetCommands#   s   € õ ˜t [Ñ1Ô1Ð1r   c                 ót   — | j         j        st          ‚| j         j                             | j        ¦  «         d S r   )r   Úclientr   Ú	joinGroupr   r   s    r   ÚjoinzAbstractGroup.join.   s6   € ØŒ|Ô"ð 	ÝÐØŒÔ×%Ò% d¤iÑ0Ô0Ð0Ð0Ð0r   c                 ót   — | j         j        st          ‚| j         j                             | j        ¦  «         d S r   )r   r    r   Ú
leaveGroupr   r   s    r   ÚleavezAbstractGroup.leave3   s6   € ØŒ|Ô"ð 	ÝÐØŒÔ×&Ò& t¤yÑ1Ô1Ð1Ð1Ð1r   Úreturnc                 ó(   — d| j         › d| j        ›d�S )Nú<ú ú>)Ú	__class__r   r   s    r   Ú__repr__zAbstractGroup.__repr__8   s   € Ø2�4”>Ð2Ð2 D¤IÐ2Ð2Ð2Ð2r   c                 ó.   — | j         › d| j        j        › �S ©Nú@©r   r   ÚaccountNamer   s    r   Ú__str__zAbstractGroup.__str__;   ó   € Ø”)Ð8Ð8˜dœlÔ6Ð8Ð8Ð8r   N)Ú__name__Ú
__module__Ú__qualname__r   r   r   r"   r%   Ústrr,   r2   © r   r   r   r      s•   € € € € € ðð ð ð1ð 1ð 1ð	2ð 	2ð 	2ð1ð 1ð 1ð
2ð 2ð 2ð
3˜#ð 3ð 3ð 3ð 3ð9˜ð 9ð 9ð 9ð 9ð 9ð 9r   r   c                   ó8   — e Zd Zd„ Zd„ Zd„ Zdefd„Zdefd„ZdS )ÚAbstractPersonc                 ó:   — || _         || _        t          | _        d S r   )r   r   r   Ústatus)r   r   ÚbaseAccounts      r   r   zAbstractPerson.__init__@   s   € ØˆŒ	Ø"ˆŒÝˆŒˆˆr   c                 ó"   — t          | d¦  «        S )z�finds person commands

        these commands are methods on me that start with imperson_; they are
        called with no arguments
        Ú	imperson_r	   r   s    r   ÚgetPersonCommandsz AbstractPerson.getPersonCommandsE   s   € õ ˜t [Ñ1Ô1Ð1r   c                 ó   — dS )z#
        Returns a string.
        z--r8   r   s    r   ÚgetIdleTimezAbstractPerson.getIdleTimeM   s	   € ð ˆtr   r&   c                 ó8   — d| j         › d| j        ›d| j        › d�S )Nr(   r)   ú/r*   )r+   r   r<   r   s    r   r,   zAbstractPerson.__repr__S   s)   € Ø@�4”>Ð@Ð@ D¤IÐ@Ð@°$´+Ð@Ð@Ð@Ð@r   c                 ó.   — | j         › d| j        j        › �S r.   r0   r   s    r   r2   zAbstractPerson.__str__V   r3   r   N)	r4   r5   r6   r   r@   rB   r7   r,   r2   r8   r   r   r:   r:   ?   s|   € € € € € ðð ð ð
2ð 2ð 2ðð ð ðA˜#ð Að Að Að Að9˜ð 9ð 9ð 9ð 9ð 9ð 9r   r:   c                   óT   — e Zd ZU dZdZee         ed<   d„ Zd„ Z	e
fdeddfd„Zd	„ ZdS )
ÚAbstractClientMixinz–Designed to be mixed in to a Protocol implementing class.

    Inherit from me first.

    @ivar _logonDeferred: Fired when I am done logging in.
    NÚ
_protoBasec                 ó–   — | j         j        D ]%}t          |t          ¦  «        r|| j         _         nŒ&	 || _        || _        || _        d S r   )r+   Ú	__bases__Ú
issubclassr   rH   r   ÚchatÚ_logonDeferred)r   r   ÚchatuiÚlogonDeferredÚbases        r   r   zAbstractClientMixin.__init__d   s]   € Ø”NÔ,ð 	ð 	ˆDÝ˜$¥Ñ)Ô)ð Ø,0�”Ô)Ø�ðð ØˆŒØˆŒ	Ø+ˆÔÐÐr   c                 ó:   — | j                              | ¦  «         d S r   )rH   ÚconnectionMader   s    r   rR   z"AbstractClientMixin.connectionMadeo   s   € ØŒ×&Ò& tÑ,Ô,Ð,Ð,Ð,r   Úreasonr&   c                 ó–   — | j                              | |¦  «         |                      ¦   «          | j                             | |¦  «        S r   )r   Ú_clientLostÚunregisterAsAccountClientrH   ÚconnectionLost©r   rS   s     r   rW   z"AbstractClientMixin.connectionLostr   sD   € ØŒ× Ò   vÑ.Ô.Ð.Ø×&Ò&Ñ(Ô(Ð(ØŒ×-Ò-¨d°FÑ;Ô;Ð;r   c                 ó:   — | j                              | ¦  «         dS )z*Tell the chat UI that I have `signed off'.N)rL   ÚunregisterAccountClientr   s    r   rV   z-AbstractClientMixin.unregisterAsAccountClientw   s   € àŒ	×)Ò)¨$Ñ/Ô/Ð/Ð/Ð/r   )r4   r5   r6   Ú__doc__rH   r   r   Ú__annotations__r   rR   r   r   rW   rV   r8   r   r   rG   rG   Z   s�   € € € € € € ðð ð "&€J��X”Ð%Ð%Ñ%ð	,ð 	,ð 	,ð-ð -ð -ð 0>ð <ð < Wð <À$ð <ð <ð <ð <ð
0ð 0ð 0ð 0ð 0r   rG   c                   óx   — e Zd ZdZdZdZdZeZe	Z
dZd„ Zd„ Zd„ Zd„ Zd	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zdefd„ZdS )ÚAbstractAccounta  Base class for Accounts.

    I am the start of an implementation of L{IAccount<interfaces.IAccount>}, I
    implement L{isOnline} and most of L{logOn}, though you'll need to implement
    L{_startLogOn} in a subclass.

    @cvar _groupFactory: A Callable that will return a L{IGroup} appropriate
        for this account type.
    @cvar _personFactory: A Callable that will return a L{IPerson} appropriate
        for this account type.

    @type _isConnecting: boolean
    @ivar _isConnecting: Whether I am in the process of establishing a
    connection to the server.
    @type _isOnline: boolean
    @ivar _isOnline: Whether I am currently on-line with the server.

    @ivar accountName:
    @ivar autoLogin:
    @ivar username:
    @ivar password:
    @ivar host:
    @ivar port:
    r   Né   c                 óv   — || _         || _        || _        || _        || _        || _        i | _        i | _        d S r   )r1   Ú	autoLoginÚusernameÚpasswordÚhostÚportÚ_groupsÚ_persons)r   r1   ra   rb   rc   rd   re   s          r   r   zAbstractAccount.__init__Ÿ   s?   € Ø&ˆÔØ"ˆŒØ ˆŒØ ˆŒØˆŒ	ØˆŒ	àˆŒØˆŒˆˆr   c                 óR   — dD ]#}t          | |¦  «        st          | |i ¦  «         Œ$d S )N)rf   rg   )ÚhasattrÚsetattr)r   Úks     r   ÚupgrateToVersion2z!AbstractAccount.upgrateToVersion2ª   s@   € à(ð 	%ð 	%ˆAÝ˜4 Ñ#Ô#ð %Ý˜˜a Ñ$Ô$Ð$øð	%ð 	%r   c                 óv   — t           j                             | ¦  «        }dD ]}	 ||= Œ# t          $ r Y Œw xY w|S )N)r    Ú	_isOnlineÚ_isConnecting)r   Ú	VersionedÚ__getstate__ÚKeyError)r   Ústaterk   s      r   rq   zAbstractAccount.__getstate__°   sZ   € ÝÔ ×-Ò-¨dÑ3Ô3ˆØ9ð 	ð 	ˆAðØ˜!�H�HøÝð ð ð Ø�ðøøøàˆs   ¥)©
6µ6c                 ó   — | j         S r   )rn   r   s    r   ÚisOnlinezAbstractAccount.isOnline¹   s
   € ØŒ~Ðr   c                 ó  — | j         ss| j        sld| _         |                      |¦  «        }|                     | j        ¦  «         |                     |j        ¦  «         |                     | j        ¦  «         |S t          j	        d¦  «        ‚)a=  Log on to this account.

        Takes care to not start a connection if a connection is
        already in progress.  You will need to implement
        L{_startLogOn} for this to work, and it would be a good idea
        to override L{_loginFailed} too.

        @returntype: Deferred L{interfaces.IClient}
        é   zConnection in progress)
ro   rn   Ú_startLogOnÚaddCallbackÚ	_cb_logOnÚregisterAccountClientÚ
addErrbackÚ_loginFailedr   ÚConnectError)r   rN   Úds      r   ÚlogOnzAbstractAccount.logOn¼   sŠ   € ð Ô"ð 	?¨T¬^ð 	?Ø!"ˆDÔØ× Ò  Ñ(Ô(ˆAØ�MŠM˜$œ.Ñ)Ô)Ð)ð �MŠM˜&Ô6Ñ7Ô7Ð7Ø�LŠL˜Ô*Ñ+Ô+Ð+ØˆHåÔ$Ð%=Ñ>Ô>Ð>r   c                 ó~   — | j                              |¦  «        }|€ |                      || ¦  «        }|| j         |<   |S )zkGroup factory.

        @param name: Name of the group on this account.
        @type name: string
        )rf   ÚgetÚ_groupFactory)r   r   Úgroups      r   ÚgetGroupzAbstractAccount.getGroupÓ   sD   € ð ”× Ò  Ñ&Ô&ˆØˆ=Ø×&Ò& t¨TÑ2Ô2ˆEØ!&ˆDŒL˜ÑØˆr   c                 ó~   — | j                              |¦  «        }|€ |                      || ¦  «        }|| j         |<   |S )zmPerson factory.

        @param name: Name of the person on this account.
        @type name: string
        )rg   r‚   Ú_personFactory)r   r   Úpersons      r   Ú	getPersonzAbstractAccount.getPersonß   sD   € ð ”×"Ò" 4Ñ(Ô(ˆØˆ>Ø×(Ò(¨¨tÑ4Ô4ˆFØ"(ˆDŒM˜$ÑØˆr   c                 ó   — t          ¦   «         ‚)z{Start the sign on process.

        Factored out of L{logOn}.

        @returntype: Deferred L{interfaces.IClient}
        )ÚNotImplementedError)r   rN   s     r   rx   zAbstractAccount._startLogOnë   s   € õ "Ñ#Ô#Ð#r   c                 ó0   — d| _         d| _        || _        |S )Nr   rw   )ro   rn   r    )r   r    s     r   rz   zAbstractAccount._cb_logOnô   s   € ØˆÔØˆŒØˆŒØˆr   c                 ó"   — d| _         d| _        |S )z¨Errorback for L{logOn}.

        @type reason: Failure

        @returns: I{reason}, for further processing in the callback chain.
        @returntype: Failure
        r   )ro   rn   rX   s     r   r}   zAbstractAccount._loginFailedú   s   € ð ˆÔØˆŒØˆr   c                 ó0   — d | _         d| _        d| _        |S )Nr   )r    ro   rn   )r   r    rS   s      r   rU   zAbstractAccount._clientLost  s   € ØˆŒØˆÔØˆŒØˆr   r&   c                 óf   — d                      | j        | j        | j        | j        | j        ¦  «        S )Nz<{}: {} ({}@{}:{})>)Úformatr+   r1   rb   rd   re   r   s    r   r,   zAbstractAccount.__repr__  s4   € Ø$×+Ò+ØŒNØÔØŒMØŒIØŒIñ
ô 
ð 	
r   )r4   r5   r6   r[   rn   ro   r    r   rƒ   r:   r‡   ÚpersistanceVersionr   rl   rq   ru   r€   r…   r‰   rx   rz   r}   rU   r7   r,   r8   r   r   r^   r^   |   sÿ   € € € € € ðð ð2 €IØ€MØ€Fà!€MØ#€NàÐð	ð 	ð 	ð%ð %ð %ðð ð ðð ð ð?ð ?ð ?ð.
ð 
ð 
ð
ð 
ð 
ð$ð $ð $ðð ð ð
ð 
ð 
ðð ð ð
˜#ð 
ð 
ð 
ð 
ð 
ð 
r   r^   N)r[   Útypingr   Útwisted.internetr   Útwisted.internet.protocolr   r   Útwisted.persistedr   Útwisted.python.failurer   Útwisted.python.reflectr
   Útwisted.words.im.localsr   r   r   r:   rG   rp   r^   r8   r   r   ú<module>r™      sV  ððð ð Ð Ð Ð Ð Ð à "Ð "Ð "Ð "Ð "Ð "Ø >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ø $Ð $Ð $Ð $Ð $Ð $Ø *Ð *Ð *Ð *Ð *Ð *Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9ð
&9ð &9ð &9ð &9ð &9ñ &9ô &9ð &9ðR9ð 9ð 9ð 9ð 9ñ 9ô 9ð 9ð60ð 0ð 0ð 0ð 0ñ 0ô 0ð 0ðDW
ð W
ð W
ð W
ð W
�fÔ&ñ W
ô W
ð W
ð W
ð W
r   