U
    
W[P!                     @   sp   d dl mZmZ G dd deZG dd deZG dd deZG dd	 d	eZG d
d deZddd	dgZdS )    )	Interface	Attributec                   @   s    e Zd ZdZedZdd ZdS )IProtocolPluginzDInterface for plugins providing an interface to a Words service
    zHA single word describing what kind of interface this is (eg, irc or web)c                 C   s   dS )ab  Retrieve a C{twisted.internet.interfaces.IServerFactory} provider

        @param realm: An object providing C{twisted.cred.portal.IRealm} and
        L{IChatService}, with which service information should be looked up.

        @param portal: An object providing C{twisted.cred.portal.IPortal},
        through which logins should be performed.
        N )realmZportalr   r   6/usr/lib/python3/dist-packages/twisted/words/iwords.py
getFactory   s    zIProtocolPlugin.getFactoryN)__name__
__module____qualname____doc__r   namer   r   r   r   r   r      s   r   c                   @   sF   e Zd ZedZdd ZdddZdd Zd	d
 Zdd Z	dd Z
dS )IGroupz$A short string, unique among groups.c                 C   s   dS )zLInclude the given user in this group.

        @type user: L{IUser}
        Nr   )userr   r   r   add   s    z
IGroup.addNc                 C   s   dS )znRemove the given user from this group.

        @type user: L{IUser}
        @type reason: C{unicode}
        Nr   )r   reasonr   r   r   remove"   s    zIGroup.removec                   C   s   dS )zReturn the number of participants in this group.

        @rtype: L{twisted.internet.defer.Deferred}
        @return: A Deferred which fires with an C{int} representing the
        number of participants in this group.
        Nr   r   r   r   r   size)   s    zIGroup.sizec                 C   s   dS )aY  
        Broadcast the given message from the given sender to other
        users in group.

        The message is not re-transmitted to the sender.

        @param sender: L{IUser}

        @type recipient: L{IGroup}
        @param recipient: This is probably a wart.  Maybe it will be removed
        in the future.  For now, it should be the group object the message
        is being delivered to.

        @param message: C{dict}

        @rtype: L{twisted.internet.defer.Deferred}
        @return: A Deferred which fires with None when delivery has been
        attempted for all users.
        Nr   Zsender	recipientmessager   r   r   receive1   s    zIGroup.receivec                 C   s   dS )zUChange the metadata associated with this group.

        @type meta: C{dict}
        Nr   )metar   r   r   setMetadataF   s    zIGroup.setMetadatac                   C   s   dS )z7Return an iterator of all users in this group.
        Nr   r   r   r   r   	iterusersL   s    zIGroup.iterusers)N)r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r      s   
r   c                   @   s:   e Zd ZdZedZdd Zdd Zdd Zdd
dZ	d	S )IChatClientzAInterface through which IChatService interacts with clients.
    z[A short string, unique among users.  This will be set by the L{IChatService} at login time.c                 C   s   dS )a^  
        Callback notifying this user of the given message sent by the
        given user.

        This will be invoked whenever another user sends a message to a
        group this user is participating in, or whenever another user sends
        a message directly to this user.  In the former case, C{recipient}
        will be the group to which the message was sent; in the latter, it
        will be the same object as the user who is receiving the message.

        @type sender: L{IUser}
        @type recipient: L{IUser} or L{IGroup}
        @type message: C{dict}

        @rtype: L{twisted.internet.defer.Deferred}
        @return: A Deferred which fires when the message has been delivered,
        or which fails in some way.  If the Deferred fails and the message
        was directed at a group, this user will be removed from that group.
        Nr   r   r   r   r   r   W   s    zIChatClient.receivec                 C   s   dS )z
        Callback notifying this user that the metadata for the given
        group has changed.

        @type group: L{IGroup}
        @type meta: C{dict}

        @rtype: L{twisted.internet.defer.Deferred}
        Nr   )groupr   r   r   r   groupMetaUpdatel   s    zIChatClient.groupMetaUpdatec                 C   s   dS )z
        Callback notifying this user that the given user has joined
        the given group.

        @type group: L{IGroup}
        @type user: L{IUser}

        @rtype: L{twisted.internet.defer.Deferred}
        Nr   )r   r   r   r   r   
userJoinedw   s    zIChatClient.userJoinedNc                 C   s   dS )a  
        Callback notifying this user that the given user has left the
        given group for the given reason.

        @type group: L{IGroup}
        @type user: L{IUser}
        @type reason: C{unicode}

        @rtype: L{twisted.internet.defer.Deferred}
        Nr   )r   r   r   r   r   r   userLeft   s    zIChatClient.userLeft)N)
r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   Q   s   r   c                   @   s`   e Zd ZdZedZedZedZedZedZ	dd Z
d	d
 Zdd Zdd Zdd ZdS )IUserz@Interface through which clients interact with IChatService.
    z_A reference to the Realm to which this user belongs.  Set if and only if the user is logged in.z`A reference to the mind which logged in to this user.  Set if and only if the user is logged in.z#A short string, unique among users.zRA POSIX timestamp indicating the time of the last message received from this user.zBA POSIX timestamp indicating this user's most recent sign on time.c                 C   s   dS )zInvoked by the associated L{IChatService} when login occurs.

        @param realm: The L{IChatService} through which login is occurring.
        @param mind: The mind object used for cred login.
        Nr   )r   mindr   r   r   loggedIn   s    zIUser.loggedInc                 C   s   dS )zSend the given message to the given user or group.

        @type recipient: Either L{IUser} or L{IGroup}
        @type message: C{dict}
        Nr   )r   r   r   r   r   send   s    z
IUser.sendc                 C   s   dS )z|Attempt to join the given group.

        @type group: L{IGroup}
        @rtype: L{twisted.internet.defer.Deferred}
        Nr   r   r   r   r   join   s    z
IUser.joinc                 C   s   dS )zDiscontinue participation in the given group.

        @type group: L{IGroup}
        @rtype: L{twisted.internet.defer.Deferred}
        Nr   r$   r   r   r   leave   s    zIUser.leavec                   C   s   dS )zZ
        Return an iterator of all groups of which this user is a
        member.
        Nr   r   r   r   r   
itergroups   s    zIUser.itergroupsN)r	   r
   r   r   r   r   r!   r   ZlastMessageZsignOnr"   r#   r%   r&   r'   r   r   r   r   r       s   r    c                   @   sT   e Zd ZedZedZedZdd Zdd Zdd	 Z	d
d Z
dd Zdd ZdS )IChatServicez=A short string identifying this chat service (eg, a hostname)zxA boolean indicating whether L{getGroup} should implicitly create groups which are requested but which do not yet exist.zvA boolean indicating whether L{getUser} should implicitly create users which are requested but which do not yet exist.c                   C   s   dS )zReturn all groups available on this service.

        @rtype: C{twisted.internet.defer.Deferred}
        @return: A Deferred which fires with a list of C{IGroup} providers.
        Nr   r   r   r   r   r'      s    zIChatService.itergroupsc                 C   s   dS )a  Retrieve the group by the given name.

        @type name: C{str}

        @rtype: L{twisted.internet.defer.Deferred}
        @return: A Deferred which fires with the group with the given
        name if one exists (or if one is created due to the setting of
        L{IChatService.createGroupOnRequest}, or which fails with
        L{twisted.words.ewords.NoSuchGroup} if no such group exists.
        Nr   r   r   r   r   getGroup   s    zIChatService.getGroupc                 C   s   dS )a2  Create a new group with the given name.

        @type name: C{str}

        @rtype: L{twisted.internet.defer.Deferred}
        @return: A Deferred which fires with the created group, or
        with fails with L{twisted.words.ewords.DuplicateGroup} if a
        group by that name exists already.
        Nr   r)   r   r   r   createGroup   s    zIChatService.createGroupc                 C   s   dS )aE  Retrieve a group by name.

        Unlike C{getGroup}, this will never implicitly create a group.

        @type name: C{str}

        @rtype: L{twisted.internet.defer.Deferred}
        @return: A Deferred which fires with the group by the given
        name, or which fails with L{twisted.words.ewords.NoSuchGroup}.
        Nr   r)   r   r   r   lookupGroup   s    zIChatService.lookupGroupc                 C   s   dS )a  Retrieve the user by the given name.

        @type name: C{str}

        @rtype: L{twisted.internet.defer.Deferred}
        @return: A Deferred which fires with the user with the given
        name if one exists (or if one is created due to the setting of
        L{IChatService.createUserOnRequest}, or which fails with
        L{twisted.words.ewords.NoSuchUser} if no such user exists.
        Nr   r)   r   r   r   getUser   s    zIChatService.getUserc                 C   s   dS )a.  Create a new user with the given name.

        @type name: C{str}

        @rtype: L{twisted.internet.defer.Deferred}
        @return: A Deferred which fires with the created user, or
        with fails with L{twisted.words.ewords.DuplicateUser} if a
        user by that name exists already.
        Nr   r)   r   r   r   
createUser   s    zIChatService.createUserN)r	   r
   r   r   r   ZcreateGroupOnRequestZcreateUserOnRequestr'   r*   r+   r,   r-   r.   r   r   r   r   r(      s   r(   N)	Zzope.interfacer   r   r   r   r   r    r(   __all__r   r   r   r   <module>   s   8>.M   