3 ָVXv � @ sB d dl mZ ddlmZ G dd� dedd��ZG dd � d e�Zd S )� )�Gio� )�ExitableWithAliasesc @ s e Zd ZejZf Zdd� ZdS )�Subscriptionc s. � j |||||||��| j� �fdd�� d S )Nc s � j ��S )N)Zsignal_unsubscribe� )�con�idr �"/usr/lib/python3.6/subscription.py�<lambda> s z'Subscription.__init__.<locals>.<lambda>)Zsignal_subscribeZ_at_exit) �selfr �sender�iface�member�object�arg0�flags�callbackr )r r r �__init__ s zSubscription.__init__N)�__name__� __module__�__qualname__r ZDBusSignalFlags�Flags� __slots__r r r r r r s r ZunsubscribeZ disconnectc @ s e Zd Zf ZejZddd�ZdS )�SubscriptionMixinNr c s4 � dk r� fdd�ndd� }t | j|||||||�S )a Subscribes to matching signals. Subscribes to signals on connection and invokes signal_fired callback whenever the signal is received. To receive signal_fired callback, you need an event loop. https://github.com/LEW21/pydbus/blob/master/doc/tutorial.rst#setting-up-an-event-loop Parameters ---------- sender : string, optional Sender name to match on (unique or well-known name) or None to listen from all senders. iface : string, optional Interface name to match on or None to match on all interfaces. signal : string, optional Signal name to match on or None to match on all signals. object : string, optional Object path to match on or None to match on all object paths. arg0 : string, optional Contents of first string argument to match on or None to match on all kinds of arguments. flags : SubscriptionFlags, optional signal_fired : callable, optional Invoked when there is a signal matching the requested data. Parameters: sender, object, iface, signal, params Returns ------- Subscription An object you can use as a context manager to unsubscribe from the signal later. See Also -------- See https://developer.gnome.org/gio/2.44/GDBusConnection.html#g-dbus-connection-signal-subscribe for more information. Nc s � |||||j � �S )N)�unpack)r r r r �signalZparams)�signal_firedr r r 4 s z-SubscriptionMixin.subscribe.<locals>.<lambda>c W s d S )Nr )�argsr r r r 4 s )r r ) r r r r r r r r r r )r r � subscribe s $zSubscriptionMixin.subscribe)NNNNNr N)r r r r r r ZSubscriptionFlagsr r r r r r s r N)Z gi.repositoryr Zexitabler r r r r r r r �<module> s