o
    \c                     @   s   d dl 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 d dlmZ er8d dlmZ G d	d
 d
eZdS )    )gettext)TYPE_CHECKINGUnionOptionalAny)GLib)ServiceUUID)Device)Notification)AppletPlugin)BluemanAppletc                       s   e Zd ZdgZdZdZedZdddZde	d	d
iZ
d fddZdeddfddZdedededdfddZdefddZ  ZS )AutoConnectDBusServicezbluetooth-symboliccschrammzMTries to auto-connect to configurable services on start and every 60 seconds.zorg.blueman.plugins.autoconnectN)schemapathservicesz[])typedefaultparentr   c                    s   t  | td| j d S )Ni`  )super__init__r   timeout_add_run)selfr   	__class__ D/usr/lib/python3/dist-packages/blueman/plugins/applet/AutoConnect.pyr      s   zAutoConnect.__init__statereturnc                 C   s   |r|    d S d S Nr   )r   r   r   r   r   on_manager_state_changed"   s   z$AutoConnect.on_manager_state_changedr   keyvaluec                 C   s    |dkr|r|    d S d S d S )NPoweredr"   )r   r   r$   r%   r   r   r   on_adapter_property_changed&   s   z'AutoConnect.on_adapter_property_changedc                 C   s   |  dD ]B\}}| jj|}|d u s|drq|t|jfdtt dt	dd fdd}dt
tt	f dd fd	d
}| jjj| ||| qdS )Nr   	Connecteddevservice_namer    c                 S   s>   t | tsJ ttdtd|| d d | d d  d S )Nr(   z4Automatically connected to %(service)s on %(device)sAlias)servicedeviceIcon)	icon_name)
isinstancer	   r
   _show)r)   r*   r   r   r   reply0   s   
zAutoConnect._run.<locals>.reply_reasonc                 S   s   d S r!   r   )r4   r   r   r   err6   s   zAutoConnect._run.<locals>.errT)
get_optionr   Managerfind_devicegetr   namer   r	   strr   	ExceptionPluginsr   connect_serviceget_object_path)r   addressuuidr-   r3   r5   r   r   r   r   *   s   &zAutoConnect._run)r   r   )__name__
__module____qualname____depends____icon__
__author__r1   __description____gsettings__list__options__r   boolr#   r;   r   r'   r   __classcell__r   r   r   r   r      s    
r   N)r   r1   typingr   r   r   r   gi.repositoryr   blueman.Sdpr   blueman.bluez.Devicer	   blueman.gui.Notificationr
   blueman.plugins.AppletPluginr   blueman.main.Appletr   r   r   r   r   r   <module>   s    