HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/twisted/words/im/__pycache__/basesupport.cpython-38.pyc
U


W[��@s�dZddlmZmZddlmZddlmZddlm	Z	ddl
mZGdd�d�ZGd	d
�d
�Z
Gdd�d�ZGd
d�de	j�ZdS)zyInstance Messenger base classes for protocol support.

You will find these useful if you're adding a new protocol to IM.
�)�OFFLINE�OfflineError)�Protocol��prefixedMethods)�styles)�errorc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�
AbstractGroupcCs||_||_dS�N)�name�account)�selfrr�r�>/usr/lib/python3/dist-packages/twisted/words/im/basesupport.py�__init__szAbstractGroup.__init__cCs
t|d�S)z�finds group commands

        these commands are methods on me that start with imgroup_; they are
        called with no arguments
        Zimgroup_r�r
rrr�getGroupCommandsszAbstractGroup.getGroupCommandscCs
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
        Z	imtarget_r)r
�targetrrr�getTargetCommands#s	zAbstractGroup.getTargetCommandscCs |jjst�|jj�|j�dSr
)r�clientrZ	joinGrouprrrrr�join.szAbstractGroup.joincCs |jjst�|jj�|j�dSr
)rrrZ
leaveGrouprrrrr�leave3szAbstractGroup.leavecCsd|j|jfS)Nz<%s %r>)�	__class__rrrrr�__repr__8szAbstractGroup.__repr__cCsd|j|jjfS�Nz%s@%s�rr�accountNamerrrr�__str__;szAbstractGroup.__str__N)
�__name__�
__module__�__qualname__rrrrrrrrrrrr	sr	c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�AbstractPersoncCs||_||_t|_dSr
)rrr�status)r
rZbaseAccountrrrr?szAbstractPerson.__init__cCs
t|d�S)z�finds person commands

        these commands are methods on me that start with imperson_; they are
        called with no arguments
        Z	imperson_rrrrr�getPersonCommandsDsz AbstractPerson.getPersonCommandscCsdS)z#
        Returns a string.
        z--rrrrr�getIdleTimeLszAbstractPerson.getIdleTimecCsd|j|j|jfS)Nz
<%s %r/%s>)rrr"rrrrrRszAbstractPerson.__repr__cCsd|j|jjfSrrrrrrrUszAbstractPerson.__str__N)rrr rr#r$rrrrrrr!>s
r!c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
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.
    cCs:|jjD]}t|t�r||j_q$q||_||_||_dSr
)r�	__bases__�
issubclassr�
_protoBaser�chatZ_logonDeferred)r
r�chatuiZ
logonDeferred�baserrrr_s
zAbstractClientMixin.__init__cCs|j�|�dSr
)r(�connectionMaderrrrr,jsz"AbstractClientMixin.connectionMadecCs$|j�||�|��|j�||�Sr
)r�_clientLost�unregisterAsAccountClientr(�connectionLost�r
�reasonrrrr/msz"AbstractClientMixin.connectionLostcCs|j�|�dS)z3Tell the chat UI that I have `signed off'.
        N)r)ZunregisterAccountClientrrrrr.rsz-AbstractClientMixin.unregisterAsAccountClientN)rrr �__doc__rr,r/r.rrrrr%Xs
r%c@s�eZdZdZdZdZdZeZe	Z
dZdd�Zdd�Z
d	d
�Zdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)�AbstractAccountaBase 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:
    rN�cCs4||_||_||_||_||_||_i|_i|_dSr
)r�	autoLogin�username�password�host�port�_groups�_persons)r
rr5r6r7r8r9rrrr�szAbstractAccount.__init__cCs$dD]}t||�st||i�qdS)N)r:r;)�hasattr�setattr)r
�krrr�upgrateToVersion2�s
z!AbstractAccount.upgrateToVersion2c	Cs:tj�|�}dD]$}z
||=Wqtk
r2YqXq|S)N)r�	_isOnline�
_isConnecting)r�	Versioned�__getstate__�KeyError)r
�stater>rrrrC�s
zAbstractAccount.__getstate__cCs|jSr
)r@rrrr�isOnline�szAbstractAccount.isOnlinecCsR|jsD|jsDd|_|�|�}|�|j�|�|j�|�|j�|St�	d��dS)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}
        �zConnection in progressN)
rAr@�_startLogOnZaddCallback�	_cb_logOnZregisterAccountClientZ
addErrback�_loginFailedrZConnectError)r
r*�drrr�logOn�s

zAbstractAccount.logOncCs.|j�|�}|dkr*|�||�}||j|<|S)zkGroup factory.

        @param name: Name of the group on this account.
        @type name: string
        N)r:�get�
_groupFactory)r
r�grouprrr�getGroup�s

zAbstractAccount.getGroupcCs.|j�|�}|dkr*|�||�}||j|<|S)zmPerson factory.

        @param name: Name of the person on this account.
        @type name: string
        N)r;rM�_personFactory)r
rZpersonrrr�	getPerson�s

zAbstractAccount.getPersoncCs
t��dS)z{Start the sign on process.

        Factored out of L{logOn}.

        @returntype: Deferred L{interfaces.IClient}
        N)�NotImplementedError)r
r*rrrrH�szAbstractAccount._startLogOncCsd|_d|_||_|S)NrrG)rAr@r)r
rrrrrI�szAbstractAccount._cb_logOncCsd|_d|_|S)z�Errorback for L{logOn}.

        @type reason: Failure

        @returns: I{reason}, for further processing in the callback chain.
        @returntype: Failure
        r)rAr@r0rrrrJ�szAbstractAccount._loginFailedcCsd|_d|_d|_|S)Nr)rrAr@)r
rr1rrrr-szAbstractAccount._clientLostcCsd|j|j|j|j|jfS)Nz<%s: %s (%s@%s:%s)>)rrr6r8r9rrrrrs�zAbstractAccount.__repr__)rrr r2r@rArr	rNr!rQZpersistanceVersionrr?rCrFrLrPrRrHrIrJr-rrrrrr3xs&		r3N)r2Ztwisted.words.im.localsrrZtwisted.internet.protocolrZtwisted.python.reflectrZtwisted.persistedrZtwisted.internetrr	r!r%rBr3rrrr�<module>s(