o
    “¼é`  ã                   @   s:   d dl mZ ddlmZmZ ddlmZ G dd„ dƒZdS )é    )Úwarné   )ÚMessageTypeÚHeaderFields)ÚDBusErrorResponsec                   @   sL   e Zd ZdZddd„Zedd„ ƒZejdd„ ƒZdd	„ Zd
d„ Z	dd„ Z
dS )ÚRoutera[  Routing for messages coming back to a client application.
    
    :param handle_factory: Constructor for an object like asyncio.Future,
        with methods *set_result* and *set_exception*. Outgoing method call
        messages will get a handle associated with them.
    :param on_unhandled: Callback for messages not otherwise dispatched.
    Nc                 C   s"   || _ || _d| _i | _i | _d S )Nr   )Úhandle_factoryÚ_on_unhandledÚoutgoing_serialÚawaiting_replyÚsignal_callbacks)Úselfr   Úon_unhandled© r   ú1/usr/lib/python3/dist-packages/jeepney/routing.pyÚ__init__   s
   
zRouter.__init__c                 C   s   | j S ©N)r	   )r   r   r   r   r      s   zRouter.on_unhandledc                 C   s   t ddd� || _d S )NzeSetting on_unhandled is deprecated. Please use the filter() method or simple receive() calls instead.é   ©Ú
stacklevel)r   r	   )r   Úvaluer   r   r   r      s   ÿ
c                 C   sD   |  j d7  _ | j |j_|jjtju r |  ¡  | j|jj< }|S dS )zNSet the serial number in the message & make a handle if a method call
        r   N)r
   ÚheaderÚserialÚmessage_typer   Úmethod_callr   r   )r   ÚmsgÚhandler   r   r   Úoutgoing   s   
þzRouter.outgoingc                 C   s    t ddd� || j|||f< dS )z%Add a callback for a signal.
        zQThe subscribe_signal() method is deprecated. Please use the filter() API instead.r   r   N)r   r   )r   ÚcallbackÚpathÚ	interfaceÚmemberr   r   r   Úsubscribe_signal)   s   ÿzRouter.subscribe_signalc                 C   sÜ   |j }|jtju r2|j tjd¡|j tjd¡|j tj	d¡f}| j
 |d¡}|dur2||jƒ dS |j tjd¡}| j |d¡}|durb|jtju rS| |j¡ dS |jtju rb| t|ƒ¡ dS | jrl|  |¡ dS dS )z#Route an incoming message.
        Néÿÿÿÿ)r   r   r   ÚsignalÚfieldsÚgetr   r   r    r!   r   ÚbodyÚreply_serialr   ÚpopÚmethod_returnÚ
set_resultÚerrorÚset_exceptionr   r   )r   r   ÚhdrÚkeyÚcbr(   Úreply_handler   r   r   Úincoming0   s,   þ
ÿzRouter.incomingr   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr   Úsetterr   r"   r2   r   r   r   r   r      s    



r   N)Úwarningsr   Ú	low_levelr   r   Úwrappersr   r   r   r   r   r   Ú<module>   s    