o
    `	                     @   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   ;/usr/lib/python3/dist-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   sD   | j | | j jr|   d S | j jr | jt| j j d S 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   outgoing	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	TypeErrorr3   )r   r1   r   r   r   send_and_get_reply5   s   zDBusProtocol.send_and_get_replyN)
__name__
__module____qualname__r   r    r%   r#   r"   r3   r8   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   msggenprotocol	__class__r   r   r   A   s   
zProxy.__init__c                 C   s   d | j| jS )NzProxy({}, {}))format_msggenr>   r   r   r   r   __repr__E   s   zProxy.__repr__c                    s    fdd}|S )Nc                     s4    | i |}|j jtju sJ j|I d H S r   )r4   r5   r   r6   r>   r8   )argskwargsr,   make_msgr   r   r   innerI   s   z!Proxy._method_call.<locals>.innerr   )r   rI   rJ   r   rH   r   _method_callH   s   zProxy._method_call)r9   r:   r;   __doc__r   rE   rK   __classcell__r   r   rA   r   r<   ;   s
    r<   SESSIONc                    sd   |d u 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
   Hellor   )buslooptphello_replyr   r   r   connect_and_authenticateQ   s   

rX   )rN   N)rL   r   warningsr   jeepneyr   r   jeepney.authr   r   r   r   jeepney.busr	   jeepney.bus_messagesr
   jeepney.routingr   jeepney.wrappersr   Protocolr   r<   rX   r   r   r   r   <module>   s    ,