<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
3
<eW                 @   sZ   d dl Z d dlZ d dlZd dlmZ d dlmZmZ ddlm	Z	 dgZ
G dd deZdS )    N)DBusGMainLoop)GLibGObject   )TunedAdminDBusExceptionDBusControllerc               @   s  e Zd ZdCddZdd Zdd Zdd	 Zd
d Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zd d! Zd"d# Zd$d% Zd&d' Zd(d) Zd*d+ Zd,d- Zd.d/ Zd0d1 Zd2d3 Zd4d5 Zd6d7 Zd8d9 Zd:d; Zd<d= Z d>d? Z!d@dA Z"dBS )Dr   Fc             C   sL   || _ || _|| _d | _d | _|| _d | _d | _d | _d| _	d| _
d | _d S )NTF)	_bus_name_interface_name_object_name_proxy
_interface_debug
_main_loop_action_on_exit_action_ret_exit
_exception)selfZbus_nameZinterface_nameZobject_namedebug r   %/usr/lib/python3.6/dbus_controller.py__init__   s    zDBusController.__init__c             C   sv   yP| j d krNtdd tj | _tj }|j| j| j	| _ tj
| j | jd| _W n  tjjk
rp   tdY nX d S )NT)Zset_as_default)Zdbus_interfacez>Cannot talk to TuneD daemon via DBus. Is TuneD daemon running?)r   r   r   ZMainLoopr   dbusZ	SystemBusZ
get_objectr   r
   Z	Interfacer	   r   
exceptionsDBusExceptionr   )r   Zbusr   r   r   _init_proxy   s    


zDBusController._init_proxyc             C   s   | j d k	rPy| j | j| j| _W n. tk
rN } z|| _d| _W Y d d }~X nX | jr~| jd k	rp| j| j| j	 | j
j  dS tjd dS )NTFr   )r   _action_args_action_kwargsZ_action_exit_coder   r   r   r   _on_exit_action_args_on_exit_action_kwargsr   quittimeZsleep)r   er   r   r   _idle$   s    



zDBusController._idlec             O   s   || _ || _|| _d S )N)r   r   r    )r   actionargskwargsr   r   r   set_on_exit_action7   s    z!DBusController.set_on_exit_actionc             O   s   || _ || _|| _d S )N)r   r   r   )r   r%   r&   r'   r   r   r   
set_action<   s    zDBusController.set_actionc             C   s2   d | _ tj| j | jj  | j d k	r,| j | jS )N)r   r   Zidle_addr$   r   runr   )r   r   r   r   r*   A   s    

zDBusController.runc             O   sp   | j   y| jj|}||ddiS  tjjk
rj } z(d}| jrR|dt| 7 }t|W Y d d }~X nX d S )Ntimeout(   z DBus call to TuneD daemon failedz (%s))	r   r   Zget_dbus_methodr   r   r   r   strr   )r   Zmethod_namer&   r'   methodZdbus_exceptionZerr_strr   r   r   _callJ   s    zDBusController._callc             C   s   | j   | jj|| d S )N)r   r   Zconnect_to_signal)r   signalcbr   r   r   set_signal_handlerV   s    z!DBusController.set_signal_handlerc             C   s
   | j dS )N
is_running)r/   )r   r   r   r   r3   Z   s    zDBusController.is_runningc             C   s
   | j dS )Nstart)r/   )r   r   r   r   r4   ]   s    zDBusController.startc             C   s
   | j dS )Nstop)r/   )r   r   r   r   r5   `   s    zDBusController.stopc             C   s
   | j dS )Nprofiles)r/   )r   r   r   r   r6   c   s    zDBusController.profilesc             C   s
   | j dS )N	profiles2)r/   )r   r   r   r   r7   f   s    zDBusController.profiles2c             C   s   | j d|S )Nprofile_info)r/   )r   Zprofile_namer   r   r   r8   i   s    zDBusController.profile_infoc             C   s   | j d||S )Nlog_capture_start)r/   )r   Z	log_levelr+   r   r   r   r9   l   s    z DBusController.log_capture_startc             C   s   | j d|S )Nlog_capture_finish)r/   )r   tokenr   r   r   r:   o   s    z!DBusController.log_capture_finishc             C   s
   | j dS )Nactive_profile)r/   )r   r   r   r   r<   r   s    zDBusController.active_profilec             C   s
   | j dS )Nprofile_mode)r/   )r   r   r   r   r=   u   s    zDBusController.profile_modec             C   s
   | j dS )Npost_loaded_profile)r/   )r   r   r   r   r>   x   s    z"DBusController.post_loaded_profilec             C   s   |dkrdS | j d|S )N FNo profile specifiedswitch_profile)Fr@   )r/   )r   Znew_profiler   r   r   rA   {   s    zDBusController.switch_profilec             C   s
   | j dS )Nauto_profile)r/   )r   r   r   r   rB      s    zDBusController.auto_profilec             C   s
   | j dS )Nrecommend_profile)r/   )r   r   r   r   rC      s    z DBusController.recommend_profilec             C   s
   | j dS )Nverify_profile)r/   )r   r   r   r   rD      s    zDBusController.verify_profilec             C   s
   | j dS )Nverify_profile_ignore_missing)r/   )r   r   r   r   rE      s    z,DBusController.verify_profile_ignore_missingc             C   s
   | j dS )Ndisable)r/   )r   r   r   r   off   s    zDBusController.offc             C   s
   | j dS )zzReturn dict with plugin names and their hints

		Return:
		dictionary -- {plugin_name: {parameter_name: default_value}}
		Zget_all_plugins)r/   )r   r   r   r   get_plugins   s    zDBusController.get_pluginsc             C   s   | j d|S )z"Return docstring of plugin's classget_plugin_documentation)r/   )r   plugin_namer   r   r   rI      s    z'DBusController.get_plugin_documentationc             C   s   | j d|S )zReturn dictionary with parameters of plugin and their hints

		Parameters:
		plugin_name -- name of plugin

		Return:
		dictionary -- {parameter_name: hint}
		get_plugin_hints)r/   )r   rJ   r   r   r   rK      s    	zDBusController.get_plugin_hintsc             C   s   | j d||S )Ninstance_acquire_devices)r/   )r   Zdevicesinstancer   r   r   rL      s    z'DBusController.instance_acquire_devicesc             C   s   | j d|S )Nget_instances)r/   )r   rJ   r   r   r   rN      s    zDBusController.get_instancesc             C   s   | j d|S )Ninstance_get_devices)r/   )r   rM   r   r   r   rO      s    z#DBusController.instance_get_devicesc             C   s   | j d  || _d| _|S )NT)r)   r   r   )r   retr   r   r   exit   s    
zDBusController.exitN)F)#__name__
__module____qualname__r   r   r$   r(   r)   r*   r/   r2   r3   r4   r5   r6   r7   r8   r9   r:   r<   r=   r>   rA   rB   rC   rD   rE   rG   rH   rI   rK   rL   rN   rO   rQ   r   r   r   r   r   
   s@   
	)r   Zdbus.exceptionsr"   Zdbus.mainloop.glibr   Zgi.repositoryr   r   r   r   __all__objectr   r   r   r   r   <module>   s   