U
    [e	                     @   s   d Z ddlZddlmZ ddlmZmZ ddlmZm	Z	m
Z
mZ ddlmZ ddlmZ ddlmZ dd	lmZ ed
dd G dd dejZG dd deZdddZdS )z*Deprecated: use jeepney.io.asyncio instead    N)warn)ParserMessageType)AuthenticationErrorBEGINmake_auth_external
SASLParser)get_bus)message_bus)Router)	ProxyBasezOjeepney.integrate.asyncio is deprecated: please use jeepney.io.asyncio instead.   )
stacklevelc                   @   sD   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dS )DBusProtocolc                 C   s0   t  | _t | _ttj| _t | _d | _	d S N)
r   auth_parserr   parserr   asyncioFuturerouterauthenticationunique_nameself r   [/var/www/html/services/stratfitenv/lib/python3.8/site-packages/jeepney/integrate/asyncio.py__init__   s
    
zDBusProtocol.__init__c                 C   s   || _ | j dt   d S )N    )	transportwriter   )r   r   r   r   r   connection_made   s    zDBusProtocol.connection_madec                 C   s2   | j t | jd | j| _| | jj d S )NT)	r   r   r   r   
set_resultdata_received_post_authdata_receivedr   bufferr   r   r   r   _authenticated   s    zDBusProtocol._authenticatedc                 C   s>   | j | | j jr|   n| j jr:| jt| j j d S r   )r   feedauthenticatedr%   errorr   set_exceptionr   )r   datar   r   r   r#   !   s
    
zDBusProtocol.data_receivedc                 C   s"   | j |D ]}| j| qd S r   )r   r&   r   incoming)r   r*   msgr   r   r   r"   (   s    z$DBusProtocol.data_received_post_authc                 C   s6   | j  std| j|}| }| j| |S )Nz/Wait for authentication before sending messages)r   doneRuntimeErrorr   outgoingZ	serialiser   r   )r   messagefuturer*   r   r   r   send_message,   s    
zDBusProtocol.send_messagec                    s&   |j jtjkrtd| |I d H S )Nz&Only method call messages have replies)headermessage_typer   method_call	TypeErrorr2   )r   r0   r   r   r   send_and_get_reply5   s    zDBusProtocol.send_and_get_replyN)
__name__
__module____qualname__r   r    r%   r#   r"   r2   r7   r   r   r   r   r      s   	r   c                       s0   e Zd ZdZ fddZdd Zdd Z  ZS )ProxyzAn asyncio proxy for calling D-Bus methods

    :param msggen: A message generator object.
    :param DBusProtocol proto: Protocol object to send and receive messages.
    c                    s   t  | || _d S r   )superr   	_protocol)r   Zmsggenprotocol	__class__r   r   r   A   s    zProxy.__init__c                 C   s   d | j| jS )NzProxy({}, {}))formatZ_msggenr=   r   r   r   r   __repr__E   s    zProxy.__repr__c                    s    fdd}|S )Nc                     s.    | |}|j jtjkstj|I d H S r   )r3   r4   r   r5   AssertionErrorr=   r7   )argskwargsr,   make_msgr   r   r   innerI   s    
z!Proxy._method_call.<locals>.innerr   )r   rG   rH   r   rF   r   _method_callH   s    zProxy._method_call)r8   r9   r:   __doc__r   rB   rI   __classcell__r   r   r?   r   r;   ;   s   r;   SESSIONc                    sb   |d krt  }|jtt| dI d H \}}|jI d H  tt|} |  I d H }|d |_	||fS )N)pathr   )
r   get_event_loopcreate_unix_connectionr   r	   r   r;   r
   ZHellor   )buslooptpZhello_replyr   r   r   connect_and_authenticateQ   s    

rT   )rL   N)rJ   r   warningsr   Zjeepneyr   r   Zjeepney.authr   r   r   r   Zjeepney.busr	   Zjeepney.bus_messagesr
   Zjeepney.routingr   Zjeepney.wrappersr   Protocolr   r;   rT   r   r   r   r   <module>   s   ,