3 ָVX� � @ sl d dl mZ ddlmZ d dlZG dd� ded��ZG dd � d ed ��ZG dd� de�ZG d d� de�Z dS )� )�Gio� )�ExitableWithAliasesNc @ s e Zd ZejZf Zdd� ZdS )� NameOwnerc s( t j|||||�� | j� fdd�� d S )Nc s t j� �S )N)r Zbus_unown_name� )�idr �/usr/lib/python3.6/bus_names.py�<lambda> s z$NameOwner.__init__.<locals>.<lambda>)r Zbus_own_name_on_connection�_at_exit)�self�con�name�flags�name_aquired_handler�name_lost_handlerr )r r �__init__ s zNameOwner.__init__N)�__name__� __module__�__qualname__r ZBusNameOwnerFlags�Flags� __slots__r r r r r r s r Zunownc @ s e Zd ZejZf Zdd� ZdS )�NameWatcherc s( t j|||||�� | j� fdd�� d S )Nc s t j� �S )N)r Zbus_unwatch_namer )r r r r s z&NameWatcher.__init__.<locals>.<lambda>)r Zbus_watch_name_on_connectionr )r r r r �name_appeared_handler�name_vanished_handlerr )r r r s zNameWatcher.__init__N)r r r r ZBusNameWatcherFlagsr r r r r r r r s r Zunwatchc @ s e Zd Zf ZejZddd�ZdS )�OwnMixinr Nc sN t jdt� � dk r � fdd�nd}�dk r8�fdd�nd}t| j||||�S )a7 [DEPRECATED] Asynchronously aquires a bus name. Starts acquiring name on the bus specified by bus_type and calls name_acquired and name_lost when the name is acquired respectively lost. To receive name_aquired and name_lost callbacks, you need an event loop. https://github.com/LEW21/pydbus/blob/master/doc/tutorial.rst#setting-up-an-event-loop Parameters ---------- name : string Bus name to aquire flags : NameOwnerFlags, optional name_aquired : callable, optional Invoked when name is acquired name_lost : callable, optional Invoked when name is lost Returns ------- NameOwner An object you can use as a context manager to unown the name later. See Also -------- See https://developer.gnome.org/gio/2.44/gio-Owning-Bus-Names.html#g-bus-own-name for more information. z5own_name() is deprecated, use request_name() instead.Nc s � � S )Nr )r r )�name_aquiredr r r 8 s z#OwnMixin.own_name.<locals>.<lambda>c s � � S )Nr )r r )� name_lostr r r 9 s )�warnings�warn�DeprecationWarningr r )r r r r r r r r )r r r �own_name s zOwnMixin.own_name)r NN)r r r r r r ZNameOwnerFlagsr r r r r r s r c @ s e Zd Zf ZejZddd�ZdS )� WatchMixinr Nc sB � dk r� fdd�nd}�dk r,�fdd�nd}t | j||||�S )a� Asynchronously watches a bus name. Starts watching name on the bus specified by bus_type and calls name_appeared and name_vanished when the name is known to have a owner respectively known to lose its owner. To receive name_appeared and name_vanished callbacks, you need an event loop. https://github.com/LEW21/pydbus/blob/master/doc/tutorial.rst#setting-up-an-event-loop Parameters ---------- name : string Bus name to watch flags : NameWatcherFlags, optional name_appeared : callable, optional Invoked when name is known to exist Called as name_appeared(name_owner). name_vanished : callable, optional Invoked when name is known to not exist Returns ------- NameWatcher An object you can use as a context manager to unwatch the name later. See Also -------- See https://developer.gnome.org/gio/2.44/gio-Watching-Bus-Names.html#g-bus-watch-name for more information. Nc s � |�S )Nr )r r Z name_owner)� name_appearedr r r _ s z'WatchMixin.watch_name.<locals>.<lambda>c s � � S )Nr )r r )� name_vanishedr r r ` s )r r )r r r r"