/home/lnzliplg/public_html/dbus.zip
PKJW�\Ww�}I-I-%__pycache__/decorators.cpython-36.pycnu�[���3

�f�Vg;�
@sddZd
ZdZddlZddlmZmZmZddlm	Z	ddl
mZdd	lm
Z
ddd�Zddd�ZdS)zService-side D-Bus decorators.�method�signalZrestructuredtext�N)�validate_interface_name�	Signature�validate_member_name)�
SignalMessage)�
DBusException)�is_py2Fc
s.t������������	�
�fdd�}|S)a�Factory for decorators used to mark methods of a `dbus.service.Object`
    to be exported on the D-Bus.

    The decorated method will be exported over D-Bus as the method of the
    same name on the given D-Bus interface.

    :Parameters:
        `dbus_interface` : str
            Name of a D-Bus interface
        `in_signature` : str or None
            If not None, the signature of the method parameters in the usual
            D-Bus notation
        `out_signature` : str or None
            If not None, the signature of the return value in the usual
            D-Bus notation
        `async_callbacks` : tuple containing (str,str), or None
            If None (default) the decorated method is expected to return
            values matching the `out_signature` as usual, or raise
            an exception on error. If not None, the following applies:

            `async_callbacks` contains the names of two keyword arguments to
            the decorated function, which will be used to provide a success
            callback and an error callback (in that order).

            When the decorated method is called via the D-Bus, its normal
            return value will be ignored; instead, a pair of callbacks are
            passed as keyword arguments, and the decorated method is
            expected to arrange for one of them to be called.

            On success the success callback must be called, passing the
            results of this method as positional parameters in the format
            given by the `out_signature`.

            On error the decorated method may either raise an exception
            before it returns, or arrange for the error callback to be
            called with an Exception instance as parameter.

        `sender_keyword` : str or None
            If not None, contains the name of a keyword argument to the
            decorated function, conventionally ``'sender'``. When the
            method is called, the sender's unique name will be passed as
            this keyword argument.

        `path_keyword` : str or None
            If not None (the default), the decorated method will receive
            the destination object path as a keyword argument with this
            name. Normally you already know the object path, but in the
            case of "fallback paths" you'll usually want to use the object
            path in the method's implementation.

            For fallback objects, `rel_path_keyword` (new in 0.82.2) is
            likely to be more useful.

            :Since: 0.80.0?

        `rel_path_keyword` : str or None
            If not None (the default), the decorated method will receive
            the destination object path, relative to the path at which the
            object was exported, as a keyword argument with this
            name. For non-fallback objects the relative path will always be
            '/'.

            :Since: 0.82.2

        `destination_keyword` : str or None
            If not None (the default), the decorated method will receive
            the destination bus name as a keyword argument with this name.
            Included for completeness - you shouldn't need this.

            :Since: 0.80.0?

        `message_keyword` : str or None
            If not None (the default), the decorated method will receive
            the `dbus.lowlevel.MethodCallMessage` as a keyword argument
            with this name.

            :Since: 0.80.0?

        `connection_keyword` : str or None
            If not None (the default), the decorated method will receive
            the `dbus.connection.Connection` as a keyword argument
            with this name. This is generally only useful for objects
            that are available on more than one connection.

            :Since: 0.82.0

        `utf8_strings` : bool
            If False (default), D-Bus strings are passed to the decorated
            method as objects of class dbus.String, a unicode subclass.

            If True, D-Bus strings are passed to the decorated method
            as objects of class dbus.UTF8String, a str subclass guaranteed
            to be encoded in UTF-8.

            This option does not affect object-paths and signatures, which
            are always 8-bit strings (str subclass) encoded in ASCII.

            :Since: 0.80.0

        `byte_arrays` : bool
            If False (default), a byte array will be passed to the decorated
            method as an `Array` (a list subclass) of `Byte` objects.

            If True, a byte array will be passed to the decorated method as
            a `ByteArray`, a str subclass. This is usually what you want,
            but is switched off by default to keep dbus-python's API
            consistent.

            :Since: 0.80.0
    cs�ttd�rLg}xJtj|�jj�D]&}|jtjjtjjfkr |j	|j
�q Wntj|�d}|jd��r�t
��tkr|td��t��dkr�td��|j�d�|j�d��r�|j���
r�|j�
��	r�|j�	��r�|j���r�|j����r|j����rJtt���}t|�t|�k�r0td��nt|�t|�k�rJtd��d|_�|_�|_�|_�|_�|_�	|_�
|_�|_�|_�|_||_t �d	�|_!t"�r��j#d
d�|j!d
<nd
�k�r�td��|S)
Nrrz\async_callbacks must be a tuple of (keyword for return callback, keyword for error callback)��z<input signature is longer than the number of arguments takenz=input signature is shorter than the number of arguments takenT)�byte_arraysZutf8_stringsFz*unexpected keyword argument 'utf8_strings')$�hasattr�inspect�	signatureZ
parameters�valuesZkindZ	ParameterZPOSITIONAL_ONLYZPOSITIONAL_OR_KEYWORD�append�name�
getargspec�pop�type�tuple�	TypeError�len�
ValueError�removerZ_dbus_is_methodZ_dbus_async_callbacks�_dbus_interfaceZ_dbus_in_signatureZ_dbus_out_signatureZ_dbus_sender_keywordZ_dbus_path_keywordZ_dbus_rel_path_keywordZ_dbus_destination_keywordZ_dbus_message_keywordZ_dbus_connection_keyword�
_dbus_args�dictZ_dbus_get_args_optionsr	�get)�func�args�argZin_sig)�async_callbacksr�connection_keyword�dbus_interface�destination_keyword�in_signature�kwargs�message_keyword�
out_signature�path_keyword�rel_path_keyword�sender_keyword��"/usr/lib64/python3.6/decorators.py�	decorator�sh










zmethod.<locals>.decorator)r)
r$r&r)r"r,r*r%r(r#rr+r'r/r-)r"rr#r$r%r&r'r(r)r*r+r,r.r'st">csTt���dk	r>ddlm}|td�tdd��dk	r>td������fdd	�}|S)
a	Factory for decorators used to mark methods of a `dbus.service.Object`
    to emit signals on the D-Bus.

    Whenever the decorated method is called in Python, after the method
    body is executed, a signal with the same name as the decorated method,
    with the given D-Bus interface, will be emitted from this object.

    :Parameters:
        `dbus_interface` : str
            The D-Bus interface whose signal is emitted
        `signature` : str
            The signature of the signal in the usual D-Bus notation

        `path_keyword` : str or None
            A keyword argument to the decorated method. If not None,
            that argument will not be emitted as an argument of
            the signal, and when the signal is emitted, it will appear
            to come from the object path given by the keyword argument.

            Note that when calling the decorated method, you must always
            pass in the object path as a keyword argument, not as a
            positional argument.

            This keyword argument cannot be used on objects where
            the class attribute ``SUPPORTS_MULTIPLE_OBJECT_PATHS`` is true.

            :Deprecated: since 0.82.0. Use `rel_path_keyword` instead.

        `rel_path_keyword` : str or None
            A keyword argument to the decorated method. If not None,
            that argument will not be emitted as an argument of
            the signal.

            When the signal is emitted, if the named keyword argument is given,
            the signal will appear to come from the object path obtained by
            appending the keyword argument to the object's object path.
            This is useful to implement "fallback objects" (objects which
            own an entire subtree of the object-path tree).

            If the object is available at more than one object-path on the
            same or different connections, the signal will be emitted at
            an appropriate object-path on each connection - for instance,
            if the object is exported at /abc on connection 1 and at
            /def and /x/y/z on connection 2, and the keyword argument is
            /foo, then signals will be emitted from /abc/foo and /def/foo
            on connection 1, and /x/y/z/foo on connection 2.

            :Since: 0.82.0
    Nr)�warnz�dbus.service.signal::path_keyword has been deprecated since dbus-python 0.82.0, and will not work on objects that support multiple object pathsr
)�
stacklevelzJdbus.service.signal::path_keyword and rel_path_keyword cannot both be usedcs��j�t��������fdd�}tj��d}|jd�xH��fD]<}|dk	rFy|j|�WqFtk
r�td|��YqFXqFW�r�tt���}t	|�t	|�kr�td��nt	|�t	|�kr�td���j|_�j
|_
d|_�|_�|_
||_|S)Ncs�d}�dk	rP|jrtd��|j�d�}||jkrP|jj|d�rPtd||j��d}�dk	rh|j�d�}�|f|�|�xl|jD]b}|dkr�|dks�|dkr�|d}q�|d|}n|}t|���}|j|d�i�|dj	|�q�WdS)	Nz[path_keyword cannot be used on the signals of an object that supports multiple object paths�/zPath %r is not below %r�rrr)r2r3)
ZSUPPORTS_MULTIPLE_OBJECT_PATHSrrZ__dbus_object_path__�
startswithrZ	locationsrrZsend_message)�selfr �keywordsZabs_pathZrel_path�locationZobject_path�message)r$r�member_namer*r+rr-r.�emit_signal"s0

z.signal.<locals>.decorator.<locals>.emit_signalrzfunction has no argument "%s"z@signal signature is longer than the number of arguments providedzAsignal signature is shorter than the number of arguments providedT)�__name__rrrrrrrrr�__doc__Z_dbus_is_signalrZ_dbus_signaturer)rr:r �keywordZsig)r$r*r+r)rr9r.r/s0&

zsignal.<locals>.decorator)r�warningsr0�DeprecationWarningr)r$rr*r+r0r/r-)r$r*r+rr.r�s3
D)rr)
NNNNNNNNFN)NNN)r<�__all__Z
__docformat__rZdbusrrrZ
dbus.lowlevelrZdbus.exceptionsrZdbus._compatr	rrr-r-r-r.�<module>s 
3PKKW�\$R�a
a
!__pycache__/server.cpython-36.pycnu�[���3

iR�V�@s4dZdZddlmZddlmZGdd�de�ZdS)�ServerZreStructuredText�)�_Server)�
ConnectioncsfeZdZdZeddf�fdd�	Zdd�Zdd�Zd	d
�Zdd�Z	e
ej�Z
e
ej�Ze
ej�Z�ZS)
ra%An opaque object representing a server that listens for connections from
    other applications.

    This class is not useful to instantiate directly: you must subclass it and
    either extend the method connection_added, or append to the
    list on_connection_added.

    :Since: 0.83
    Ncstt|�j|||||�S)a�Construct a new Server.

        :Parameters:
            `address` : str
                Listen on this address.
            `connection_class` : type
                When new connections come in, instantiate this subclass
                of dbus.connection.Connection to represent them.
                The default is Connection.
            `mainloop` : dbus.mainloop.NativeMainLoop or None
                The main loop with which to associate the new connections.
            `auth_mechanisms` : sequence of str
                Authentication mechanisms to allow. The default is to allow
                any authentication mechanism supported by ``libdbus``.
        )�superr�__new__)�cls�addressZconnection_classZmainloopZauth_mechanisms)�	__class__��/usr/lib64/python3.6/server.pyr)szServer.__new__cOsi|_g|_g|_dS)N)Z_Server__connections�on_connection_added�on_connection_removed)�self�args�kwargsr
r
r�__init__=szServer.__init__cCs|j|j�|j|�dS)N)Zcall_on_disconnection�connection_removed�connection_added)r�connr
r
r�_on_new_connectionLszServer._on_new_connectioncCs"|jrx|jD]}||�qWdS)a�Respond to the creation of a new Connection.

        This base-class implementation just invokes the callbacks in
        the on_connection_added attribute.

        :Parameters:
            `conn` : dbus.connection.Connection
                A D-Bus connection which has just been added.

                The type of this parameter is whatever was passed
                to the Server constructor as the ``connection_class``.
        N)r)rr�cbr
r
rrPs
zServer.connection_addedcCs"|jrx|jD]}||�qWdS)a�Respond to the disconnection of a Connection.

        This base-class implementation just invokes the callbacks in
        the on_connection_removed attribute.

        :Parameters:
            `conn` : dbus.connection.Connection
                A D-Bus connection which has just become disconnected.

                The type of this parameter is whatever was passed
                to the Server constructor as the ``connection_class``.
        N)r
)rrrr
r
rras
zServer.connection_removed)�__name__�
__module__�__qualname__�__doc__rrrrrr�propertyrZget_addressrZget_id�idZget_is_connectedZis_connected�
__classcell__r
r
)r	rrs	

N)r)�__all__Z
__docformat__Z_dbus_bindingsrZdbus.connectionrrr
r
r
r�<module>sPKLW�\���ĭ� __pycache__/types.cpython-36.pycnu�[���3

iR�V�@s�dddddddddd	d
ddd
dddgZddlmZmZmZmZmZmZmZm	Z	m
Z
mZmZm
Z
mZmZmZmZmZddlmZer�ddlmZejd�dS)�
ObjectPath�	ByteArray�	Signature�Byte�Boolean�Int16�UInt16�Int32�UInt32�Int64�UInt64�Double�String�Array�Struct�
Dictionary�UnixFd�)rrrrrrrrr
rrr
rrr	rr)�is_py2)�
UTF8StringrN)�__all__Z_dbus_bindingsrrrrrrrrr
rrr
rrr	rrZdbus._compatrr�append�rr�/usr/lib64/python3.6/types.py�<module>s

LPKLW�\��w��F�F%__pycache__/connection.cpython-36.pycnu�[���3

iR�V}l�@s�dZdZddlZddlZddlZddlmZmZm	Z	m
Z
mZmZm
Z
ddlmZddlmZmZmZmZmZddlmZdd	lmZmZer�dd
lmZnddlmZejd�Zd
d�ZGdd�de �Z!Gdd�de�ZdS)�
Connection�SignalMatchZreStructuredText�N)r�LOCAL_IFACE�
LOCAL_PATH�validate_bus_name�validate_interface_name�validate_member_name�validate_object_path)�
DBusException)�ErrorMessage�HANDLER_RESULT_NOT_YET_HANDLED�MethodCallMessage�MethodReturnMessage�
SignalMessage)�ProxyObject)�is_py2�is_py3)�String)�
UTF8Stringzdbus.connectioncOsdS)N�)�args�kwargsrr�"/usr/lib64/python3.6/connection.py�_noop1src@s�eZdZddddddddd	d
ddd
ddddgZer<ejd�ee�Zd+dd�Zdd�Z	dd�Z
dd�Zedd��Z
dd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�ZdS),r�_sender_name_owner�_member�
_interface�_sender�_path�_handler�_args_match�_rule�_byte_arrays�
_conn_weakref�_destination_keyword�_interface_keyword�_message_keyword�_member_keyword�_sender_keyword�
_path_keyword�_int_args_match�
_utf8_stringsFNcKsl|dk	rt|�|dk	r t|�|dk	r0t|�|dk	r@t|�d|_tj|�|_||_||_	||_
||_||_||_
tr�|jdd�|_nd|kr�td��||_||_|	|_||_|
|_||_|
|_||_|s�d|_n�i|_x�|D]�}|jd��s�td|��yt|dd��}Wn"tk
�r4td|��YnX|dk�sJ|dk�rVtd	|��|||j|<q�WdS)
N�utf8_stringsFz*unexpected keyword argument 'utf8_strings'�argz(SignalMatch: unknown keyword argument %s�r�?z9SignalMatch: arg match index must be in range(64), not %d)rrrr	r!�weakref�refr#rrrrrrr�popr+�	TypeErrorr"r(r)r'r%r&r$r r*�
startswith�int�
ValueError)�self�conn�sender�object_path�dbus_interface�member�handler�byte_arraysZsender_keywordZpath_keywordZinterface_keywordZmember_keywordZmessage_keywordZdestination_keywordrZkwarg�indexrrr�__init__AsX
zSignalMatch.__init__cCstt|��S)z-SignalMatch objects are compared by identity.)�hash�id)r7rrr�__hash__|szSignalMatch.__hash__cCs||kS)z-SignalMatch objects are compared by identity.r)r7�otherrrr�__eq__�szSignalMatch.__eq__cCs||k	S)z-SignalMatch objects are compared by identity.r)r7rDrrr�__ne__�szSignalMatch.__ne__cCs|jS)N)r)r7rrr�<lambda>�szSignalMatch.<lambda>cCs�|jdkr�dg}|jdk	r*|jd|j�|jdk	rD|jd|j�|jdk	r^|jd|j�|jdk	rx|jd|j�|jdk	r�x(|jj�D]\}}|jd||f�q�Wdj|�|_|jS)Nz
type='signal'zsender='%s'z	path='%s'zinterface='%s'zmember='%s'z
arg%d='%s'�,)	r!r�appendrrrr*�items�join)r7Zruler?�valuerrr�__str__�s





zSignalMatch.__str__cCsd|jt|�|j|j�fS)Nz<%s at %x "%s" on conn %r>)�	__class__rBr!r#)r7rrr�__repr__�szSignalMatch.__repr__cCs
||_dS)N)r)r7�new_namerrr�set_sender_name_owner�sz!SignalMatch.set_sender_name_ownercKs\|d|jfkrdS||jkr dS||jkr.dS||jkr<dS||jkrJdS||jkrXdSdS)NFT)rrrrrr )r7r9r:r;r<r=rrrr�matches_removal_spec�s




z SignalMatch.matches_removal_specc
Cs�d}|jd|j�fkrdS|jdk	r�tdd�}tr6tnt}trFd|d<|jf|�}xB|jj	�D]4\}}|t
|�ks�t|||�s�|||kr^dSq^W|jd|j
�fkr�dS|jd|j�fkr�dS|jd|j�fkr�dSy�to�|j}|dks�|s�|j�r$t|jd�}t�r|j|d<|jf|�}i}|jdk	�rB|j�||j<|jdk	�r\|j�||j<|jdk	�rv|j�||j<|jdk	�r�|j
�||j<|jdk	�r�|j�||j<|jdk	�r�|||j<|j||�Wn"tj�tjddd�YnXdS)NFT)r>r,z&Exception in handler for D-Bus signal:�)�exc_info) rZ
get_senderr*�dictrrrr�
get_args_listrJ�len�
isinstancer�
get_memberr�
get_interfacer�get_pathr+r"r(r$Zget_destinationr)r'r%r&r�logging�basicConfig�_logger�error)r7�messagerrZarg_typer?rLr,rrr�maybe_handle_message�sZ




z SignalMatch.maybe_handle_messagecCs4|j�}|dk	r0|j||j|j|j|jf|j�dS)N)r#�remove_signal_receiverrrrrr )r7r8rrr�remove�s
zSignalMatch.remove)FNNNNNN)�__name__�
__module__�__qualname__Z_slotsrrI�tuple�	__slots__r@rCrErF�propertyr9rMrOrQrRrarcrrrrr5s.


7:cs~eZdZdZeZ�fdd�Zdd�Zddd	�Zdd
d�Z	dd
�Z
ddd�Zdd�Zdd�Z
d dd�Zd"dd�Zdd�Z�ZS)#rzzA connection to another application. In this base class there is
    assumed to be no bus daemon.

    :Since: 0.81.0
    csJtt|�j||�t|d�sFd|_g|_i|_tj�|_	|j
|jj�dS)N�_dbus_Connection_initializedrS)
�superrr@�hasattrrj�"_Connection__call_on_disconnection�!_signal_recipients_by_object_path�	threadingZLock�
_signals_lockZadd_message_filterrN�_signal_func)r7rr)rNrrr@s

zConnection.__init__cCs|S)aReturn the unique name for the given bus name, activating it
        if necessary and possible.

        If the name is already unique or this connection is not to a
        bus daemon, just return it.

        :Returns: a bus name. If the given `bus_name` exists, the returned
            name identifies its current owner; otherwise the returned name
            does not exist.
        :Raises DBusException: if the implementation has failed
            to activate the given bus name.
        :Since: 0.81.0
        r)r7�bus_namerrr�activate_name_ownerszConnection.activate_name_ownerNTcKsn|jdd�}|dk	rB|dk	r$td��ddlm}|dtdd�|}|r\td	d
j|j����|j||||d�S)a�Return a local proxy for the given remote object.

        Method calls on the proxy are translated into method calls on the
        remote object.

        :Parameters:
            `bus_name` : str
                A bus name (either the unique name or a well-known name)
                of the application owning the object. The keyword argument
                named_service is a deprecated alias for this.
            `object_path` : str
                The object path of the desired object
            `introspect` : bool
                If true (default), attempt to introspect the remote
                object to find out supported methods and their signatures

        :Returns: a `dbus.proxies.ProxyObject`
        �
named_serviceNz3bus_name and named_service cannot both be specifiedr)�warnziPassing the named_service parameter to get_object by name is deprecated: please use positional parameters�)�
stacklevelz4get_object does not take these keyword arguments: %sz, )�
introspect)r2r3�warningsru�DeprecationWarningrK�keys�ProxyObjectClass)r7rrr:rxrrtrurrr�
get_object$s

zConnection.get_objectc

Ks�|j�|jdd�}|dk	rJ|dk	r,td��|}ddlm}|dtdd�t||||||f|�}	|jj�z4|j	j
|i�}
|
j
|i�}|j
|g�}|j|	�Wd|jj�X|	S)	aArrange for the given function to be called when a signal matching
        the parameters is received.

        :Parameters:
            `handler_function` : callable
                The function to be called. Its positional arguments will
                be the arguments of the signal. By default it will receive
                no keyword arguments, but see the description of
                the optional keyword arguments below.
            `signal_name` : str
                The signal name; None (the default) matches all names
            `dbus_interface` : str
                The D-Bus interface name with which to qualify the signal;
                None (the default) matches all interface names
            `bus_name` : str
                A bus name for the sender, which will be resolved to a
                unique name if it is not already; None (the default) matches
                any sender.
            `path` : str
                The object path of the object which must have emitted the
                signal; None (the default) matches any object path
        :Keywords:
            `utf8_strings` : bool
                If True, the handler function will receive any string
                arguments as dbus.UTF8String objects (a subclass of str
                guaranteed to be UTF-8). If False (default) it will receive
                any string arguments as dbus.String objects (a subclass of
                unicode).
            `byte_arrays` : bool
                If True, the handler function will receive any byte-array
                arguments as dbus.ByteArray objects (a subclass of str).
                If False (default) it will receive any byte-array
                arguments as a dbus.Array of dbus.Byte (subclasses of:
                a list of ints).
            `sender_keyword` : str
                If not None (the default), the handler function will receive
                the unique name of the sending endpoint as a keyword
                argument with this name.
            `destination_keyword` : str
                If not None (the default), the handler function will receive
                the bus name of the destination (or None if the signal is a
                broadcast, as is usual) as a keyword argument with this name.
            `interface_keyword` : str
                If not None (the default), the handler function will receive
                the signal interface as a keyword argument with this name.
            `member_keyword` : str
                If not None (the default), the handler function will receive
                the signal name as a keyword argument with this name.
            `path_keyword` : str
                If not None (the default), the handler function will receive
                the object-path of the sending object as a keyword argument
                with this name.
            `message_keyword` : str
                If not None (the default), the handler function will receive
                the `dbus.lowlevel.SignalMessage` as a keyword argument with
                this name.
            `arg...` : unicode or UTF-8 str
                If there are additional keyword parameters of the form
                ``arg``\ *n*, match only signals where the *n*\ th argument
                is the value given for that keyword parameter. As of this
                time only string arguments can be matched (in particular,
                object paths and signatures can't).
            `named_service` : str
                A deprecated alias for `bus_name`.
        rtNz3bus_name and named_service cannot both be specifiedr)ruzrPassing the named_service parameter to add_signal_receiver by name is deprecated: please use positional parametersrv)rw)
Z_require_main_loopr2r3ryrurzrrp�acquirern�
setdefaultrI�release)
r7Zhandler_function�signal_namer;rr�path�keywordsrtru�match�by_interface�	by_member�matchesrrr�add_signal_receiverIs(G


zConnection.add_signal_receiverccs�|dk	rd|f}nd}|dk	r(d|f}nd}|dk	r>d|f}nd}x~|D]v}|jj|�}|dkrbqHxZ|D]R}|j|d�}|dkr�qhx6|D].}|j|d�}	|	dkr�q�x|	D]
}
|
Vq�Wq�WqhWqHWdS)N)N)N)N)rn�get)r7r�r;r<Z	path_keysZinterface_keysZmember_keysr�r�r��mrrr�_iter_easy_matches�s.






zConnection._iter_easy_matchesc
Ks>|jdd�}|dk	rB|dk	r$td��|}ddlm}|dtdd�g}	g}
|jj�z�|jj|d�}|dkrpdS|j|d�}|dkr�dS|j|d�}
|
dkr�dSx@|
D]8}||ks�|j	|||||f|�r�|
j
|�q�|	j
|�q�W|	r�|	||<n ||=|�s||=|�s|j|=Wd|jj�Xx|
D]}|j|��q&WdS)Nrtz3bus_name and named_service cannot both be specifiedr)ruzuPassing the named_service parameter to remove_signal_receiver by name is deprecated: please use positional parametersrv)rw)
r2r3ryrurzrpr~rnr�rRrIr��_clean_up_signal_match)r7Zhandler_or_matchr�r;rrr�r�rtru�newZ	deletionsr�r�r�r�rrrrb�sT




z!Connection.remove_signal_receivercCsdS)Nr)r7r�rrrr�sz!Connection._clean_up_signal_matchcCs�t|t�stS|j�}|j�}|j�}x |j|||�D]}|j|�q6W|tkr�|t	kr�|dkr�xF|j
D]<}y||�Wqhtk
r�tj
�tjddd�YqhXqhWtS)zvD-Bus filter function. Handle signals by dispatching to Python
        callbacks kept in the match-rule tree.
        ZDisconnectedz-Exception in handler for Disconnected signal:rS)rT)rXrrrZr[rYr�rarrrm�	Exceptionr\r]r^r_)r7r`r;r�r�r��cbrrrrq	s&


zConnection._signal_funcg�?Fcs|tkrtdt��|tkr(tdt��t|
d��trH|jdd��d<nd|krXtd��t||||d�}
y|
j|d|i�Wn@t	k
r�}z$t
j�tj
d	|||j|��WYd
d
}~XnX�d
kr܈d
kr�|j|
�d
S�d
kr�t��d
kr�t����fdd�}|j|
||	|d
�S)aSCall the given method, asynchronously.

        If the reply_handler is None, successful replies will be ignored.
        If the error_handler is None, failures will be ignored. If both
        are None, the implementation may request that no reply is sent.

        :Returns: The dbus.lowlevel.PendingCall.
        :Since: 0.81.0
        z1Methods may not be called on the reserved path %sz6Methods may not be called on the reserved interface %s)r>r,Fz*unexpected keyword argument 'utf8_strings')�destinationr��	interface�method�	signaturez<Unable to set arguments %r according to signature %r: %s: %sNcsVt|t�r�|jf���n6t|t�rB�t|j�d|j�i��n�td|��dS)N�namez%Unexpected type for reply message: %r)rXrrVrr
Zget_error_namer3)r`)�
error_handler�
get_args_opts�
reply_handlerrr�msg_reply_handlerZs

z0Connection.call_async.<locals>.msg_reply_handler)�require_main_loop)rr
rrUrr�r3r
rIr�r\r]r^r_rNZsend_messagerZsend_message_with_reply)r7rrr:r;r�r�rr�r��timeoutr>r�rr`�er�r)r�r�r�r�
call_async'sB


	zConnection.call_asyncc	Ks|tkrtdt��|tkr(tdt��t|d�}
trH|	jdd�|
d<nd|	krXtd��t||||d�}y|j|d|i�Wn@t	k
r�}z$t
j�tj
d	|||j|��WYd
d
}~XnX|j||�}
|
jf|
�}t|�dkr�d
St|�dkr�|dSt|�Sd
S)
zECall the given method, synchronously.
        :Since: 0.81.0
        z1Methods may not be called on the reserved path %sz6Methods may not be called on the reserved interface %s)r>r,Fz*unexpected keyword argument 'utf8_strings')r�r�r�r�r�z<Unable to set arguments %r according to signature %r: %s: %sNrrS)rr
rrUrr�r3r
rIr�r\r]r^r_rNZ!send_message_with_reply_and_blockrVrWrg)r7rrr:r;r�r�rr�r>rr�r`r�Z
reply_messageZ	args_listrrr�
call_blockinggs<
zConnection.call_blockingcCs|jj|�dS)z�Arrange for `callable` to be called with one argument (this
        Connection object) when the Connection becomes
        disconnected.

        :Since: 0.83.0
        N)rmrI)r7�callablerrr�call_on_disconnection�sz Connection.call_on_disconnection)NNT)NNNN)NNNN��)r�FT��)r�F)rdrerf�__doc__rr|r@rsr}r�r�rbr�rqr�r�r��
__classcell__rr)rNrr�s*
&
`
7 
>
+)rr)"�__all__Z
__docformat__r\ror0Z_dbus_bindingsrZ_Connectionrrrrrr	Zdbus.exceptionsr
Z
dbus.lowlevelrrr
rrZdbus.proxiesrZdbus._compatrrrrZ	getLoggerr^r�objectrrrrr�<module>s"$
DPKLW�\ܟ �yy%__pycache__/gi_service.cpython-36.pycnu�[���3

iR�V�
�@sfdZdgZddlmZddlZGdd�dejjejj�Z	ddd�Z
d	Ze	dejejjfe
ed
��Z
dS)z6Support code for implementing D-Bus services via PyGI.�ExportedGObject�)�GObjectNc@seZdZdZdd�ZdS)�ExportedGObjectTypez�A metaclass which inherits from both GObjectMeta and
    `dbus.service.InterfaceType`. Used as the metaclass for `ExportedGObject`.
    cCs,tjjj||||�tjjj||||�dS)N)r�	__class__�__init__�dbus�service�
InterfaceType)�cls�name�basesZdct�r
�"/usr/lib64/python3.6/gi_service.pyr,szExportedGObjectType.__init__N)�__name__�
__module__�__qualname__�__doc__rr
r
r
rr(srcKsT|jdd�}|jdd�}|dk	r*|j|�tjj|f|�tjjj||||d�dS)a:Initialize an exported GObject.

    :Parameters:
        `conn` : dbus.connection.Connection
            The D-Bus connection or bus
        `object_path` : str
            The object path at which to register this object.
    :Keywords:
        `bus_name` : dbus.service.BusName
            A bus name to be held on behalf of this object, or None.
        `gobject_properties` : dict
            GObject properties to be set on the constructed object.

            Any unrecognised keyword arguments will also be interpreted
            as GObject properties.
        �bus_nameN�gobject_properties)�conn�object_pathr)�pop�updaterrrr�Object)�selfrr�kwargsrrr
r
r�ExportedGObject__init__1s
rz)A GObject which is exported on the D-Bus.)rr)NN)r�__all__Z
gi.repositoryrZdbus.servicerrrr	rrZExportedGObject__doc__rrr
r
r
r�<module>s	
PKLW�\͑���(__pycache__/_compat.cpython-36.opt-1.pycnu�[���3

iR�V��@s ddlZejddkZeZdS)�N�)�sys�version_infoZis_py3Zis_py2�rr�/usr/lib64/python3.6/_compat.py�<module>sPKLW�\$R�a
a
'__pycache__/server.cpython-36.opt-1.pycnu�[���3

iR�V�@s4dZdZddlmZddlmZGdd�de�ZdS)�ServerZreStructuredText�)�_Server)�
ConnectioncsfeZdZdZeddf�fdd�	Zdd�Zdd�Zd	d
�Zdd�Z	e
ej�Z
e
ej�Ze
ej�Z�ZS)
ra%An opaque object representing a server that listens for connections from
    other applications.

    This class is not useful to instantiate directly: you must subclass it and
    either extend the method connection_added, or append to the
    list on_connection_added.

    :Since: 0.83
    Ncstt|�j|||||�S)a�Construct a new Server.

        :Parameters:
            `address` : str
                Listen on this address.
            `connection_class` : type
                When new connections come in, instantiate this subclass
                of dbus.connection.Connection to represent them.
                The default is Connection.
            `mainloop` : dbus.mainloop.NativeMainLoop or None
                The main loop with which to associate the new connections.
            `auth_mechanisms` : sequence of str
                Authentication mechanisms to allow. The default is to allow
                any authentication mechanism supported by ``libdbus``.
        )�superr�__new__)�cls�addressZconnection_classZmainloopZauth_mechanisms)�	__class__��/usr/lib64/python3.6/server.pyr)szServer.__new__cOsi|_g|_g|_dS)N)Z_Server__connections�on_connection_added�on_connection_removed)�self�args�kwargsr
r
r�__init__=szServer.__init__cCs|j|j�|j|�dS)N)Zcall_on_disconnection�connection_removed�connection_added)r�connr
r
r�_on_new_connectionLszServer._on_new_connectioncCs"|jrx|jD]}||�qWdS)a�Respond to the creation of a new Connection.

        This base-class implementation just invokes the callbacks in
        the on_connection_added attribute.

        :Parameters:
            `conn` : dbus.connection.Connection
                A D-Bus connection which has just been added.

                The type of this parameter is whatever was passed
                to the Server constructor as the ``connection_class``.
        N)r)rr�cbr
r
rrPs
zServer.connection_addedcCs"|jrx|jD]}||�qWdS)a�Respond to the disconnection of a Connection.

        This base-class implementation just invokes the callbacks in
        the on_connection_removed attribute.

        :Parameters:
            `conn` : dbus.connection.Connection
                A D-Bus connection which has just become disconnected.

                The type of this parameter is whatever was passed
                to the Server constructor as the ``connection_class``.
        N)r
)rrrr
r
rras
zServer.connection_removed)�__name__�
__module__�__qualname__�__doc__rrrrrr�propertyrZget_addressrZget_id�idZget_is_connectedZis_connected�
__classcell__r
r
)r	rrs	

N)r)�__all__Z
__docformat__Z_dbus_bindingsrZdbus.connectionrrr
r
r
r�<module>sPKMW�\��h�� __pycache__/_dbus.cpython-36.pycnu�[���3

iR�Vd"�@s�dZddlmZdZdZddlmZdd	lmZm	Z	m
Z
mZmZm
Z
mZmZmZmZmZmZdd
lmZddlmZddlmZer�dd
lmZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)z9Implementation for dbus.Bus. Not to be imported directly.�)�
generators�Bus�	SystemBus�
SessionBus�
StarterBusZreStructuredText)�
DBusException)�BUS_DAEMON_IFACE�BUS_DAEMON_NAME�BUS_DAEMON_PATH�BUS_SESSION�BUS_STARTER�
BUS_SYSTEM� DBUS_START_REPLY_ALREADY_RUNNING�DBUS_START_REPLY_SUCCESS�validate_bus_name�validate_interface_name�validate_member_name�validate_object_path)�
BusConnection)�
SignalMessage)�is_py2)�
UTF8Stringcs�eZdZdZiZejddfdd�Z�fdd�Zdd	�Z	e
e	ddd
�Zddd�Ze
e�Zdd
d�Ze
e�Zddd�Ze
e�Zdd�ZeZ�ZS)ra A connection to one of three possible standard buses, the SESSION,
    SYSTEM, or STARTER bus. This class manages shared connections to those
    buses.

    If you're trying to subclass `Bus`, you may be better off subclassing
    `BusConnection`, which doesn't have all this magic.
    FNcCsx|r||jkr|j|S|tkr(t}n(|tkr6t}n|tkrDt}ntd|��tj	|||d�}||_
|st||j|<|S)a�Constructor, returning an existing instance where appropriate.

        The returned instance is actually always an instance of `SessionBus`,
        `SystemBus` or `StarterBus`.

        :Parameters:
            `bus_type` : cls.TYPE_SESSION, cls.TYPE_SYSTEM or cls.TYPE_STARTER
                Connect to the appropriate bus
            `private` : bool
                If true, never return an existing shared instance, but instead
                return a private connection.

                :Deprecated: since 0.82.3. Use dbus.bus.BusConnection for
                    private connections.

            `mainloop` : dbus.mainloop.NativeMainLoop
                The main loop to use. The default is to use the default
                main loop if one has been set up, or raise an exception
                if none has been.
        :Changed: in dbus-python 0.80:
            converted from a wrapper around a Connection to a Connection
            subclass.
        zinvalid bus_type %s)�mainloop)�_shared_instancesrrr
rrr�
ValueErrorr�__new__�	_bus_type)�clsZbus_type�privater�subclassZbus�r �/usr/lib64/python3.6/_dbus.pyr:s

zBus.__new__cs4|j}|jjj|�|kr"|jj|=tt|�j�dS)N)r�	__class__r�get�superr�close)�self�t)r"r r!r%ms
z	Bus.closecCs|S)z�Return self, for backwards compatibility with earlier dbus-python
        versions where Bus was not a subclass of Connection.

        :Deprecated: since 0.80.0
        r )r&r r r!�get_connectionsszBus.get_connectionz�self._connection == self, for backwards
                           compatibility with earlier dbus-python versions
                           where Bus was not a subclass of Connection.cCs
t|d�S)z�Static method that returns a connection to the session bus.

        :Parameters:
            `private` : bool
                If true, do not return a shared connection.
        )r)r)rr r r!�get_sessionszBus.get_sessioncCs
t|d�S)z�Static method that returns a connection to the system bus.

        :Parameters:
            `private` : bool
                If true, do not return a shared connection.
        )r)r)rr r r!�
get_system�szBus.get_systemcCs
t|d�S)z�Static method that returns a connection to the starter bus.

        :Parameters:
            `private` : bool
                If true, do not return a shared connection.
        )r)r)rr r r!�get_starter�szBus.get_startercCsP|jtkrd}n$|jtkr d}n|jtkr0d}nd}d|jj|jj|t|�fS)NZsession�systemZstarterzunknown bus typez<%s.%s (%s) at %#x>)rrr
rr"�
__module__�__name__�id)r&�namer r r!�__repr__�s


zBus.__repr__)F)F)F)r.r-�__qualname__�__doc__rr�TYPE_SESSIONrr%r(�propertyZ_connectionr)�staticmethodr*r+r1�__str__�
__classcell__r r )r"r!r/s 2
	
	
	
c@seZdZdZddd�ZdS)rzThe system-wide message bus.FNcCstj|tj||d�S)a�Return a connection to the system bus.

        :Parameters:
            `private` : bool
                If true, never return an existing shared instance, but instead
                return a private connection.
            `mainloop` : dbus.mainloop.NativeMainLoop
                The main loop to use. The default is to use the default
                main loop if one has been set up, or raise an exception
                if none has been.
        )rr)rrZTYPE_SYSTEM)rrrr r r!r�szSystemBus.__new__)FN)r.r-r2r3rr r r r!r�sc@seZdZdZddd�ZdS)rz(The session (current login) message bus.FNcCstj|tj||d�S)a�Return a connection to the session bus.

        :Parameters:
            `private` : bool
                If true, never return an existing shared instance, but instead
                return a private connection.
            `mainloop` : dbus.mainloop.NativeMainLoop
                The main loop to use. The default is to use the default
                main loop if one has been set up, or raise an exception
                if none has been.
        )rr)rrr4)rrrr r r!r�szSessionBus.__new__)FN)r.r-r2r3rr r r r!r�sc@seZdZdZddd�ZdS)rzjThe bus that activated this process (only valid if
    this process was launched by DBus activation).
    FNcCstj|tj||d�S)a�Return a connection to the bus that activated this process.

        :Parameters:
            `private` : bool
                If true, never return an existing shared instance, but instead
                return a private connection.
            `mainloop` : dbus.mainloop.NativeMainLoop
                The main loop to use. The default is to use the default
                main loop if one has been set up, or raise an exception
                if none has been.
        )rr)rrZTYPE_STARTER)rrrr r r!r�szStarterBus.__new__)FN)r.r-r2r3rr r r r!r�sN)rrrr)r3Z
__future__r�__all__Z
__docformat__Zdbus.exceptionsrZ_dbus_bindingsrr	r
rrr
rrrrrrZdbus.busrZ
dbus.lowlevelrZdbus._compatrrrrrrr r r r!�<module>s8PKMW�\Ϥ���U�U"__pycache__/service.cpython-36.pycnu�[���3

iR�V��@s:dZdZddlZddlZddlZddlZddlmZddlZdd	l	m
Z
mZmZm
Z
mZmZmZdd
lmZmZddlmZmZmZddlmZmZmZdd
lmZddlmZej d�Z!Gdd�de"�Z#Gdd�de"�Z$dd�Z%dd�Z&dd�Z'Gdd�de(�Z)e)de"fi�Z*e"�Z+Gdd�de*�Z,Gdd�de,�Z-dS)�BusName�Object�FallbackObject�method�signalZrestructuredtext�N)�Sequence)�INTROSPECTABLE_IFACE�
ObjectPath�
SessionBus�	Signature�Struct�validate_bus_name�validate_object_path)rr)�
DBusException�NameExistsException�UnknownMethodException)�ErrorMessage�MethodReturnMessage�MethodCallMessage)�
LOCAL_PATH)�is_py2zdbus.servicec@s(eZdZdZdd�Zdd�Zer$eZdS)�_VariantSignaturez�A fake method signature which, when iterated, yields an endless stream
    of 'v' characters representing variants (handy with zip()).

    It has no string representation.
    cCs|S)zReturn self.�)�selfrr�/usr/lib64/python3.6/service.py�__iter__8sz_VariantSignature.__iter__cCsdS)zReturn 'v' whenever called.�vr)rrrr�__next__<sz_VariantSignature.__next__N)�__name__�
__module__�__qualname__�__doc__rrr�nextrrrrr2s
rc@sFeZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	e	Z
dS)ra^A base class for exporting your own Named Services across the Bus.

    When instantiated, objects of this class attempt to claim the given
    well-known name on the given bus for the current process. The name is
    released when the BusName object becomes unreferenced.

    If a well-known name is requested multiple times, multiple references
    to the same BusName object will be returned.

    Caveats
    -------
    - Assumes that named services are only ever requested using this class -
      if you request names from the bus directly, confusion may occur.
    - Does not handle queueing.
    NFc
Cs�t|ddd�|dkr4ddl}|jdtdd�t�}||jkrH|j|S|rRtjpTd|r^tjp`dB|rltj	pndB}|j
||�}|tjkr�n<|tjkr�n0|tj
kr�t|��n|tjkr�ntd	||f��tj|�}	||	_||	_|	|j|<|	S)
aSConstructor, which may either return an existing cached object
        or a new object.

        :Parameters:
            `name` : str
                The well-known name to be advertised
            `bus` : dbus.Bus
                A Bus on which this service will be advertised.

                Omitting this parameter or setting it to None has been
                deprecated since version 0.82.1. For backwards compatibility,
                if this is done, the global shared connection to the session
                bus will be used.

            `allow_replacement` : bool
                If True, other processes trying to claim the same well-known
                name will take precedence over this one.
            `replace_existing` : bool
                If True, this process can take over the well-known name
                from other processes already holding it.
            `do_not_queue` : bool
                If True, this service will not be placed in the queue of
                services waiting for the requested name if another service
                already holds it.
        TF)Zallow_well_knownZallow_uniqueNrzKOmitting the "bus" parameter to dbus.service.BusName.__init__ is deprecated�)�
stacklevelz3requesting bus name %s returned unexpected value %s)r
�warnings�warn�DeprecationWarningr
Z
_bus_names�_dbus_bindingsZNAME_FLAG_ALLOW_REPLACEMENTZNAME_FLAG_REPLACE_EXISTINGZNAME_FLAG_DO_NOT_QUEUEZrequest_nameZ REQUEST_NAME_REPLY_PRIMARY_OWNERZREQUEST_NAME_REPLY_IN_QUEUEZREQUEST_NAME_REPLY_EXISTSrZ REQUEST_NAME_REPLY_ALREADY_OWNER�RuntimeError�object�__new__�_bus�_name)
�cls�nameZbusZallow_replacementZreplace_existingZdo_not_queuer%Z
name_flags�retval�bus_namerrrr+Ts2









zBusName.__new__cOsdS)Nr)r�args�keywordsrrr�__init__�szBusName.__init__cCs|jj|j�dS)N)r,Zrelease_namer-)rrrr�__del__�szBusName.__del__cCs|jS)zGet the Bus this Service is on)r,)rrrr�get_bus�szBusName.get_buscCs|jS)zGet the name of this service)r-)rrrr�get_name�szBusName.get_namecCsd|j|jt|�fS)Nz&<dbus.service.BusName %s on %r at %#x>)r-r,�id)rrrr�__repr__�szBusName.__repr__)NFFF)rrr r!r+r4r5r6r7r9�__str__rrrrrDs
OcCs^d}d}d}|r�x�|jjD]�}|rz||jkrzd|j|jkrvd|j|jkrv|j|j|krz|}|j|}d}Pqzn|}|r||jkrd|j|jkrd|j|jkr|j|j|kr|j|}d}PqWnTxR|jjD]F}|r�||jkr�|}|r�||jkr�d|j|jkr�|j|}d}Pq�W|�r6|j||fS|�rNtd||f��ntd|��dS)z�Walks the Python MRO of the given class to find the method to invoke.

    Returns two methods, the one to call, and the one it inherits from which
    defines its D-Bus interface name, signature, and attributes.
    NF�_dbus_is_method�_dbus_interfaceTz(%s is not a valid method of interface %sz%s is not a valid method)�	__class__�__mro__�__dict__r<r)r�method_nameZdbus_interface�
parent_methodZcandidate_classZ
successfulr.rrr�_method_lookup�sF


rBc Gs�t|�}y|j|d|i�Wn�tk
r�}zvtj�|dkr�y|j|�d}Wn6tk
r�}ztjd||j|��WYdd}~XnXtjd|||j|��WYdd}~XnX|j	|�dS)N�	signaturez
 (guessed)z2Unable to guess signature for arguments %r: %s: %sz8Unable to append %r to message with signature %s: %s: %s)
r�append�	Exception�loggingZbasicConfigZguess_signature�_logger�errorr=�send_message)�
connection�messager@rCr0�reply�errr�_method_reply_return�s rNc	Cs�t|dd�}|dk	rn0t|dd�dkr4d|jj}nd|j|jjf}tj�\}}}t|t�rp|jrp|j	�}n2||kr�dj
tj|||��}ndj
tj
|j|��}t|||�}|j|�dS)NZ_dbus_error_namer��__main__zorg.freedesktop.DBus.Python.%sz!org.freedesktop.DBus.Python.%s.%s)rOrP)�getattrr=rr�sys�exc_info�
isinstancerZinclude_tracebackZget_dbus_message�join�	traceback�format_exception�format_exception_onlyrrI)	rJrK�	exceptionr/ZetZevZetb�contentsrLrrr�_method_reply_errors
r[cs,eZdZ�fdd�Zdd�Zdd�Z�ZS)�
InterfaceTypecs�t|di�}||_i}||jd|<xX|D]P}|jd|j}t|dd�r.x.||j�D]\}}	|j|i�}
|
j|	�q\Wq.Wx4|j�D](}t|dd�r�|j|ji�}	||	|j<q�Wt	t
|�j|||�dS)N�_dbus_class_table�.Fr<)rQr]rr�items�
setdefault�update�valuesr<�superr\r4)r.r/�basesZdctZclass_tableZinterface_table�bZ	base_nameZ	interfaceZmethod_tableZour_method_table�func)r=rrr4,s
zInterfaceType.__init__cCs�|j}|jrtt|j��}nt�}|jr4t|j�}ng}d|j}xt||�D]}|d|7}qNWx|D]}|d|7}qhW|d7}|S)Nz    <method name="%s">
z2      <arg direction="in"  type="%s" name="%s" />
z(      <arg direction="out" type="%s" />
z    </method>
)�
_dbus_argsZ_dbus_in_signature�tuplerr�_dbus_out_signaturer�zip)r.rfr2Zin_sigZout_sig�reflection_data�pair�typerrr�_reflect_on_methodFs

z InterfaceType._reflect_on_methodcCsX|j}|jrtt|j��}nt�}d|j}xt||�D]}|d|}q8W|d}|S)Nz    <signal name="%s">
z"      <arg type="%s" name="%s" />
z    </signal>
)rgZ_dbus_signaturerhrrrrj)r.rfr2Zsigrkrlrrr�_reflect_on_signalcs
z InterfaceType._reflect_on_signal)rrr r4rnro�
__classcell__rr)r=rr\+sr\�	Interfacec@s�eZdZdZdZdZddd�Zedd��Zedd	��Z	ed
d��Z
dd
�Zddd�Zdd�Z
dd�Zeeddddd�dd��Zdd�ZeZdS)ra�A base class for exporting your own Objects across the Bus.

    Just inherit from Object and mark exported methods with the
    @\ `dbus.service.method` or @\ `dbus.service.signal` decorator.

    Example::

        class Example(dbus.service.object):
            def __init__(self, object_path):
                dbus.service.Object.__init__(self, dbus.SessionBus(), path)
                self._last_input = None

            @dbus.service.method(interface='com.example.Sample',
                                 in_signature='v', out_signature='s')
            def StringifyVariant(self, var):
                self.LastInputChanged(var)      # emits the signal
                return str(var)

            @dbus.service.signal(interface='com.example.Sample',
                                 signature='v')
            def LastInputChanged(self, var):
                # run just before the signal is actually emitted
                # just put "pass" if nothing should happen
                self._last_input = var

            @dbus.service.method(interface='com.example.Sample',
                                 in_signature='', out_signature='v')
            def GetLastInput(self):
                return self._last_input
    FNcCs�|dk	rt|�t|t�r(|}|j�}n|dkr@|dk	r@|j�}d|_d|_g|_tj�|_	d|_
||_|dkr�|dk	r�td��|dk	r�|dk	r�|j
||�dS)aConstructor. Either conn or bus_name is required; object_path
        is also required.

        :Parameters:
            `conn` : dbus.connection.Connection or None
                The connection on which to export this object.

                If None, use the Bus associated with the given ``bus_name``.
                If there is no ``bus_name`` either, the object is not
                initially available on any Connection.

                For backwards compatibility, if an instance of
                dbus.service.BusName is passed as the first parameter,
                this is equivalent to passing its associated Bus as
                ``conn``, and passing the BusName itself as ``bus_name``.

            `object_path` : str or None
                A D-Bus object path at which to make this Object available
                immediately. If this is not None, a `conn` or `bus_name` must
                also be provided.

            `bus_name` : dbus.service.BusName or None
                Represents a well-known name claimed by this process. A
                reference to the BusName object will be held by this
                Object, preventing the name from being released during this
                Object's lifetime (unless it's released manually).
        NFz<If object_path is given, either conn or bus_name is required)rrTrr6�_object_path�_connection�
_locations�	threadingZLock�_locations_lock�	_fallbackr-�	TypeError�add_to_connection)r�conn�object_pathr1rrrr4�s$


zObject.__init__cCs:|jtkrtd|��n|jdkr0td|��n|jSdS)z�The object-path at which this object is available.
        Access raises AttributeError if there is no object path, or more than
        one object path.

        Changed in 0.82.0: AttributeError can be raised.
        zEObject %r has more than one object path: use Object.locations insteadNz Object %r has no object path yet)rr�_MANY�AttributeError)rrrr�__dbus_object_path__�s


zObject.__dbus_object_path__cCs:|jtkrtd|��n|jdkr0td|��n|jSdS)z�The Connection on which this object is available.
        Access raises AttributeError if there is no Connection, or more than
        one Connection.

        Changed in 0.82.0: AttributeError can be raised.
        zFObject %r is on more than one Connection: use Object.locations insteadNzObject %r has no Connection yet)rsr|r})rrrrrJ�s


zObject.connectioncCs
t|j�S)aeAn iterable over tuples representing locations at which this
        object is available.

        Each tuple has at least two items, but may have more in future
        versions of dbus-python, so do not rely on their exact length.
        The first two items are the dbus.connection.Connection and the object
        path.

        :Since: 0.82.0
        )�iterrt)rrrr�	locationsszObject.locationscCs�|tkrtdt��|jj�z�|jdk	rN|j|k	rN|jrNtd||jf��|jdk	r||jr||j|kr|td||jf��|j||j	|j
|j�|jdkr�||_n|j|k	r�t|_|jdkr�||_n|j|kr�t|_|j
j|||jf�Wd|jj�XdS)aNMake this object accessible via the given D-Bus connection and
        object path.

        :Parameters:
            `connection` : dbus.connection.Connection
                Export the object on this connection. If the class attribute
                SUPPORTS_MULTIPLE_CONNECTIONS is False (default), this object
                can only be made available on one connection; if the class
                attribute is set True by a subclass, the object can be made
                available on more than one connection.

            `path` : dbus.ObjectPath or other str
                Place the object at this object path. If the class attribute
                SUPPORTS_MULTIPLE_OBJECT_PATHS is False (default), this object
                can only be made available at one object path; if the class
                attribute is set True by a subclass, the object can be made
                available with more than one object path.

        :Raises ValueError: if the object's class attributes do not allow the
            object to be exported in the desired way.
        :Since: 0.82.0
        z3Objects may not be exported on the reserved path %sNz'%r is already exported on connection %rz(%r is already exported at object path %s)r�
ValueErrorrv�acquirers�SUPPORTS_MULTIPLE_CONNECTIONSrr�SUPPORTS_MULTIPLE_OBJECT_PATHSZ_register_object_path�_message_cb�_unregister_cbrwr|rtrD�release)rrJ�pathrrrrys8









zObject.add_to_connectioncCs$|jj��z|jdks"|jdkr.td|��|dk	s>|dk	r�g}xN|jD]6}|dksb|d|krJ|dksv|d|krJ|j|�qJWn|j}g|_|s�td|||f��xf|D]^}y|dj|d�Wntk
r�YnX|jr�y|jj|�Wq�t	k
�r
Yq�Xq�WWd|jj
�XdS)aMake this object inaccessible via the given D-Bus connection
        and object path. If no connection or path is specified,
        the object ceases to be accessible via any connection or path.

        :Parameters:
            `connection` : dbus.connection.Connection or None
                Only remove the object from this Connection. If None,
                remove from all Connections on which it's exported.
            `path` : dbus.ObjectPath or other str, or None
                Only remove the object from this object path. If None,
                remove from all object paths.
        :Raises LookupError:
            if the object was not exported on the requested connection
            or path, or (if both are None) was not exported at all.
        :Since: 0.81.1
        Nz%r is not exportedr�z1%r is not exported at a location matching (%r,%r))rvr�rrrs�LookupErrorrtrDZ_unregister_object_path�remover�r�)rrJr�Zdropped�locationrrr�remove_from_connectionPs4

zObject.remove_from_connectioncCstjd||�dS)Nz5Unregistering exported object %r from some path on %r)rG�info)rrJrrrr��szObject._unregister_cbcs�t�t�sdS�y`�j���j�}t|�|�\}}�jf|j�}i}|jdk	rZt|j��nd�|j	r�|j	\}}	����fdd�||<��fdd�||	<|j
r��j�||j
<|jr��j
�||j<|j�r^�j
�}
|
}xx|jD]n}|d�kr�|
|dk�r�d}P|ddk�rq�|
j|dd�r�|
t|d�d�}
t|
�t|�kr�|
}q�Wt|�}|||j<|j�rt�j�||j<|j�r��||j<|j�r��||j<||f|�|�}|j	�r�dS�dk	�r(t��}t|�dk�r�|dk�r�f}ntd���n4t|�dk�r|f}nt|t��rntd��f��n2|dk�r8f}n"t|t��rTt|t��rTn|f}t����f|��Wn0tk
�r�}zt��|�WYdd}~XnXdS)	Ncst����f|��S)N)rN)r0)rJrKr@rCrr�<lambda>�sz$Object._message_cb.<locals>.<lambda>cst��|�S)N)r[)rY)rJrKrrr��srr��/z8%s has an empty output signature but did not return NonezK%s has multiple output values in signature %s but did not return a sequence)rTrZ
get_memberZ
get_interfacerBZ
get_args_listZ_dbus_get_args_optionsrirZ_dbus_async_callbacksZ_dbus_sender_keywordZ
get_senderZ_dbus_path_keyword�get_pathZ_dbus_rel_path_keywordrt�
startswith�lenr	Z_dbus_destination_keywordZget_destinationZ_dbus_message_keywordZ_dbus_connection_keywordrhrxrrrNrEr[)rrJrKZinterface_nameZcandidate_methodrAr2r3Zreturn_callbackZerror_callbackr�Zrel_pathZexp�suffixr0Zsignature_tuplerYr)rJrKr@rCrr��s�









zObject._message_cbrO�sr{rJ)Zin_signatureZ
out_signatureZpath_keywordZconnection_keywordcCs�tj}|d|7}|j|jjd|jj}xt|j�D]h\}}|d|7}xJ|j�D]>}t|dd�rv||jj	|�7}qTt|dd�rT||jj
|�7}qTW|d7}q6Wx|j|�D]}|d|7}q�W|d	7}|S)
ziReturn a string of XML encoding this object's supported interfaces,
        methods and signals.
        z<node name="%s">
r^z  <interface name="%s">
r;FZ_dbus_is_signalz  </interface>
z  <node name="%s"/>
z</node>
)r(Z)DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODEr]r=rrr_rbrQrnroZlist_exported_child_objects)rr{rJrkZ
interfacesr/Zfuncsrfrrr�
Introspect�szObject.IntrospectcCs>d}|jtk	r"|jdk	r"d|j}d|jj|jj|t|�fS)NrOz at %sz<%s.%s%s at %#x>)rrr|r=rrr8)r�whererrrr9s


zObject.__repr__)NNN)NN)rrr r!r�r�r4�propertyr~rJr�ryr�r�r�rrr�r9r:rrrrrs
=;
1ncs&eZdZdZdZd�fdd�	Z�ZS)rzaAn object that implements an entire subtree of the object-path
    tree.

    :Since: 0.82.0
    TNcsPtt|�j�d|_|dkr.|dk	rLtd��n|dkr@td��n|j||�dS)aHConstructor.

        Note that the superclass' ``bus_name`` __init__ argument is not
        supported here.

        :Parameters:
            `conn` : dbus.connection.Connection or None
                The connection on which to export this object. If this is not
                None, an `object_path` must also be provided.

                If None, the object is not initially available on any
                Connection.

            `object_path` : str or None
                A D-Bus object path at which to make this Object available
                immediately. If this is not None, a `conn` must also be
                provided.

                This object will implements all object-paths in the subtree
                starting at this object-path, except where a more specific
                object has been added.
        TNz)If object_path is given, conn is requiredz)If conn is given, object_path is required)rcrr4rwrxry)rrzr{)r=rrr4#s

zFallbackObject.__init__)NN)rrr r!r�r4rprr)r=rrs)rrrrr).�__all__Z
__docformat__rRrFrurV�collectionsrr(Zdbusrr	r
rrr
rZdbus.decoratorsrrZdbus.exceptionsrrrZ
dbus.lowlevelrrrZdbus.proxiesrZdbus._compatrZ	getLoggerrGr*rrrBrNr[rmr\rqr|rrrrrr�<module>s6$
uBMPKMW�\ܟ �yy+__pycache__/gi_service.cpython-36.opt-1.pycnu�[���3

iR�V�
�@sfdZdgZddlmZddlZGdd�dejjejj�Z	ddd�Z
d	Ze	dejejjfe
ed
��Z
dS)z6Support code for implementing D-Bus services via PyGI.�ExportedGObject�)�GObjectNc@seZdZdZdd�ZdS)�ExportedGObjectTypez�A metaclass which inherits from both GObjectMeta and
    `dbus.service.InterfaceType`. Used as the metaclass for `ExportedGObject`.
    cCs,tjjj||||�tjjj||||�dS)N)r�	__class__�__init__�dbus�service�
InterfaceType)�cls�name�basesZdct�r
�"/usr/lib64/python3.6/gi_service.pyr,szExportedGObjectType.__init__N)�__name__�
__module__�__qualname__�__doc__rr
r
r
rr(srcKsT|jdd�}|jdd�}|dk	r*|j|�tjj|f|�tjjj||||d�dS)a:Initialize an exported GObject.

    :Parameters:
        `conn` : dbus.connection.Connection
            The D-Bus connection or bus
        `object_path` : str
            The object path at which to register this object.
    :Keywords:
        `bus_name` : dbus.service.BusName
            A bus name to be held on behalf of this object, or None.
        `gobject_properties` : dict
            GObject properties to be set on the constructed object.

            Any unrecognised keyword arguments will also be interpreted
            as GObject properties.
        �bus_nameN�gobject_properties)�conn�object_pathr)�pop�updaterrrr�Object)�selfrr�kwargsrrr
r
r�ExportedGObject__init__1s
rz)A GObject which is exported on the D-Bus.)rr)NN)r�__all__Z
gi.repositoryrZdbus.servicerrrr	rrZExportedGObject__doc__rrr
r
r
r�<module>s	
PKMW�\�Y=��%__pycache__/exceptions.cpython-36.pycnu�[���3

iR�VB�@s�dZdZdd	lmZGd
d�de�ZGdd�de�ZGdd�de�ZGd
d�de�ZGdd�de�Z	Gdd�de�Z
Gdd�de�ZdS)zD-Bus exceptions.�
DBusException�MissingErrorHandlerException�MissingReplyHandlerException�ValidationException�IntrospectionParserException�UnknownMethodException�NameExistsException�)�is_py3c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
rFcOsX|jdd�}|dk	s$t|dd�dkr*||_|rDtddj|j����tj|f|��dS)N�name�_dbus_error_namez1DBusException does not take keyword arguments: %sz, )�pop�getattrr�	TypeError�join�keys�	Exception�__init__)�self�args�kwargsr
�r�"/usr/lib64/python3.6/exceptions.pyr-szDBusException.__init__cCsFt|j�dkrt|j�}ndj|j�}|jdk	r>d|j|fS|SdS)zReturn a unicode error��Nz%s: %s)�lenr�unicoderr)r�srrr�__unicode__6s
zDBusException.__unicode__cCs*tj|�}|jdk	r"d|j|fS|SdS)zReturn a str errorNz%s: %s)r�__str__r)rrrrrrDs

zDBusException.__str__cCsPt|j�dkr*trt|j�}q6t|j�}ndj|j�}t|t�rL|jdd�S|S)Nrrzutf-8�replace)	rrr	�strrr�
isinstance�bytes�decode)rrrrr�get_dbus_messageLs
zDBusException.get_dbus_messagecCs|jS)N)r)rrrr�
get_dbus_nameZszDBusException.get_dbus_nameN)	�__name__�
__module__�__qualname__�include_tracebackrrrr$r%rrrrr!s
	c@seZdZdZdd�ZdS)rTcCstj|d�dS)Nz^error_handler not defined: if you define a reply_handler you must also define an error_handler)rr)rrrrrasz%MissingErrorHandlerException.__init__N)r&r'r(r)rrrrrr]sc@seZdZdZdd�ZdS)rTcCstj|d�dS)Nz^reply_handler not defined: if you define an error_handler you must also define a reply_handler)rr)rrrrrhsz%MissingReplyHandlerException.__init__N)r&r'r(r)rrrrrrdsc@seZdZdZddd�ZdS)rTrcCstj|d|�dS)NzError validating string: %s)rr)r�msgrrrroszValidationException.__init__N)r)r&r'r(r)rrrrrrksc@seZdZdZddd�ZdS)rTrcCstj|d|�dS)Nz!Error parsing introspect data: %s)rr)rr*rrrrvsz%IntrospectionParserException.__init__N)r)r&r'r(r)rrrrrrrsc@seZdZdZdZdd�ZdS)rTz(org.freedesktop.DBus.Error.UnknownMethodcCstj|d|�dS)NzUnknown method: %s)rr)r�methodrrrr~szUnknownMethodException.__init__N)r&r'r(r)rrrrrrrysc@seZdZdZdd�ZdS)rTcCstj|d|�dS)NzBus name already exists: %s)rr)rr
rrrr�szNameExistsException.__init__N)r&r'r(r)rrrrrr�sN)rrrrrrr)�__doc__�__all__Zdbus._compatr	rrrrrrrrrrrr�<module>s<PKMW�\���rDrD"__pycache__/proxies.cpython-36.pycnu�[���3

iR�V�`�@s�ddlZyddlmZWn ek
r8ddlmZYnXddlZddlmZddlm	Z	m
Z
mZmZdZ
ejd�ZddlmZmZmZmZmZddlmZGd	d
�d
�ZGdd�d�ZGd
d�de�ZGdd�de�ZdS)�N)�RLock)�process_introspection_data)�
DBusException�IntrospectionParserException�MissingErrorHandlerException�MissingReplyHandlerExceptionZrestructuredtextzdbus.proxies)�BUS_DAEMON_IFACE�BUS_DAEMON_NAME�BUS_DAEMON_PATH�INTROSPECTABLE_IFACE�
LOCAL_PATH)�is_py2c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_DeferredMethodzXA proxy method which will only get called once we have its
    introspection reply.
    cCs||_|j|_||_||_dS)N)�
_proxy_method�_method_name�_append�_block)�self�proxy_method�append�block�r�/usr/lib64/python3.6/proxies.py�__init__6sz_DeferredMethod.__init__cOs@d|ks|jdd�r(|j|j||�dS|j�|j||�SdS)N�
reply_handler�ignore_replyF)�getrrr)r�args�keywordsrrr�__call__=sz_DeferredMethod.__call__cOs|j|j||�dS)N)rr)rrrrrr�
call_asyncHsz_DeferredMethod.call_asyncN)�__name__�
__module__�__qualname__�__doc__rrr rrrrr2src@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_ProxyMethodz�A proxy method.

    Typically a member of a ProxyObject. Calls to the
    method produce messages that travel over the Bus and are routed
    to a specific named Service.
    cCsX|tkrtdt��||_||_||_||_tj|�||_|dk	rNtj	|�||_
dS)Nz1Methods may not be called on the reserved path %s)rr�_proxy�_connection�_named_service�_object_path�_dbus_bindingsZvalidate_member_namerZvalidate_interface_name�_dbus_interface)r�proxyZ
connection�bus_name�object_pathZmethod_nameZifacerrrrSs

z_ProxyMethod.__init__c		Os|jdd�}|jdd�}|jdd�}|jdd�}|dk	s@|dk	rl|dkrPt��n|dkr`t��n|rltd��|jd|j�}|dkr�|dkr�|j}n|d|j}|jjj|d�}|s�|dk	r�|j	j
|j|j||j||||f|�n |j	j
|j|j||j||f|�SdS)	Nr�
error_handlerrF�	signaturez6ignore_reply and reply_handler cannot be used together�dbus_interface�.)�poprr�	TypeErrorr+rr&�_introspect_method_maprr'r r(r)Z
call_blocking)	rrrrr/rr0r1�keyrrrrgsD

z_ProxyMethod.__call__c	Os�|jdd�}|jdd�}|jdd�}|jd|j�}|dkrd|rN|d|j}n|j}|jjj|d�}|jj|j|j	||j||||f|�dS)Nrr/r0r1r2)
r3r+rr&r5rr'r r(r))rrrrr/r0r1r6rrrr �s$
z_ProxyMethod.call_asyncN)r!r"r#r$rrr rrrrr%Ls,r%c@s�eZdZdZeZeZdZdZ	dZ
d%dd	�Zed
d�ddd�Z
ed
d�ddd�Zedd�ddd�Zd&dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd'd!d"�Zd#d$�ZeZdS)(�ProxyObjectz�A proxy to the remote Object.

    A ProxyObject is provided by the Bus. ProxyObjects
    have member functions, and can be called like normal Python objects.
    r��NTFc
Ks<|jdd�}|dk	rB|dk	r$td��|}ddlm}|dtdd�|jd	d�}	|	dk	r�|dk	rftd
��|	}ddlm}|dtdd�|r�tdd
j|j����|r�|j�||_|dk	r�t	j
|�||_|_t	j
|�||_|s�|j|�|_d|_g|_i|_t�|_|�s|jtk�r&|j|_n|j|_|j�|_dS)a�Initialize the proxy object.

        :Parameters:
            `conn` : `dbus.connection.Connection`
                The bus or connection on which to find this object.
                The keyword argument `bus` is a deprecated alias for this.
            `bus_name` : str
                A bus name for the application owning the object, to be used
                as the destination for method calls and the sender for
                signal matches. The keyword argument ``named_service`` is a
                deprecated alias for this.
            `object_path` : str
                The object path at which the application exports the object
            `introspect` : bool
                If true (default), attempt to introspect the remote
                object to find out supported methods and their signatures
            `follow_name_owner_changes` : bool
                If true (default is false) and the `bus_name` is a
                well-known name, follow ownership changes for that name
        �busNz%conn and bus cannot both be specifiedr)�warnz`Passing the bus parameter to ProxyObject by name is deprecated: please use positional parametersr9)�
stacklevel�
named_servicez3bus_name and named_service cannot both be specifiedzjPassing the named_service parameter to ProxyObject by name is deprecated: please use positional parametersz>ProxyObject.__init__ does not take these keyword arguments: %sz, )r3r4�warningsr;�DeprecationWarning�join�keysZ_require_main_loop�_busr*Zvalidate_bus_namer(�_requested_bus_nameZvalidate_object_path�__dbus_object_path__Zactivate_name_owner�_pending_introspect�_pending_introspect_queuer5r�_introspect_lockr� INTROSPECT_STATE_DONT_INTROSPECT�_introspect_state�'INTROSPECT_STATE_INTROSPECT_IN_PROGRESS�_Introspect)
rZconnr-r.Z
introspectZfollow_name_owner_changes�kwargsr:r;r=rrrr�sJ




zProxyObject.__init__cCs|jS)N)r()rrrr�<lambda>szProxyObject.<lambda>a�The bus name to which this proxy is bound. (Read-only,
            may change.)

            If the proxy was instantiated using a unique name, this property
            is that unique name.

            If the proxy was instantiated with a well-known name and with
            ``follow_name_owner_changes`` set false (the default), this
            property is the unique name of the connection that owned that
            well-known name when the proxy was instantiated, which might
            not actually own the requested well-known name any more.

            If the proxy was instantiated with a well-known name and with
            ``follow_name_owner_changes`` set true, this property is that
            well-known name.
            cCs|jS)N)rC)rrrrrMsz[The bus name which was requested when this proxy was
            instantiated.
            cCs|jS)N)rD)rrrrrM$szThe object-path of this proxy.cKs"|jj|f|||j|jd�|��S)axArrange for the given function to be called when the given signal
        is received.

        :Parameters:
            `signal_name` : str
                The name of the signal
            `handler_function` : callable
                A function to be called when the signal is emitted by
                the remote object. Its positional arguments will be the
                arguments of the signal; optionally, it may be given
                keyword arguments as described below.
            `dbus_interface` : str
                Optional interface with which to qualify the signal name.
                If None (the default) the handler will be called whenever a
                signal of the given member name is received, whatever
                its interface.
        :Keywords:
            `utf8_strings` : bool
                If True, the handler function will receive any string
                arguments as dbus.UTF8String objects (a subclass of str
                guaranteed to be UTF-8). If False (default) it will receive
                any string arguments as dbus.String objects (a subclass of
                unicode).
            `byte_arrays` : bool
                If True, the handler function will receive any byte-array
                arguments as dbus.ByteArray objects (a subclass of str).
                If False (default) it will receive any byte-array
                arguments as a dbus.Array of dbus.Byte (subclasses of:
                a list of ints).
            `sender_keyword` : str
                If not None (the default), the handler function will receive
                the unique name of the sending endpoint as a keyword
                argument with this name
            `destination_keyword` : str
                If not None (the default), the handler function will receive
                the bus name of the destination (or None if the signal is a
                broadcast, as is usual) as a keyword argument with this name.
            `interface_keyword` : str
                If not None (the default), the handler function will receive
                the signal interface as a keyword argument with this name.
            `member_keyword` : str
                If not None (the default), the handler function will receive
                the signal name as a keyword argument with this name.
            `path_keyword` : str
                If not None (the default), the handler function will receive
                the object-path of the sending object as a keyword argument
                with this name
            `message_keyword` : str
                If not None (the default), the handler function will receive
                the `dbus.lowlevel.SignalMessage` as a keyword argument with
                this name.
            `arg...` : unicode or UTF-8 str
                If there are additional keyword parameters of the form
                ``arg``\ *n*, match only signals where the *n*\ th argument
                is the value given for that keyword parameter. As of this time
                only string arguments can be matched (in particular,
                object paths and signatures can't).
        )�signal_namer1r-�path)rBZadd_signal_receiverr(rD)rrN�handler_functionr1rrrr�connect_to_signal0s<
zProxyObject.connect_to_signalc	Cs>i}trd|d<|jj|j|jtddf|j|jfddi|��S)NTZutf8_stringsZ
Introspect�Zrequire_main_loopF)r
rBr r(rDr�_introspect_reply_handler�_introspect_error_handler)rrLrrrrKss
zProxyObject._IntrospectcCs*x|jD]\}}}|||�qWg|_dS)N)rF)rrrrrrr�_introspect_execute_queue~sz%ProxyObject._introspect_execute_queuecCsp|jj�zTyt|�|_Wn*tk
rD}z|j|�dSd}~XnX|j|_d|_|j	�Wd|jj
�XdS)N)rG�acquirerr5rrT� INTROSPECT_STATE_INTROSPECT_DONErIrErU�release)r�data�errrrS�s

z%ProxyObject._introspect_reply_handlerc
Cshtj�tjd|j|j|jj|jj|�|j	j
�z$tjd�|j|_
d|_|j�Wd|j	j�XdS)Nz$Introspect error on %s:%s: %s.%s: %sz'Executing introspect queue due to error)�loggingZbasicConfig�_logger�errorr(rD�	__class__r"r!rGrV�debugrHrIrErUrX)rr]rrrrT�s

z%ProxyObject._introspect_error_handlerc
Cs4|jj�z|jdk	r |jj�Wd|jj�XdS)N)rGrVrErrX)rrrr�_introspect_block�s


zProxyObject._introspect_blockc
CsJ|jj�z.|j|jkr,|jj|||f�n
|||�Wd|jj�XdS)N)rGrVrIrJrFrrX)r�callbackrrLrrr�_introspect_add_to_queue�s
z$ProxyObject._introspect_add_to_queuecCs,|jd�r|jd�rt|��n
|j|�SdS)N�__)�
startswith�endswith�AttributeError�get_dbus_method)r�memberrrr�__getattr__�s
zProxyObject.__getattr__cCs<|j||j|j|j||�}|j|jkr8|j||j|j�}|S)a,Return a proxy method representing the given D-Bus method. The
        returned proxy method can be called in the usual way. For instance, ::

            proxy.get_dbus_method("Foo", dbus_interface='com.example.Bar')(123)

        is equivalent to::

            proxy.Foo(123, dbus_interface='com.example.Bar')

        or even::

            getattr(proxy, "Foo")(123, dbus_interface='com.example.Bar')

        However, using `get_dbus_method` is the only way to call D-Bus
        methods with certain awkward names - if the author of a service
        implements a method called ``connect_to_signal`` or even
        ``__getattr__``, you'll need to use `get_dbus_method` to call them.

        For services which follow the D-Bus convention of CamelCaseMethodNames
        this won't be a problem.
        )	�ProxyMethodClassrBr(rDrIrJ�DeferredMethodClassrbr`)rrhr1�retrrrrg�s

zProxyObject.get_dbus_methodcCsd|j|j|jt|�fS)Nz&<ProxyObject wrapping %s %s %s at %#x>)rBr(rD�id)rrrr�__repr__�szProxyObject.__repr__)NNNTF)N)N)r!r"r#r$r%rjrrkrHrJrWr�propertyr-�requested_bus_namer.rQrKrUrSrTr`rbrirgrn�__str__rrrrr7�s6
R

C

&r7c@s�eZdZdZdd�Zedd�ddd�ZeZedd�ddd	�Zed
d�ddd�Z	edd�ddd
�Z
edd�ddd�Zddd�Zdd�Z
ddd�Zdd�ZeZdS)�	Interfacez�An interface into a remote object.

    An Interface can be used to wrap ProxyObjects
    so that calls can be routed to their correct
    D-Bus interface.
    cCs$t|t�r|j|_n||_||_dS)a:Construct a proxy for the given interface on the given object.

        :Parameters:
            `object` : `dbus.proxies.ProxyObject` or `dbus.Interface`
                The remote object or another of its interfaces
            `dbus_interface` : str
                An interface the `object` implements
        N)�
isinstancerr�proxy_object�_objr+)r�objectr1rrrr�s	

zInterface.__init__cCs|jjS)N)rur.)rrrrrMszInterface.<lambda>Nz.The D-Bus object path of the underlying objectcCs|jjS)N)rur-)rrrrrMsz:The bus name to which the underlying proxy object is boundcCs|jjS)N)rurp)rrrrrM	szGThe bus name which was requested when the underlying object was createdcCs|jS)N)ru)rrrrrM
szThe underlying proxy objectcCs|jS)N)r+)rrrrrMszThe D-Bus interface representedcKs|s
|j}|jj|||f|�S)aaArrange for a function to be called when the given signal is
        emitted.

        The parameters and keyword arguments are the same as for
        `dbus.proxies.ProxyObject.connect_to_signal`, except that if
        `dbus_interface` is None (the default), the D-Bus interface that
        was passed to the `Interface` constructor is used.
        )r+rurQ)rrNrPr1rrrrrQs

zInterface.connect_to_signalcCs2|jd�r|jd�rt|��n|jj||j�SdS)Nrc)rdrerfrurgr+)rrhrrrri"s
zInterface.__getattr__cCs|dkr|j}|jj||�S)a&Return a proxy method representing the given D-Bus method.

        This is the same as `dbus.proxies.ProxyObject.get_dbus_method`
        except that if `dbus_interface` is None (the default),
        the D-Bus interface that was passed to the `Interface` constructor
        is used.
        N)r+rurg)rrhr1rrrrg(szInterface.get_dbus_methodcCsd|j|jt|�fS)Nz%<Interface %r implementing %r at %#x>)rur+rm)rrrrrn4szInterface.__repr__)N)N)r!r"r#r$rror.rDr-rprtr1rQrirgrnrqrrrrrr�s&

rr)r[Z	threadingr�ImportErrorZdummy_threadingr*Zdbus._expat_introspect_parserrZdbus.exceptionsrrrrZ
__docformat__Z	getLoggerr\rr	r
rrZdbus._compatr
rr%rvr7rrrrrr�<module>s"
`BPKMW�\@�l���%__pycache__/glib.cpython-36.opt-1.pycnu�[���3

iR�V1�@sHdZdZddlmZmZddlmZeZedd�ee	d�e	dd	�d
S)a�Deprecated module which sets the default GLib main context as the mainloop
implementation within D-Bus, as a side-effect of being imported!

This API is highly non-obvious, so instead of importing this module,
new programs which don't need pre-0.80 compatibility should use this
equivalent code::

    from dbus.mainloop.glib import DBusGMainLoop
    DBusGMainLoop(set_as_default=True)
Zrestructuredtext�)�
DBusGMainLoop�threads_init)�warnT)Zset_as_defaultz�Importing dbus.glib to use the GLib main loop with dbus-python is deprecated.
Instead, use this sequence:

    from dbus.mainloop.glib import DBusGMainLoop

    DBusGMainLoop(set_as_default=True)
�)�
stacklevelN)
�__doc__Z
__docformat__Zdbus.mainloop.glibrr�warningsrZ_warnZinit_threads�DeprecationWarning�r
r
�/usr/lib64/python3.6/glib.py�<module>"s
PKMW�\���7��#__pycache__/lowlevel.cpython-36.pycnu�[���3

iR�V'�
@sHdZdZddlmZmZmZmZmZmZm	Z	m
Z
mZmZm
Z
mZmZdS)zLow-level interface to D-Bus.�PendingCall�Message�MethodCallMessage�MethodReturnMessage�ErrorMessage�
SignalMessage�HANDLER_RESULT_HANDLED�HANDLER_RESULT_NOT_YET_HANDLED�MESSAGE_TYPE_INVALID�MESSAGE_TYPE_METHOD_CALL�MESSAGE_TYPE_METHOD_RETURN�MESSAGE_TYPE_ERROR�MESSAGE_TYPE_SIGNAL�)
rrrrr	r
rr
rrrrrN)
rrrrrrrrr	r
rrr
)�__doc__�__all__Z_dbus_bindingsrrrrr	r
rr
rrrrr�rr� /usr/lib64/python3.6/lowlevel.py�<module>sPKMW�\�O��#__pycache__/__init__.cpython-36.pycnu�[���3

+d�V��.@s�dZddddddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.g.Zd/d0lmZer~ejd1�d2Zd/d3ljZd/d3lj	Z	d/d4l
mZee
eejd5���Zd/d6l
mZmZmZmZmZmZmZd/d7l
mZmZmZmZmZmZmZmZd/d8lm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&d/d9l
m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6e�r�d/d:l
m7Z7d/d;l8m9Z9m:Z:m;Z;m<Z<d/d<l=m>Z>d3S)=z�Implements the public API for a D-Bus client. See the dbus.service module
to export objects or claim well-known names.

..
  for epydoc's benefit

:NewField SupportedUsage: Supported usage
:NewField Constructor: Constructor
�Bus�	SystemBus�
SessionBus�
StarterBus�	Interface�get_default_main_loop�set_default_main_loop�validate_interface_name�validate_member_name�validate_bus_name�validate_object_path�validate_error_name�BUS_DAEMON_NAME�BUS_DAEMON_PATH�BUS_DAEMON_IFACE�
LOCAL_PATH�LOCAL_IFACE�
PEER_IFACE�INTROSPECTABLE_IFACE�PROPERTIES_IFACE�
ObjectPath�	ByteArray�	Signature�Byte�Boolean�Int16�UInt16�Int32�UInt32�Int64�UInt64�Double�String�Array�Struct�
Dictionary�
DBusException�MissingErrorHandlerException�MissingReplyHandlerException�ValidationException�IntrospectionParserException�UnknownMethodException�NameExistsExceptionZserviceZmainloopZlowlevel�)�is_py2�
UTF8StringZrestructuredtextN)�__version__�.)rrr
rrr	r)rr
rrrrrr)r%r)r&r'r+r*r()r"rrrr$r rrrrrr!r#rrr)r.)rrrr)r)?�__doc__�__all__Zdbus._compatr-�appendZ
__docformat__Zdbus.exceptions�
exceptionsZ
dbus.types�typesZ_dbus_bindingsr/�tuple�map�int�split�versionrrr
rrr	rrr
rrrrrrr%r)r&r'r+r*r(r"rrrr$r rrrrrr!r#rrrr.Z
dbus._dbusrrrrZdbus.proxiesr�r;r;� /usr/lib64/python3.6/__init__.py�<module>
sB





$($HPKMW�\@�l���__pycache__/glib.cpython-36.pycnu�[���3

iR�V1�@sHdZdZddlmZmZddlmZeZedd�ee	d�e	dd	�d
S)a�Deprecated module which sets the default GLib main context as the mainloop
implementation within D-Bus, as a side-effect of being imported!

This API is highly non-obvious, so instead of importing this module,
new programs which don't need pre-0.80 compatibility should use this
equivalent code::

    from dbus.mainloop.glib import DBusGMainLoop
    DBusGMainLoop(set_as_default=True)
Zrestructuredtext�)�
DBusGMainLoop�threads_init)�warnT)Zset_as_defaultz�Importing dbus.glib to use the GLib main loop with dbus-python is deprecated.
Instead, use this sequence:

    from dbus.mainloop.glib import DBusGMainLoop

    DBusGMainLoop(set_as_default=True)
�)�
stacklevelN)
�__doc__Z
__docformat__Zdbus.mainloop.glibrr�warningsrZ_warnZinit_threads�DeprecationWarning�r
r
�/usr/lib64/python3.6/glib.py�<module>"s
PKMW�\͑���"__pycache__/_compat.cpython-36.pycnu�[���3

iR�V��@s ddlZejddkZeZdS)�N�)�sys�version_infoZis_py3Zis_py2�rr�/usr/lib64/python3.6/_compat.py�<module>sPKMW�\�Y=��+__pycache__/exceptions.cpython-36.opt-1.pycnu�[���3

iR�VB�@s�dZdZdd	lmZGd
d�de�ZGdd�de�ZGdd�de�ZGd
d�de�ZGdd�de�Z	Gdd�de�Z
Gdd�de�ZdS)zD-Bus exceptions.�
DBusException�MissingErrorHandlerException�MissingReplyHandlerException�ValidationException�IntrospectionParserException�UnknownMethodException�NameExistsException�)�is_py3c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
rFcOsX|jdd�}|dk	s$t|dd�dkr*||_|rDtddj|j����tj|f|��dS)N�name�_dbus_error_namez1DBusException does not take keyword arguments: %sz, )�pop�getattrr�	TypeError�join�keys�	Exception�__init__)�self�args�kwargsr
�r�"/usr/lib64/python3.6/exceptions.pyr-szDBusException.__init__cCsFt|j�dkrt|j�}ndj|j�}|jdk	r>d|j|fS|SdS)zReturn a unicode error��Nz%s: %s)�lenr�unicoderr)r�srrr�__unicode__6s
zDBusException.__unicode__cCs*tj|�}|jdk	r"d|j|fS|SdS)zReturn a str errorNz%s: %s)r�__str__r)rrrrrrDs

zDBusException.__str__cCsPt|j�dkr*trt|j�}q6t|j�}ndj|j�}t|t�rL|jdd�S|S)Nrrzutf-8�replace)	rrr	�strrr�
isinstance�bytes�decode)rrrrr�get_dbus_messageLs
zDBusException.get_dbus_messagecCs|jS)N)r)rrrr�
get_dbus_nameZszDBusException.get_dbus_nameN)	�__name__�
__module__�__qualname__�include_tracebackrrrr$r%rrrrr!s
	c@seZdZdZdd�ZdS)rTcCstj|d�dS)Nz^error_handler not defined: if you define a reply_handler you must also define an error_handler)rr)rrrrrasz%MissingErrorHandlerException.__init__N)r&r'r(r)rrrrrr]sc@seZdZdZdd�ZdS)rTcCstj|d�dS)Nz^reply_handler not defined: if you define an error_handler you must also define a reply_handler)rr)rrrrrhsz%MissingReplyHandlerException.__init__N)r&r'r(r)rrrrrrdsc@seZdZdZddd�ZdS)rTrcCstj|d|�dS)NzError validating string: %s)rr)r�msgrrrroszValidationException.__init__N)r)r&r'r(r)rrrrrrksc@seZdZdZddd�ZdS)rTrcCstj|d|�dS)Nz!Error parsing introspect data: %s)rr)rr*rrrrvsz%IntrospectionParserException.__init__N)r)r&r'r(r)rrrrrrrsc@seZdZdZdZdd�ZdS)rTz(org.freedesktop.DBus.Error.UnknownMethodcCstj|d|�dS)NzUnknown method: %s)rr)r�methodrrrr~szUnknownMethodException.__init__N)r&r'r(r)rrrrrrrysc@seZdZdZdd�ZdS)rTcCstj|d|�dS)NzBus name already exists: %s)rr)rr
rrrr�szNameExistsException.__init__N)r&r'r(r)rrrrrr�sN)rrrrrrr)�__doc__�__all__Zdbus._compatr	rrrrrrrrrrrr�<module>s<PKMW�\Ww�}I-I-+__pycache__/decorators.cpython-36.opt-1.pycnu�[���3

�f�Vg;�
@sddZd
ZdZddlZddlmZmZmZddlm	Z	ddl
mZdd	lm
Z
ddd�Zddd�ZdS)zService-side D-Bus decorators.�method�signalZrestructuredtext�N)�validate_interface_name�	Signature�validate_member_name)�
SignalMessage)�
DBusException)�is_py2Fc
s.t������������	�
�fdd�}|S)a�Factory for decorators used to mark methods of a `dbus.service.Object`
    to be exported on the D-Bus.

    The decorated method will be exported over D-Bus as the method of the
    same name on the given D-Bus interface.

    :Parameters:
        `dbus_interface` : str
            Name of a D-Bus interface
        `in_signature` : str or None
            If not None, the signature of the method parameters in the usual
            D-Bus notation
        `out_signature` : str or None
            If not None, the signature of the return value in the usual
            D-Bus notation
        `async_callbacks` : tuple containing (str,str), or None
            If None (default) the decorated method is expected to return
            values matching the `out_signature` as usual, or raise
            an exception on error. If not None, the following applies:

            `async_callbacks` contains the names of two keyword arguments to
            the decorated function, which will be used to provide a success
            callback and an error callback (in that order).

            When the decorated method is called via the D-Bus, its normal
            return value will be ignored; instead, a pair of callbacks are
            passed as keyword arguments, and the decorated method is
            expected to arrange for one of them to be called.

            On success the success callback must be called, passing the
            results of this method as positional parameters in the format
            given by the `out_signature`.

            On error the decorated method may either raise an exception
            before it returns, or arrange for the error callback to be
            called with an Exception instance as parameter.

        `sender_keyword` : str or None
            If not None, contains the name of a keyword argument to the
            decorated function, conventionally ``'sender'``. When the
            method is called, the sender's unique name will be passed as
            this keyword argument.

        `path_keyword` : str or None
            If not None (the default), the decorated method will receive
            the destination object path as a keyword argument with this
            name. Normally you already know the object path, but in the
            case of "fallback paths" you'll usually want to use the object
            path in the method's implementation.

            For fallback objects, `rel_path_keyword` (new in 0.82.2) is
            likely to be more useful.

            :Since: 0.80.0?

        `rel_path_keyword` : str or None
            If not None (the default), the decorated method will receive
            the destination object path, relative to the path at which the
            object was exported, as a keyword argument with this
            name. For non-fallback objects the relative path will always be
            '/'.

            :Since: 0.82.2

        `destination_keyword` : str or None
            If not None (the default), the decorated method will receive
            the destination bus name as a keyword argument with this name.
            Included for completeness - you shouldn't need this.

            :Since: 0.80.0?

        `message_keyword` : str or None
            If not None (the default), the decorated method will receive
            the `dbus.lowlevel.MethodCallMessage` as a keyword argument
            with this name.

            :Since: 0.80.0?

        `connection_keyword` : str or None
            If not None (the default), the decorated method will receive
            the `dbus.connection.Connection` as a keyword argument
            with this name. This is generally only useful for objects
            that are available on more than one connection.

            :Since: 0.82.0

        `utf8_strings` : bool
            If False (default), D-Bus strings are passed to the decorated
            method as objects of class dbus.String, a unicode subclass.

            If True, D-Bus strings are passed to the decorated method
            as objects of class dbus.UTF8String, a str subclass guaranteed
            to be encoded in UTF-8.

            This option does not affect object-paths and signatures, which
            are always 8-bit strings (str subclass) encoded in ASCII.

            :Since: 0.80.0

        `byte_arrays` : bool
            If False (default), a byte array will be passed to the decorated
            method as an `Array` (a list subclass) of `Byte` objects.

            If True, a byte array will be passed to the decorated method as
            a `ByteArray`, a str subclass. This is usually what you want,
            but is switched off by default to keep dbus-python's API
            consistent.

            :Since: 0.80.0
    cs�ttd�rLg}xJtj|�jj�D]&}|jtjjtjjfkr |j	|j
�q Wntj|�d}|jd��r�t
��tkr|td��t��dkr�td��|j�d�|j�d��r�|j���
r�|j�
��	r�|j�	��r�|j���r�|j����r|j����rJtt���}t|�t|�k�r0td��nt|�t|�k�rJtd��d|_�|_�|_�|_�|_�|_�	|_�
|_�|_�|_�|_||_t �d	�|_!t"�r��j#d
d�|j!d
<nd
�k�r�td��|S)
Nrrz\async_callbacks must be a tuple of (keyword for return callback, keyword for error callback)��z<input signature is longer than the number of arguments takenz=input signature is shorter than the number of arguments takenT)�byte_arraysZutf8_stringsFz*unexpected keyword argument 'utf8_strings')$�hasattr�inspect�	signatureZ
parameters�valuesZkindZ	ParameterZPOSITIONAL_ONLYZPOSITIONAL_OR_KEYWORD�append�name�
getargspec�pop�type�tuple�	TypeError�len�
ValueError�removerZ_dbus_is_methodZ_dbus_async_callbacks�_dbus_interfaceZ_dbus_in_signatureZ_dbus_out_signatureZ_dbus_sender_keywordZ_dbus_path_keywordZ_dbus_rel_path_keywordZ_dbus_destination_keywordZ_dbus_message_keywordZ_dbus_connection_keyword�
_dbus_args�dictZ_dbus_get_args_optionsr	�get)�func�args�argZin_sig)�async_callbacksr�connection_keyword�dbus_interface�destination_keyword�in_signature�kwargs�message_keyword�
out_signature�path_keyword�rel_path_keyword�sender_keyword��"/usr/lib64/python3.6/decorators.py�	decorator�sh










zmethod.<locals>.decorator)r)
r$r&r)r"r,r*r%r(r#rr+r'r/r-)r"rr#r$r%r&r'r(r)r*r+r,r.r'st">csTt���dk	r>ddlm}|td�tdd��dk	r>td������fdd	�}|S)
a	Factory for decorators used to mark methods of a `dbus.service.Object`
    to emit signals on the D-Bus.

    Whenever the decorated method is called in Python, after the method
    body is executed, a signal with the same name as the decorated method,
    with the given D-Bus interface, will be emitted from this object.

    :Parameters:
        `dbus_interface` : str
            The D-Bus interface whose signal is emitted
        `signature` : str
            The signature of the signal in the usual D-Bus notation

        `path_keyword` : str or None
            A keyword argument to the decorated method. If not None,
            that argument will not be emitted as an argument of
            the signal, and when the signal is emitted, it will appear
            to come from the object path given by the keyword argument.

            Note that when calling the decorated method, you must always
            pass in the object path as a keyword argument, not as a
            positional argument.

            This keyword argument cannot be used on objects where
            the class attribute ``SUPPORTS_MULTIPLE_OBJECT_PATHS`` is true.

            :Deprecated: since 0.82.0. Use `rel_path_keyword` instead.

        `rel_path_keyword` : str or None
            A keyword argument to the decorated method. If not None,
            that argument will not be emitted as an argument of
            the signal.

            When the signal is emitted, if the named keyword argument is given,
            the signal will appear to come from the object path obtained by
            appending the keyword argument to the object's object path.
            This is useful to implement "fallback objects" (objects which
            own an entire subtree of the object-path tree).

            If the object is available at more than one object-path on the
            same or different connections, the signal will be emitted at
            an appropriate object-path on each connection - for instance,
            if the object is exported at /abc on connection 1 and at
            /def and /x/y/z on connection 2, and the keyword argument is
            /foo, then signals will be emitted from /abc/foo and /def/foo
            on connection 1, and /x/y/z/foo on connection 2.

            :Since: 0.82.0
    Nr)�warnz�dbus.service.signal::path_keyword has been deprecated since dbus-python 0.82.0, and will not work on objects that support multiple object pathsr
)�
stacklevelzJdbus.service.signal::path_keyword and rel_path_keyword cannot both be usedcs��j�t��������fdd�}tj��d}|jd�xH��fD]<}|dk	rFy|j|�WqFtk
r�td|��YqFXqFW�r�tt���}t	|�t	|�kr�td��nt	|�t	|�kr�td���j|_�j
|_
d|_�|_�|_
||_|S)Ncs�d}�dk	rP|jrtd��|j�d�}||jkrP|jj|d�rPtd||j��d}�dk	rh|j�d�}�|f|�|�xl|jD]b}|dkr�|dks�|dkr�|d}q�|d|}n|}t|���}|j|d�i�|dj	|�q�WdS)	Nz[path_keyword cannot be used on the signals of an object that supports multiple object paths�/zPath %r is not below %r�rrr)r2r3)
ZSUPPORTS_MULTIPLE_OBJECT_PATHSrrZ__dbus_object_path__�
startswithrZ	locationsrrZsend_message)�selfr �keywordsZabs_pathZrel_path�locationZobject_path�message)r$r�member_namer*r+rr-r.�emit_signal"s0

z.signal.<locals>.decorator.<locals>.emit_signalrzfunction has no argument "%s"z@signal signature is longer than the number of arguments providedzAsignal signature is shorter than the number of arguments providedT)�__name__rrrrrrrrr�__doc__Z_dbus_is_signalrZ_dbus_signaturer)rr:r �keywordZsig)r$r*r+r)rr9r.r/s0&

zsignal.<locals>.decorator)r�warningsr0�DeprecationWarningr)r$rr*r+r0r/r-)r$r*r+rr.r�s3
D)rr)
NNNNNNNNFN)NNN)r<�__all__Z
__docformat__rZdbusrrrZ
dbus.lowlevelrZdbus.exceptionsrZdbus._compatr	rrr-r-r-r.�<module>s 
3PKMW�\��w��F�F+__pycache__/connection.cpython-36.opt-1.pycnu�[���3

iR�V}l�@s�dZdZddlZddlZddlZddlmZmZm	Z	m
Z
mZmZm
Z
ddlmZddlmZmZmZmZmZddlmZdd	lmZmZer�dd
lmZnddlmZejd�Zd
d�ZGdd�de �Z!Gdd�de�ZdS)�
Connection�SignalMatchZreStructuredText�N)r�LOCAL_IFACE�
LOCAL_PATH�validate_bus_name�validate_interface_name�validate_member_name�validate_object_path)�
DBusException)�ErrorMessage�HANDLER_RESULT_NOT_YET_HANDLED�MethodCallMessage�MethodReturnMessage�
SignalMessage)�ProxyObject)�is_py2�is_py3)�String)�
UTF8Stringzdbus.connectioncOsdS)N�)�args�kwargsrr�"/usr/lib64/python3.6/connection.py�_noop1src@s�eZdZddddddddd	d
ddd
ddddgZer<ejd�ee�Zd+dd�Zdd�Z	dd�Z
dd�Zedd��Z
dd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�ZdS),r�_sender_name_owner�_member�
_interface�_sender�_path�_handler�_args_match�_rule�_byte_arrays�
_conn_weakref�_destination_keyword�_interface_keyword�_message_keyword�_member_keyword�_sender_keyword�
_path_keyword�_int_args_match�
_utf8_stringsFNcKsl|dk	rt|�|dk	r t|�|dk	r0t|�|dk	r@t|�d|_tj|�|_||_||_	||_
||_||_||_
tr�|jdd�|_nd|kr�td��||_||_|	|_||_|
|_||_|
|_||_|s�d|_n�i|_x�|D]�}|jd��s�td|��yt|dd��}Wn"tk
�r4td|��YnX|dk�sJ|dk�rVtd	|��|||j|<q�WdS)
N�utf8_stringsFz*unexpected keyword argument 'utf8_strings'�argz(SignalMatch: unknown keyword argument %s�r�?z9SignalMatch: arg match index must be in range(64), not %d)rrrr	r!�weakref�refr#rrrrrrr�popr+�	TypeErrorr"r(r)r'r%r&r$r r*�
startswith�int�
ValueError)�self�conn�sender�object_path�dbus_interface�member�handler�byte_arraysZsender_keywordZpath_keywordZinterface_keywordZmember_keywordZmessage_keywordZdestination_keywordrZkwarg�indexrrr�__init__AsX
zSignalMatch.__init__cCstt|��S)z-SignalMatch objects are compared by identity.)�hash�id)r7rrr�__hash__|szSignalMatch.__hash__cCs||kS)z-SignalMatch objects are compared by identity.r)r7�otherrrr�__eq__�szSignalMatch.__eq__cCs||k	S)z-SignalMatch objects are compared by identity.r)r7rDrrr�__ne__�szSignalMatch.__ne__cCs|jS)N)r)r7rrr�<lambda>�szSignalMatch.<lambda>cCs�|jdkr�dg}|jdk	r*|jd|j�|jdk	rD|jd|j�|jdk	r^|jd|j�|jdk	rx|jd|j�|jdk	r�x(|jj�D]\}}|jd||f�q�Wdj|�|_|jS)Nz
type='signal'zsender='%s'z	path='%s'zinterface='%s'zmember='%s'z
arg%d='%s'�,)	r!r�appendrrrr*�items�join)r7Zruler?�valuerrr�__str__�s





zSignalMatch.__str__cCsd|jt|�|j|j�fS)Nz<%s at %x "%s" on conn %r>)�	__class__rBr!r#)r7rrr�__repr__�szSignalMatch.__repr__cCs
||_dS)N)r)r7�new_namerrr�set_sender_name_owner�sz!SignalMatch.set_sender_name_ownercKs\|d|jfkrdS||jkr dS||jkr.dS||jkr<dS||jkrJdS||jkrXdSdS)NFT)rrrrrr )r7r9r:r;r<r=rrrr�matches_removal_spec�s




z SignalMatch.matches_removal_specc
Cs�d}|jd|j�fkrdS|jdk	r�tdd�}tr6tnt}trFd|d<|jf|�}xB|jj	�D]4\}}|t
|�ks�t|||�s�|||kr^dSq^W|jd|j
�fkr�dS|jd|j�fkr�dS|jd|j�fkr�dSy�to�|j}|dks�|s�|j�r$t|jd�}t�r|j|d<|jf|�}i}|jdk	�rB|j�||j<|jdk	�r\|j�||j<|jdk	�rv|j�||j<|jdk	�r�|j
�||j<|jdk	�r�|j�||j<|jdk	�r�|||j<|j||�Wn"tj�tjddd�YnXdS)NFT)r>r,z&Exception in handler for D-Bus signal:�)�exc_info) rZ
get_senderr*�dictrrrr�
get_args_listrJ�len�
isinstancer�
get_memberr�
get_interfacer�get_pathr+r"r(r$Zget_destinationr)r'r%r&r�logging�basicConfig�_logger�error)r7�messagerrZarg_typer?rLr,rrr�maybe_handle_message�sZ




z SignalMatch.maybe_handle_messagecCs4|j�}|dk	r0|j||j|j|j|jf|j�dS)N)r#�remove_signal_receiverrrrrr )r7r8rrr�remove�s
zSignalMatch.remove)FNNNNNN)�__name__�
__module__�__qualname__Z_slotsrrI�tuple�	__slots__r@rCrErF�propertyr9rMrOrQrRrarcrrrrr5s.


7:cs~eZdZdZeZ�fdd�Zdd�Zddd	�Zdd
d�Z	dd
�Z
ddd�Zdd�Zdd�Z
d dd�Zd"dd�Zdd�Z�ZS)#rzzA connection to another application. In this base class there is
    assumed to be no bus daemon.

    :Since: 0.81.0
    csJtt|�j||�t|d�sFd|_g|_i|_tj�|_	|j
|jj�dS)N�_dbus_Connection_initializedrS)
�superrr@�hasattrrj�"_Connection__call_on_disconnection�!_signal_recipients_by_object_path�	threadingZLock�
_signals_lockZadd_message_filterrN�_signal_func)r7rr)rNrrr@s

zConnection.__init__cCs|S)aReturn the unique name for the given bus name, activating it
        if necessary and possible.

        If the name is already unique or this connection is not to a
        bus daemon, just return it.

        :Returns: a bus name. If the given `bus_name` exists, the returned
            name identifies its current owner; otherwise the returned name
            does not exist.
        :Raises DBusException: if the implementation has failed
            to activate the given bus name.
        :Since: 0.81.0
        r)r7�bus_namerrr�activate_name_ownerszConnection.activate_name_ownerNTcKsn|jdd�}|dk	rB|dk	r$td��ddlm}|dtdd�|}|r\td	d
j|j����|j||||d�S)a�Return a local proxy for the given remote object.

        Method calls on the proxy are translated into method calls on the
        remote object.

        :Parameters:
            `bus_name` : str
                A bus name (either the unique name or a well-known name)
                of the application owning the object. The keyword argument
                named_service is a deprecated alias for this.
            `object_path` : str
                The object path of the desired object
            `introspect` : bool
                If true (default), attempt to introspect the remote
                object to find out supported methods and their signatures

        :Returns: a `dbus.proxies.ProxyObject`
        �
named_serviceNz3bus_name and named_service cannot both be specifiedr)�warnziPassing the named_service parameter to get_object by name is deprecated: please use positional parameters�)�
stacklevelz4get_object does not take these keyword arguments: %sz, )�
introspect)r2r3�warningsru�DeprecationWarningrK�keys�ProxyObjectClass)r7rrr:rxrrtrurrr�
get_object$s

zConnection.get_objectc

Ks�|j�|jdd�}|dk	rJ|dk	r,td��|}ddlm}|dtdd�t||||||f|�}	|jj�z4|j	j
|i�}
|
j
|i�}|j
|g�}|j|	�Wd|jj�X|	S)	aArrange for the given function to be called when a signal matching
        the parameters is received.

        :Parameters:
            `handler_function` : callable
                The function to be called. Its positional arguments will
                be the arguments of the signal. By default it will receive
                no keyword arguments, but see the description of
                the optional keyword arguments below.
            `signal_name` : str
                The signal name; None (the default) matches all names
            `dbus_interface` : str
                The D-Bus interface name with which to qualify the signal;
                None (the default) matches all interface names
            `bus_name` : str
                A bus name for the sender, which will be resolved to a
                unique name if it is not already; None (the default) matches
                any sender.
            `path` : str
                The object path of the object which must have emitted the
                signal; None (the default) matches any object path
        :Keywords:
            `utf8_strings` : bool
                If True, the handler function will receive any string
                arguments as dbus.UTF8String objects (a subclass of str
                guaranteed to be UTF-8). If False (default) it will receive
                any string arguments as dbus.String objects (a subclass of
                unicode).
            `byte_arrays` : bool
                If True, the handler function will receive any byte-array
                arguments as dbus.ByteArray objects (a subclass of str).
                If False (default) it will receive any byte-array
                arguments as a dbus.Array of dbus.Byte (subclasses of:
                a list of ints).
            `sender_keyword` : str
                If not None (the default), the handler function will receive
                the unique name of the sending endpoint as a keyword
                argument with this name.
            `destination_keyword` : str
                If not None (the default), the handler function will receive
                the bus name of the destination (or None if the signal is a
                broadcast, as is usual) as a keyword argument with this name.
            `interface_keyword` : str
                If not None (the default), the handler function will receive
                the signal interface as a keyword argument with this name.
            `member_keyword` : str
                If not None (the default), the handler function will receive
                the signal name as a keyword argument with this name.
            `path_keyword` : str
                If not None (the default), the handler function will receive
                the object-path of the sending object as a keyword argument
                with this name.
            `message_keyword` : str
                If not None (the default), the handler function will receive
                the `dbus.lowlevel.SignalMessage` as a keyword argument with
                this name.
            `arg...` : unicode or UTF-8 str
                If there are additional keyword parameters of the form
                ``arg``\ *n*, match only signals where the *n*\ th argument
                is the value given for that keyword parameter. As of this
                time only string arguments can be matched (in particular,
                object paths and signatures can't).
            `named_service` : str
                A deprecated alias for `bus_name`.
        rtNz3bus_name and named_service cannot both be specifiedr)ruzrPassing the named_service parameter to add_signal_receiver by name is deprecated: please use positional parametersrv)rw)
Z_require_main_loopr2r3ryrurzrrp�acquirern�
setdefaultrI�release)
r7Zhandler_function�signal_namer;rr�path�keywordsrtru�match�by_interface�	by_member�matchesrrr�add_signal_receiverIs(G


zConnection.add_signal_receiverccs�|dk	rd|f}nd}|dk	r(d|f}nd}|dk	r>d|f}nd}x~|D]v}|jj|�}|dkrbqHxZ|D]R}|j|d�}|dkr�qhx6|D].}|j|d�}	|	dkr�q�x|	D]
}
|
Vq�Wq�WqhWqHWdS)N)N)N)N)rn�get)r7r�r;r<Z	path_keysZinterface_keysZmember_keysr�r�r��mrrr�_iter_easy_matches�s.






zConnection._iter_easy_matchesc
Ks>|jdd�}|dk	rB|dk	r$td��|}ddlm}|dtdd�g}	g}
|jj�z�|jj|d�}|dkrpdS|j|d�}|dkr�dS|j|d�}
|
dkr�dSx@|
D]8}||ks�|j	|||||f|�r�|
j
|�q�|	j
|�q�W|	r�|	||<n ||=|�s||=|�s|j|=Wd|jj�Xx|
D]}|j|��q&WdS)Nrtz3bus_name and named_service cannot both be specifiedr)ruzuPassing the named_service parameter to remove_signal_receiver by name is deprecated: please use positional parametersrv)rw)
r2r3ryrurzrpr~rnr�rRrIr��_clean_up_signal_match)r7Zhandler_or_matchr�r;rrr�r�rtru�newZ	deletionsr�r�r�r�rrrrb�sT




z!Connection.remove_signal_receivercCsdS)Nr)r7r�rrrr�sz!Connection._clean_up_signal_matchcCs�t|t�stS|j�}|j�}|j�}x |j|||�D]}|j|�q6W|tkr�|t	kr�|dkr�xF|j
D]<}y||�Wqhtk
r�tj
�tjddd�YqhXqhWtS)zvD-Bus filter function. Handle signals by dispatching to Python
        callbacks kept in the match-rule tree.
        ZDisconnectedz-Exception in handler for Disconnected signal:rS)rT)rXrrrZr[rYr�rarrrm�	Exceptionr\r]r^r_)r7r`r;r�r�r��cbrrrrq	s&


zConnection._signal_funcg�?Fcs|tkrtdt��|tkr(tdt��t|
d��trH|jdd��d<nd|krXtd��t||||d�}
y|
j|d|i�Wn@t	k
r�}z$t
j�tj
d	|||j|��WYd
d
}~XnX�d
kr܈d
kr�|j|
�d
S�d
kr�t��d
kr�t����fdd�}|j|
||	|d
�S)aSCall the given method, asynchronously.

        If the reply_handler is None, successful replies will be ignored.
        If the error_handler is None, failures will be ignored. If both
        are None, the implementation may request that no reply is sent.

        :Returns: The dbus.lowlevel.PendingCall.
        :Since: 0.81.0
        z1Methods may not be called on the reserved path %sz6Methods may not be called on the reserved interface %s)r>r,Fz*unexpected keyword argument 'utf8_strings')�destinationr��	interface�method�	signaturez<Unable to set arguments %r according to signature %r: %s: %sNcsVt|t�r�|jf���n6t|t�rB�t|j�d|j�i��n�td|��dS)N�namez%Unexpected type for reply message: %r)rXrrVrr
Zget_error_namer3)r`)�
error_handler�
get_args_opts�
reply_handlerrr�msg_reply_handlerZs

z0Connection.call_async.<locals>.msg_reply_handler)�require_main_loop)rr
rrUrr�r3r
rIr�r\r]r^r_rNZsend_messagerZsend_message_with_reply)r7rrr:r;r�r�rr�r��timeoutr>r�rr`�er�r)r�r�r�r�
call_async'sB


	zConnection.call_asyncc	Ks|tkrtdt��|tkr(tdt��t|d�}
trH|	jdd�|
d<nd|	krXtd��t||||d�}y|j|d|i�Wn@t	k
r�}z$t
j�tj
d	|||j|��WYd
d
}~XnX|j||�}
|
jf|
�}t|�dkr�d
St|�dkr�|dSt|�Sd
S)
zECall the given method, synchronously.
        :Since: 0.81.0
        z1Methods may not be called on the reserved path %sz6Methods may not be called on the reserved interface %s)r>r,Fz*unexpected keyword argument 'utf8_strings')r�r�r�r�r�z<Unable to set arguments %r according to signature %r: %s: %sNrrS)rr
rrUrr�r3r
rIr�r\r]r^r_rNZ!send_message_with_reply_and_blockrVrWrg)r7rrr:r;r�r�rr�r>rr�r`r�Z
reply_messageZ	args_listrrr�
call_blockinggs<
zConnection.call_blockingcCs|jj|�dS)z�Arrange for `callable` to be called with one argument (this
        Connection object) when the Connection becomes
        disconnected.

        :Since: 0.83.0
        N)rmrI)r7�callablerrr�call_on_disconnection�sz Connection.call_on_disconnection)NNT)NNNN)NNNN��)r�FT��)r�F)rdrerf�__doc__rr|r@rsr}r�r�rbr�rqr�r�r��
__classcell__rr)rNrr�s*
&
`
7 
>
+)rr)"�__all__Z
__docformat__r\ror0Z_dbus_bindingsrZ_Connectionrrrrrr	Zdbus.exceptionsr
Z
dbus.lowlevelrrr
rrZdbus.proxiesrZdbus._compatrrrrZ	getLoggerr^r�objectrrrrr�<module>s"$
DPKMW�\h�,(;7;7$__pycache__/bus.cpython-36.opt-1.pycnu�[���3

iR�VF�@s�dZdZddlZddlZddlmZmZmZmZm	Z	m
Z
mZmZm
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZddlmZddlmZddl m!Z!ddl"m#Z#d	eeefZ$d
Z%ej&d�Z'Gdd
�d
e(�Z)Gdd�de�Z*dS)�
BusConnectionZreStructuredText�N)�BUS_DAEMON_IFACE�BUS_DAEMON_NAME�BUS_DAEMON_PATH�BUS_SESSION�BUS_STARTER�
BUS_SYSTEM� DBUS_START_REPLY_ALREADY_RUNNING�DBUS_START_REPLY_SUCCESS�NAME_FLAG_ALLOW_REPLACEMENT�NAME_FLAG_DO_NOT_QUEUE�NAME_FLAG_REPLACE_EXISTING�RELEASE_NAME_REPLY_NON_EXISTENT�RELEASE_NAME_REPLY_NOT_OWNER�RELEASE_NAME_REPLY_RELEASED� REQUEST_NAME_REPLY_ALREADY_OWNER�REQUEST_NAME_REPLY_EXISTS�REQUEST_NAME_REPLY_IN_QUEUE� REQUEST_NAME_REPLY_PRIMARY_OWNER�validate_bus_name�validate_error_name�validate_interface_name�validate_member_name�validate_object_path)�
Connection)�
DBusException)�HANDLER_RESULT_NOT_YET_HANDLED)�is_py2zWtype='signal',sender='%s',interface='%s',member='NameOwnerChanged',path='%s',arg0='%%s'z)org.freedesktop.DBus.Error.NameHasNoOwnerzdbus.busc@s eZdZdZdd�Zdd�ZdS)	�NameOwnerWatch�_match�
_pending_callc	snt���fdd�}��fdd�}|j|dttt�d�|_i}trJd|d<|jtttd	d
�f�|f|�|_dS)Ncs�|�dS)N�)ZownedZ	old_owner�	new_owner)�callbackr!�/usr/lib64/python3.6/bus.py�	signal_cb@sz*NameOwnerWatch.__init__.<locals>.signal_cbcs:|j�tkr�d�n tj�tjd�|j|dfd�dS)N�zGetNameOwner(%s) failed:)�exc_info)�
get_dbus_name�_NAME_HAS_NO_OWNER�loggingZbasicConfig�_logger�debug�	__class__)�e)�bus_namer#r!r$�error_cbCs

z)NameOwnerWatch.__init__.<locals>.error_cbZNameOwnerChanged)Zarg0T�utf8_strings�GetNameOwner�s)	r�add_signal_receiverrrrrr�
call_asyncr )�selfZbus_connr/r#r%r0�keywordsr!)r/r#r$�__init__=s&
zNameOwnerWatch.__init__cCs8|jdk	r|jj�|jdk	r(|jj�d|_d|_dS)N)r�remover �cancel)r6r!r!r$r:\s



zNameOwnerWatch.cancelN)rr )�__name__�
__module__�__qualname__�	__slots__r8r:r!r!r!r$r:srcs�eZdZdZeZeZeZ	e
ZeZ
edfdd�Zd*�fdd�	Zdd�Zd	d
�Zd+d
d�Zdd�Zd,dd�Zd-dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Z�Z S).rzxA connection to a D-Bus daemon that implements the
    ``org.freedesktop.DBus`` pseudo-service.

    :Since: 0.81.0
    NcCs"|j||d�}tj�|_i|_|S)N)�mainloop)Z_new_for_bus�weakref�WeakValueDictionaryZ
_bus_names�_signal_sender_matches)�clsZaddress_or_typer?Zbusr!r!r$�__new__ys
zBusConnection.__new__cs�|jdd�}|dk	rB|dk	r$td��|}ddlm}|dtdd�tt|�j|||||f|��|dk	r�|tkr�|dd�d	kr��fd
d�}	n�j	}	|j
||	�}
|
|j�<|jt
����S)N�
named_servicez3bus_name and named_service cannot both be specifiedr)�warnzrPassing the named_service parameter to add_signal_receiver by name is deprecated: please use positional parameters�)�
stacklevel��:cs|dkr�j�dS)Nr&)r9)r")�matchr!r$r#�sz3BusConnection.add_signal_receiver.<locals>.callback)�pop�	TypeError�warningsrF�DeprecationWarning�superrr4rZset_sender_name_owner�watch_name_ownerrB�add_match_string�str)r6Zhandler_functionZsignal_nameZdbus_interfacer/�pathr7rErFr#�watch)r-)rKr$r4�s&



z!BusConnection.add_signal_receivercCs0|jt|��|jj|d�}|dk	r,|j�dS)N)� remove_match_string_non_blockingrSrBrLr:)r6rKrUr!r!r$�_clean_up_signal_match�sz$BusConnection._clean_up_signal_matchcCst|dk	rl|dd�dkrl|tkrly
|j|�Stk
rh}z"|j�tkrJ�|j|�|j|�Sd}~XqpXn|SdS)NrIrJ)r�get_name_ownerrr(r)�start_service_by_name)r6r/r.r!r!r$�activate_name_owner�s

z!BusConnection.activate_name_ownerTFcKs||r|j�|jdd�}|dk	rN|dk	r0td��ddlm}|dtdd�|}|rhtd	d
j|j����|j|||||d�S)aJReturn a local proxy for the given remote object.

        Method calls on the proxy are translated into method calls on the
        remote object.

        :Parameters:
            `bus_name` : str
                A bus name (either the unique name or a well-known name)
                of the application owning the object. The keyword argument
                named_service is a deprecated alias for this.
            `object_path` : str
                The object path of the desired object
            `introspect` : bool
                If true (default), attempt to introspect the remote
                object to find out supported methods and their signatures
            `follow_name_owner_changes` : bool
                If the object path is a well-known name and this parameter
                is false (default), resolve the well-known name to the unique
                name of its current owner and bind to that instead; if the
                ownership of the well-known name changes in future,
                keep communicating with the original owner.
                This is necessary if the D-Bus API used is stateful.

                If the object path is a well-known name and this parameter
                is true, whenever the well-known name changes ownership in
                future, bind to the new owner, if any.

                If the given object path is a unique name, this parameter
                has no effect.

        :Returns: a `dbus.proxies.ProxyObject`
        :Raises `DBusException`: if resolving the well-known name to a
            unique name fails
        rENz3bus_name and named_service cannot both be specifiedr)rFziPassing the named_service parameter to get_object by name is deprecated: please use positional parametersrG)rHz4get_object does not take these keyword arguments: %sz, )�
introspect�follow_name_owner_changes)	Z_require_main_looprLrMrNrFrO�join�keysZProxyObjectClass)r6r/Zobject_pathr[r\�kwargsrErFr!r!r$�
get_object�s $

zBusConnection.get_objectcCst|�|jtttdd|f�S)z�Get the numeric uid of the process owning the given bus name.

        :Parameters:
            `bus_name` : str
                A bus name, either unique or well-known
        :Returns: a `dbus.UInt32`
        :Since: 0.80.0
        ZGetConnectionUnixUserr3)r�
call_blockingrrr)r6r/r!r!r$�
get_unix_user�s	zBusConnection.get_unix_userrc	Cs$t|�d|jtttdd||f�fS)a?Start a service which will implement the given bus name on this Bus.

        :Parameters:
            `bus_name` : str
                The well-known bus name to be activated.
            `flags` : dbus.UInt32
                Flags to pass to StartServiceByName (currently none are
                defined)

        :Returns: A tuple of 2 elements. The first is always True, the
            second is either START_REPLY_SUCCESS or
            START_REPLY_ALREADY_RUNNING.

        :Raises `DBusException`: if the service could not be started.
        :Since: 0.80.0
        TZStartServiceByName�su)rrarrr)r6r/�flagsr!r!r$rYs

z#BusConnection.start_service_by_namecCs$t|dd�|jtttdd||f�S)a�Request a bus name.

        :Parameters:
            `name` : str
                The well-known name to be requested
            `flags` : dbus.UInt32
                A bitwise-OR of 0 or more of the flags
                `NAME_FLAG_ALLOW_REPLACEMENT`,
                `NAME_FLAG_REPLACE_EXISTING`
                and `NAME_FLAG_DO_NOT_QUEUE`
        :Returns: `REQUEST_NAME_REPLY_PRIMARY_OWNER`,
            `REQUEST_NAME_REPLY_IN_QUEUE`,
            `REQUEST_NAME_REPLY_EXISTS` or
            `REQUEST_NAME_REPLY_ALREADY_OWNER`
        :Raises `DBusException`: if the bus daemon cannot be contacted or
            returns an error.
        F)�allow_uniqueZRequestNamerc)rrarrr)r6�namerdr!r!r$�request_nameszBusConnection.request_namecCs"t|dd�|jtttdd|f�S)asRelease a bus name.

        :Parameters:
            `name` : str
                The well-known name to be released
        :Returns: `RELEASE_NAME_REPLY_RELEASED`,
            `RELEASE_NAME_REPLY_NON_EXISTENT`
            or `RELEASE_NAME_REPLY_NOT_OWNER`
        :Raises `DBusException`: if the bus daemon cannot be contacted or
            returns an error.
        F)reZReleaseNamer3)rrarrr)r6rfr!r!r$�release_name1szBusConnection.release_namecCs(i}trd|d<|jtttddff|�S)z�Return a list of all currently-owned names on the bus.

        :Returns: a dbus.Array of dbus.UTF8String
        :Since: 0.81.0
        Tr1Z	ListNamesr&)rrarrr)r6r7r!r!r$�
list_namesBszBusConnection.list_namescCs(i}trd|d<|jtttddff|�S)z�Return a list of all names that can be activated on the bus.

        :Returns: a dbus.Array of dbus.UTF8String
        :Since: 0.81.0
        Tr1ZListActivatableNamesr&)rrarrr)r6r7r!r!r$�list_activatable_namesOsz$BusConnection.list_activatable_namescCs6i}trd|d<t|dd�|jtttdd|ff|�S)z�Return the unique connection name of the primary owner of the
        given name.

        :Raises `DBusException`: if the `bus_name` has no owner
        :Since: 0.81.0
        Tr1F)rer2r3)rrrarrr)r6r/r7r!r!r$rX\szBusConnection.get_name_ownercCst|||�S)aWatch the unique connection name of the primary owner of the
        given name.

        `callback` will be called with one argument, which is either the
        unique connection name, or the empty string (meaning the name is
        not owned).

        :Since: 0.81.0
        )r)r6r/r#r!r!r$rQks
zBusConnection.watch_name_ownercCst|jtttdd|f��S)z�Return True iff the given bus name has an owner on this bus.

        :Parameters:
            `bus_name` : str
                The bus name to look up
        :Returns: a `bool`
        ZNameHasOwnerr3)�boolrarrr)r6r/r!r!r$�name_has_ownerws
zBusConnection.name_has_ownercCs|jtttdd|f�dS)aArrange for this application to receive messages on the bus that
        match the given rule. This version will block.

        :Parameters:
            `rule` : str
                The match rule
        :Raises `DBusException`: on error.
        :Since: 0.80.0
        �AddMatchr3N)rarrr)r6�ruler!r!r$rR�s
zBusConnection.add_match_stringc	Cs|jtttdd|fdd�dS)a=Arrange for this application to receive messages on the bus that
        match the given rule. This version will not block, but any errors
        will be ignored.


        :Parameters:
            `rule` : str
                The match rule
        :Raises `DBusException`: on error.
        :Since: 0.80.0
        rmr3N)r5rrr)r6rnr!r!r$�add_match_string_non_blocking�s
z+BusConnection.add_match_string_non_blockingcCs|jtttdd|f�dS)aArrange for this application to receive messages on the bus that
        match the given rule. This version will block.

        :Parameters:
            `rule` : str
                The match rule
        :Raises `DBusException`: on error.
        :Since: 0.80.0
        �RemoveMatchr3N)rarrr)r6rnr!r!r$�remove_match_string�s
z!BusConnection.remove_match_stringc	Cs|jtttdd|fdd�dS)a=Arrange for this application to receive messages on the bus that
        match the given rule. This version will not block, but any errors
        will be ignored.


        :Parameters:
            `rule` : str
                The match rule
        :Raises `DBusException`: on error.
        :Since: 0.80.0
        rpr3N)r5rrr)r6rnr!r!r$rV�s
z.BusConnection.remove_match_string_non_blocking)NNNN)TF)r)r)!r;r<r=�__doc__rZTYPE_SESSIONrZTYPE_SYSTEMrZTYPE_STARTERr
ZSTART_REPLY_SUCCESSr	ZSTART_REPLY_ALREADY_RUNNINGrDr4rWrZr`rbrYrgrhrirjrXrQrlrRrorqrV�
__classcell__r!r!)r-r$res6
8




)r)+�__all__Z
__docformat__r*r@Z_dbus_bindingsrrrrrrr	r
rrr
rrrrrrrrrrrrZdbus.connectionrZdbus.exceptionsrZ
dbus.lowlevelrZdbus._compatrZ_NAME_OWNER_CHANGE_MATCHr)Z	getLoggerr+�objectrrr!r!r!r$�<module>sd

+PKMW�\�O��)__pycache__/__init__.cpython-36.opt-1.pycnu�[���3

+d�V��.@s�dZddddddddd	d
ddd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.g.Zd/d0lmZer~ejd1�d2Zd/d3ljZd/d3lj	Z	d/d4l
mZee
eejd5���Zd/d6l
mZmZmZmZmZmZmZd/d7l
mZmZmZmZmZmZmZmZd/d8lm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&d/d9l
m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6e�r�d/d:l
m7Z7d/d;l8m9Z9m:Z:m;Z;m<Z<d/d<l=m>Z>d3S)=z�Implements the public API for a D-Bus client. See the dbus.service module
to export objects or claim well-known names.

..
  for epydoc's benefit

:NewField SupportedUsage: Supported usage
:NewField Constructor: Constructor
�Bus�	SystemBus�
SessionBus�
StarterBus�	Interface�get_default_main_loop�set_default_main_loop�validate_interface_name�validate_member_name�validate_bus_name�validate_object_path�validate_error_name�BUS_DAEMON_NAME�BUS_DAEMON_PATH�BUS_DAEMON_IFACE�
LOCAL_PATH�LOCAL_IFACE�
PEER_IFACE�INTROSPECTABLE_IFACE�PROPERTIES_IFACE�
ObjectPath�	ByteArray�	Signature�Byte�Boolean�Int16�UInt16�Int32�UInt32�Int64�UInt64�Double�String�Array�Struct�
Dictionary�
DBusException�MissingErrorHandlerException�MissingReplyHandlerException�ValidationException�IntrospectionParserException�UnknownMethodException�NameExistsExceptionZserviceZmainloopZlowlevel�)�is_py2�
UTF8StringZrestructuredtextN)�__version__�.)rrr
rrr	r)rr
rrrrrr)r%r)r&r'r+r*r()r"rrrr$r rrrrrr!r#rrr)r.)rrrr)r)?�__doc__�__all__Zdbus._compatr-�appendZ
__docformat__Zdbus.exceptions�
exceptionsZ
dbus.types�typesZ_dbus_bindingsr/�tuple�map�int�split�versionrrr
rrr	rrr
rrrrrrr%r)r&r'r+r*r(r"rrrr$r rrrrrr!r#rrrr.Z
dbus._dbusrrrrZdbus.proxiesr�r;r;� /usr/lib64/python3.6/__init__.py�<module>
sB





$($HPKMW�\h�,(;7;7__pycache__/bus.cpython-36.pycnu�[���3

iR�VF�@s�dZdZddlZddlZddlmZmZmZmZm	Z	m
Z
mZmZm
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZddlmZddlmZddl m!Z!ddl"m#Z#d	eeefZ$d
Z%ej&d�Z'Gdd
�d
e(�Z)Gdd�de�Z*dS)�
BusConnectionZreStructuredText�N)�BUS_DAEMON_IFACE�BUS_DAEMON_NAME�BUS_DAEMON_PATH�BUS_SESSION�BUS_STARTER�
BUS_SYSTEM� DBUS_START_REPLY_ALREADY_RUNNING�DBUS_START_REPLY_SUCCESS�NAME_FLAG_ALLOW_REPLACEMENT�NAME_FLAG_DO_NOT_QUEUE�NAME_FLAG_REPLACE_EXISTING�RELEASE_NAME_REPLY_NON_EXISTENT�RELEASE_NAME_REPLY_NOT_OWNER�RELEASE_NAME_REPLY_RELEASED� REQUEST_NAME_REPLY_ALREADY_OWNER�REQUEST_NAME_REPLY_EXISTS�REQUEST_NAME_REPLY_IN_QUEUE� REQUEST_NAME_REPLY_PRIMARY_OWNER�validate_bus_name�validate_error_name�validate_interface_name�validate_member_name�validate_object_path)�
Connection)�
DBusException)�HANDLER_RESULT_NOT_YET_HANDLED)�is_py2zWtype='signal',sender='%s',interface='%s',member='NameOwnerChanged',path='%s',arg0='%%s'z)org.freedesktop.DBus.Error.NameHasNoOwnerzdbus.busc@s eZdZdZdd�Zdd�ZdS)	�NameOwnerWatch�_match�
_pending_callc	snt���fdd�}��fdd�}|j|dttt�d�|_i}trJd|d<|jtttd	d
�f�|f|�|_dS)Ncs�|�dS)N�)ZownedZ	old_owner�	new_owner)�callbackr!�/usr/lib64/python3.6/bus.py�	signal_cb@sz*NameOwnerWatch.__init__.<locals>.signal_cbcs:|j�tkr�d�n tj�tjd�|j|dfd�dS)N�zGetNameOwner(%s) failed:)�exc_info)�
get_dbus_name�_NAME_HAS_NO_OWNER�loggingZbasicConfig�_logger�debug�	__class__)�e)�bus_namer#r!r$�error_cbCs

z)NameOwnerWatch.__init__.<locals>.error_cbZNameOwnerChanged)Zarg0T�utf8_strings�GetNameOwner�s)	r�add_signal_receiverrrrrr�
call_asyncr )�selfZbus_connr/r#r%r0�keywordsr!)r/r#r$�__init__=s&
zNameOwnerWatch.__init__cCs8|jdk	r|jj�|jdk	r(|jj�d|_d|_dS)N)r�remover �cancel)r6r!r!r$r:\s



zNameOwnerWatch.cancelN)rr )�__name__�
__module__�__qualname__�	__slots__r8r:r!r!r!r$r:srcs�eZdZdZeZeZeZ	e
ZeZ
edfdd�Zd*�fdd�	Zdd�Zd	d
�Zd+d
d�Zdd�Zd,dd�Zd-dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Z�Z S).rzxA connection to a D-Bus daemon that implements the
    ``org.freedesktop.DBus`` pseudo-service.

    :Since: 0.81.0
    NcCs"|j||d�}tj�|_i|_|S)N)�mainloop)Z_new_for_bus�weakref�WeakValueDictionaryZ
_bus_names�_signal_sender_matches)�clsZaddress_or_typer?Zbusr!r!r$�__new__ys
zBusConnection.__new__cs�|jdd�}|dk	rB|dk	r$td��|}ddlm}|dtdd�tt|�j|||||f|��|dk	r�|tkr�|dd�d	kr��fd
d�}	n�j	}	|j
||	�}
|
|j�<|jt
����S)N�
named_servicez3bus_name and named_service cannot both be specifiedr)�warnzrPassing the named_service parameter to add_signal_receiver by name is deprecated: please use positional parameters�)�
stacklevel��:cs|dkr�j�dS)Nr&)r9)r")�matchr!r$r#�sz3BusConnection.add_signal_receiver.<locals>.callback)�pop�	TypeError�warningsrF�DeprecationWarning�superrr4rZset_sender_name_owner�watch_name_ownerrB�add_match_string�str)r6Zhandler_functionZsignal_nameZdbus_interfacer/�pathr7rErFr#�watch)r-)rKr$r4�s&



z!BusConnection.add_signal_receivercCs0|jt|��|jj|d�}|dk	r,|j�dS)N)� remove_match_string_non_blockingrSrBrLr:)r6rKrUr!r!r$�_clean_up_signal_match�sz$BusConnection._clean_up_signal_matchcCst|dk	rl|dd�dkrl|tkrly
|j|�Stk
rh}z"|j�tkrJ�|j|�|j|�Sd}~XqpXn|SdS)NrIrJ)r�get_name_ownerrr(r)�start_service_by_name)r6r/r.r!r!r$�activate_name_owner�s

z!BusConnection.activate_name_ownerTFcKs||r|j�|jdd�}|dk	rN|dk	r0td��ddlm}|dtdd�|}|rhtd	d
j|j����|j|||||d�S)aJReturn a local proxy for the given remote object.

        Method calls on the proxy are translated into method calls on the
        remote object.

        :Parameters:
            `bus_name` : str
                A bus name (either the unique name or a well-known name)
                of the application owning the object. The keyword argument
                named_service is a deprecated alias for this.
            `object_path` : str
                The object path of the desired object
            `introspect` : bool
                If true (default), attempt to introspect the remote
                object to find out supported methods and their signatures
            `follow_name_owner_changes` : bool
                If the object path is a well-known name and this parameter
                is false (default), resolve the well-known name to the unique
                name of its current owner and bind to that instead; if the
                ownership of the well-known name changes in future,
                keep communicating with the original owner.
                This is necessary if the D-Bus API used is stateful.

                If the object path is a well-known name and this parameter
                is true, whenever the well-known name changes ownership in
                future, bind to the new owner, if any.

                If the given object path is a unique name, this parameter
                has no effect.

        :Returns: a `dbus.proxies.ProxyObject`
        :Raises `DBusException`: if resolving the well-known name to a
            unique name fails
        rENz3bus_name and named_service cannot both be specifiedr)rFziPassing the named_service parameter to get_object by name is deprecated: please use positional parametersrG)rHz4get_object does not take these keyword arguments: %sz, )�
introspect�follow_name_owner_changes)	Z_require_main_looprLrMrNrFrO�join�keysZProxyObjectClass)r6r/Zobject_pathr[r\�kwargsrErFr!r!r$�
get_object�s $

zBusConnection.get_objectcCst|�|jtttdd|f�S)z�Get the numeric uid of the process owning the given bus name.

        :Parameters:
            `bus_name` : str
                A bus name, either unique or well-known
        :Returns: a `dbus.UInt32`
        :Since: 0.80.0
        ZGetConnectionUnixUserr3)r�
call_blockingrrr)r6r/r!r!r$�
get_unix_user�s	zBusConnection.get_unix_userrc	Cs$t|�d|jtttdd||f�fS)a?Start a service which will implement the given bus name on this Bus.

        :Parameters:
            `bus_name` : str
                The well-known bus name to be activated.
            `flags` : dbus.UInt32
                Flags to pass to StartServiceByName (currently none are
                defined)

        :Returns: A tuple of 2 elements. The first is always True, the
            second is either START_REPLY_SUCCESS or
            START_REPLY_ALREADY_RUNNING.

        :Raises `DBusException`: if the service could not be started.
        :Since: 0.80.0
        TZStartServiceByName�su)rrarrr)r6r/�flagsr!r!r$rYs

z#BusConnection.start_service_by_namecCs$t|dd�|jtttdd||f�S)a�Request a bus name.

        :Parameters:
            `name` : str
                The well-known name to be requested
            `flags` : dbus.UInt32
                A bitwise-OR of 0 or more of the flags
                `NAME_FLAG_ALLOW_REPLACEMENT`,
                `NAME_FLAG_REPLACE_EXISTING`
                and `NAME_FLAG_DO_NOT_QUEUE`
        :Returns: `REQUEST_NAME_REPLY_PRIMARY_OWNER`,
            `REQUEST_NAME_REPLY_IN_QUEUE`,
            `REQUEST_NAME_REPLY_EXISTS` or
            `REQUEST_NAME_REPLY_ALREADY_OWNER`
        :Raises `DBusException`: if the bus daemon cannot be contacted or
            returns an error.
        F)�allow_uniqueZRequestNamerc)rrarrr)r6�namerdr!r!r$�request_nameszBusConnection.request_namecCs"t|dd�|jtttdd|f�S)asRelease a bus name.

        :Parameters:
            `name` : str
                The well-known name to be released
        :Returns: `RELEASE_NAME_REPLY_RELEASED`,
            `RELEASE_NAME_REPLY_NON_EXISTENT`
            or `RELEASE_NAME_REPLY_NOT_OWNER`
        :Raises `DBusException`: if the bus daemon cannot be contacted or
            returns an error.
        F)reZReleaseNamer3)rrarrr)r6rfr!r!r$�release_name1szBusConnection.release_namecCs(i}trd|d<|jtttddff|�S)z�Return a list of all currently-owned names on the bus.

        :Returns: a dbus.Array of dbus.UTF8String
        :Since: 0.81.0
        Tr1Z	ListNamesr&)rrarrr)r6r7r!r!r$�
list_namesBszBusConnection.list_namescCs(i}trd|d<|jtttddff|�S)z�Return a list of all names that can be activated on the bus.

        :Returns: a dbus.Array of dbus.UTF8String
        :Since: 0.81.0
        Tr1ZListActivatableNamesr&)rrarrr)r6r7r!r!r$�list_activatable_namesOsz$BusConnection.list_activatable_namescCs6i}trd|d<t|dd�|jtttdd|ff|�S)z�Return the unique connection name of the primary owner of the
        given name.

        :Raises `DBusException`: if the `bus_name` has no owner
        :Since: 0.81.0
        Tr1F)rer2r3)rrrarrr)r6r/r7r!r!r$rX\szBusConnection.get_name_ownercCst|||�S)aWatch the unique connection name of the primary owner of the
        given name.

        `callback` will be called with one argument, which is either the
        unique connection name, or the empty string (meaning the name is
        not owned).

        :Since: 0.81.0
        )r)r6r/r#r!r!r$rQks
zBusConnection.watch_name_ownercCst|jtttdd|f��S)z�Return True iff the given bus name has an owner on this bus.

        :Parameters:
            `bus_name` : str
                The bus name to look up
        :Returns: a `bool`
        ZNameHasOwnerr3)�boolrarrr)r6r/r!r!r$�name_has_ownerws
zBusConnection.name_has_ownercCs|jtttdd|f�dS)aArrange for this application to receive messages on the bus that
        match the given rule. This version will block.

        :Parameters:
            `rule` : str
                The match rule
        :Raises `DBusException`: on error.
        :Since: 0.80.0
        �AddMatchr3N)rarrr)r6�ruler!r!r$rR�s
zBusConnection.add_match_stringc	Cs|jtttdd|fdd�dS)a=Arrange for this application to receive messages on the bus that
        match the given rule. This version will not block, but any errors
        will be ignored.


        :Parameters:
            `rule` : str
                The match rule
        :Raises `DBusException`: on error.
        :Since: 0.80.0
        rmr3N)r5rrr)r6rnr!r!r$�add_match_string_non_blocking�s
z+BusConnection.add_match_string_non_blockingcCs|jtttdd|f�dS)aArrange for this application to receive messages on the bus that
        match the given rule. This version will block.

        :Parameters:
            `rule` : str
                The match rule
        :Raises `DBusException`: on error.
        :Since: 0.80.0
        �RemoveMatchr3N)rarrr)r6rnr!r!r$�remove_match_string�s
z!BusConnection.remove_match_stringc	Cs|jtttdd|fdd�dS)a=Arrange for this application to receive messages on the bus that
        match the given rule. This version will not block, but any errors
        will be ignored.


        :Parameters:
            `rule` : str
                The match rule
        :Raises `DBusException`: on error.
        :Since: 0.80.0
        rpr3N)r5rrr)r6rnr!r!r$rV�s
z.BusConnection.remove_match_string_non_blocking)NNNN)TF)r)r)!r;r<r=�__doc__rZTYPE_SESSIONrZTYPE_SYSTEMrZTYPE_STARTERr
ZSTART_REPLY_SUCCESSr	ZSTART_REPLY_ALREADY_RUNNINGrDr4rWrZr`rbrYrgrhrirjrXrQrlrRrorqrV�
__classcell__r!r!)r-r$res6
8




)r)+�__all__Z
__docformat__r*r@Z_dbus_bindingsrrrrrrr	r
rrr
rrrrrrrrrrrrZdbus.connectionrZdbus.exceptionsrZ
dbus.lowlevelrZdbus._compatrZ_NAME_OWNER_CHANGE_MATCHr)Z	getLoggerr+�objectrrr!r!r!r$�<module>sd

+PKMW�\���rDrD(__pycache__/proxies.cpython-36.opt-1.pycnu�[���3

iR�V�`�@s�ddlZyddlmZWn ek
r8ddlmZYnXddlZddlmZddlm	Z	m
Z
mZmZdZ
ejd�ZddlmZmZmZmZmZddlmZGd	d
�d
�ZGdd�d�ZGd
d�de�ZGdd�de�ZdS)�N)�RLock)�process_introspection_data)�
DBusException�IntrospectionParserException�MissingErrorHandlerException�MissingReplyHandlerExceptionZrestructuredtextzdbus.proxies)�BUS_DAEMON_IFACE�BUS_DAEMON_NAME�BUS_DAEMON_PATH�INTROSPECTABLE_IFACE�
LOCAL_PATH)�is_py2c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_DeferredMethodzXA proxy method which will only get called once we have its
    introspection reply.
    cCs||_|j|_||_||_dS)N)�
_proxy_method�_method_name�_append�_block)�self�proxy_method�append�block�r�/usr/lib64/python3.6/proxies.py�__init__6sz_DeferredMethod.__init__cOs@d|ks|jdd�r(|j|j||�dS|j�|j||�SdS)N�
reply_handler�ignore_replyF)�getrrr)r�args�keywordsrrr�__call__=sz_DeferredMethod.__call__cOs|j|j||�dS)N)rr)rrrrrr�
call_asyncHsz_DeferredMethod.call_asyncN)�__name__�
__module__�__qualname__�__doc__rrr rrrrr2src@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_ProxyMethodz�A proxy method.

    Typically a member of a ProxyObject. Calls to the
    method produce messages that travel over the Bus and are routed
    to a specific named Service.
    cCsX|tkrtdt��||_||_||_||_tj|�||_|dk	rNtj	|�||_
dS)Nz1Methods may not be called on the reserved path %s)rr�_proxy�_connection�_named_service�_object_path�_dbus_bindingsZvalidate_member_namerZvalidate_interface_name�_dbus_interface)r�proxyZ
connection�bus_name�object_pathZmethod_nameZifacerrrrSs

z_ProxyMethod.__init__c		Os|jdd�}|jdd�}|jdd�}|jdd�}|dk	s@|dk	rl|dkrPt��n|dkr`t��n|rltd��|jd|j�}|dkr�|dkr�|j}n|d|j}|jjj|d�}|s�|dk	r�|j	j
|j|j||j||||f|�n |j	j
|j|j||j||f|�SdS)	Nr�
error_handlerrF�	signaturez6ignore_reply and reply_handler cannot be used together�dbus_interface�.)�poprr�	TypeErrorr+rr&�_introspect_method_maprr'r r(r)Z
call_blocking)	rrrrr/rr0r1�keyrrrrgsD

z_ProxyMethod.__call__c	Os�|jdd�}|jdd�}|jdd�}|jd|j�}|dkrd|rN|d|j}n|j}|jjj|d�}|jj|j|j	||j||||f|�dS)Nrr/r0r1r2)
r3r+rr&r5rr'r r(r))rrrrr/r0r1r6rrrr �s$
z_ProxyMethod.call_asyncN)r!r"r#r$rrr rrrrr%Ls,r%c@s�eZdZdZeZeZdZdZ	dZ
d%dd	�Zed
d�ddd�Z
ed
d�ddd�Zedd�ddd�Zd&dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd'd!d"�Zd#d$�ZeZdS)(�ProxyObjectz�A proxy to the remote Object.

    A ProxyObject is provided by the Bus. ProxyObjects
    have member functions, and can be called like normal Python objects.
    r��NTFc
Ks<|jdd�}|dk	rB|dk	r$td��|}ddlm}|dtdd�|jd	d�}	|	dk	r�|dk	rftd
��|	}ddlm}|dtdd�|r�tdd
j|j����|r�|j�||_|dk	r�t	j
|�||_|_t	j
|�||_|s�|j|�|_d|_g|_i|_t�|_|�s|jtk�r&|j|_n|j|_|j�|_dS)a�Initialize the proxy object.

        :Parameters:
            `conn` : `dbus.connection.Connection`
                The bus or connection on which to find this object.
                The keyword argument `bus` is a deprecated alias for this.
            `bus_name` : str
                A bus name for the application owning the object, to be used
                as the destination for method calls and the sender for
                signal matches. The keyword argument ``named_service`` is a
                deprecated alias for this.
            `object_path` : str
                The object path at which the application exports the object
            `introspect` : bool
                If true (default), attempt to introspect the remote
                object to find out supported methods and their signatures
            `follow_name_owner_changes` : bool
                If true (default is false) and the `bus_name` is a
                well-known name, follow ownership changes for that name
        �busNz%conn and bus cannot both be specifiedr)�warnz`Passing the bus parameter to ProxyObject by name is deprecated: please use positional parametersr9)�
stacklevel�
named_servicez3bus_name and named_service cannot both be specifiedzjPassing the named_service parameter to ProxyObject by name is deprecated: please use positional parametersz>ProxyObject.__init__ does not take these keyword arguments: %sz, )r3r4�warningsr;�DeprecationWarning�join�keysZ_require_main_loop�_busr*Zvalidate_bus_namer(�_requested_bus_nameZvalidate_object_path�__dbus_object_path__Zactivate_name_owner�_pending_introspect�_pending_introspect_queuer5r�_introspect_lockr� INTROSPECT_STATE_DONT_INTROSPECT�_introspect_state�'INTROSPECT_STATE_INTROSPECT_IN_PROGRESS�_Introspect)
rZconnr-r.Z
introspectZfollow_name_owner_changes�kwargsr:r;r=rrrr�sJ




zProxyObject.__init__cCs|jS)N)r()rrrr�<lambda>szProxyObject.<lambda>a�The bus name to which this proxy is bound. (Read-only,
            may change.)

            If the proxy was instantiated using a unique name, this property
            is that unique name.

            If the proxy was instantiated with a well-known name and with
            ``follow_name_owner_changes`` set false (the default), this
            property is the unique name of the connection that owned that
            well-known name when the proxy was instantiated, which might
            not actually own the requested well-known name any more.

            If the proxy was instantiated with a well-known name and with
            ``follow_name_owner_changes`` set true, this property is that
            well-known name.
            cCs|jS)N)rC)rrrrrMsz[The bus name which was requested when this proxy was
            instantiated.
            cCs|jS)N)rD)rrrrrM$szThe object-path of this proxy.cKs"|jj|f|||j|jd�|��S)axArrange for the given function to be called when the given signal
        is received.

        :Parameters:
            `signal_name` : str
                The name of the signal
            `handler_function` : callable
                A function to be called when the signal is emitted by
                the remote object. Its positional arguments will be the
                arguments of the signal; optionally, it may be given
                keyword arguments as described below.
            `dbus_interface` : str
                Optional interface with which to qualify the signal name.
                If None (the default) the handler will be called whenever a
                signal of the given member name is received, whatever
                its interface.
        :Keywords:
            `utf8_strings` : bool
                If True, the handler function will receive any string
                arguments as dbus.UTF8String objects (a subclass of str
                guaranteed to be UTF-8). If False (default) it will receive
                any string arguments as dbus.String objects (a subclass of
                unicode).
            `byte_arrays` : bool
                If True, the handler function will receive any byte-array
                arguments as dbus.ByteArray objects (a subclass of str).
                If False (default) it will receive any byte-array
                arguments as a dbus.Array of dbus.Byte (subclasses of:
                a list of ints).
            `sender_keyword` : str
                If not None (the default), the handler function will receive
                the unique name of the sending endpoint as a keyword
                argument with this name
            `destination_keyword` : str
                If not None (the default), the handler function will receive
                the bus name of the destination (or None if the signal is a
                broadcast, as is usual) as a keyword argument with this name.
            `interface_keyword` : str
                If not None (the default), the handler function will receive
                the signal interface as a keyword argument with this name.
            `member_keyword` : str
                If not None (the default), the handler function will receive
                the signal name as a keyword argument with this name.
            `path_keyword` : str
                If not None (the default), the handler function will receive
                the object-path of the sending object as a keyword argument
                with this name
            `message_keyword` : str
                If not None (the default), the handler function will receive
                the `dbus.lowlevel.SignalMessage` as a keyword argument with
                this name.
            `arg...` : unicode or UTF-8 str
                If there are additional keyword parameters of the form
                ``arg``\ *n*, match only signals where the *n*\ th argument
                is the value given for that keyword parameter. As of this time
                only string arguments can be matched (in particular,
                object paths and signatures can't).
        )�signal_namer1r-�path)rBZadd_signal_receiverr(rD)rrN�handler_functionr1rrrr�connect_to_signal0s<
zProxyObject.connect_to_signalc	Cs>i}trd|d<|jj|j|jtddf|j|jfddi|��S)NTZutf8_stringsZ
Introspect�Zrequire_main_loopF)r
rBr r(rDr�_introspect_reply_handler�_introspect_error_handler)rrLrrrrKss
zProxyObject._IntrospectcCs*x|jD]\}}}|||�qWg|_dS)N)rF)rrrrrrr�_introspect_execute_queue~sz%ProxyObject._introspect_execute_queuecCsp|jj�zTyt|�|_Wn*tk
rD}z|j|�dSd}~XnX|j|_d|_|j	�Wd|jj
�XdS)N)rG�acquirerr5rrT� INTROSPECT_STATE_INTROSPECT_DONErIrErU�release)r�data�errrrS�s

z%ProxyObject._introspect_reply_handlerc
Cshtj�tjd|j|j|jj|jj|�|j	j
�z$tjd�|j|_
d|_|j�Wd|j	j�XdS)Nz$Introspect error on %s:%s: %s.%s: %sz'Executing introspect queue due to error)�loggingZbasicConfig�_logger�errorr(rD�	__class__r"r!rGrV�debugrHrIrErUrX)rr]rrrrT�s

z%ProxyObject._introspect_error_handlerc
Cs4|jj�z|jdk	r |jj�Wd|jj�XdS)N)rGrVrErrX)rrrr�_introspect_block�s


zProxyObject._introspect_blockc
CsJ|jj�z.|j|jkr,|jj|||f�n
|||�Wd|jj�XdS)N)rGrVrIrJrFrrX)r�callbackrrLrrr�_introspect_add_to_queue�s
z$ProxyObject._introspect_add_to_queuecCs,|jd�r|jd�rt|��n
|j|�SdS)N�__)�
startswith�endswith�AttributeError�get_dbus_method)r�memberrrr�__getattr__�s
zProxyObject.__getattr__cCs<|j||j|j|j||�}|j|jkr8|j||j|j�}|S)a,Return a proxy method representing the given D-Bus method. The
        returned proxy method can be called in the usual way. For instance, ::

            proxy.get_dbus_method("Foo", dbus_interface='com.example.Bar')(123)

        is equivalent to::

            proxy.Foo(123, dbus_interface='com.example.Bar')

        or even::

            getattr(proxy, "Foo")(123, dbus_interface='com.example.Bar')

        However, using `get_dbus_method` is the only way to call D-Bus
        methods with certain awkward names - if the author of a service
        implements a method called ``connect_to_signal`` or even
        ``__getattr__``, you'll need to use `get_dbus_method` to call them.

        For services which follow the D-Bus convention of CamelCaseMethodNames
        this won't be a problem.
        )	�ProxyMethodClassrBr(rDrIrJ�DeferredMethodClassrbr`)rrhr1�retrrrrg�s

zProxyObject.get_dbus_methodcCsd|j|j|jt|�fS)Nz&<ProxyObject wrapping %s %s %s at %#x>)rBr(rD�id)rrrr�__repr__�szProxyObject.__repr__)NNNTF)N)N)r!r"r#r$r%rjrrkrHrJrWr�propertyr-�requested_bus_namer.rQrKrUrSrTr`rbrirgrn�__str__rrrrr7�s6
R

C

&r7c@s�eZdZdZdd�Zedd�ddd�ZeZedd�ddd	�Zed
d�ddd�Z	edd�ddd
�Z
edd�ddd�Zddd�Zdd�Z
ddd�Zdd�ZeZdS)�	Interfacez�An interface into a remote object.

    An Interface can be used to wrap ProxyObjects
    so that calls can be routed to their correct
    D-Bus interface.
    cCs$t|t�r|j|_n||_||_dS)a:Construct a proxy for the given interface on the given object.

        :Parameters:
            `object` : `dbus.proxies.ProxyObject` or `dbus.Interface`
                The remote object or another of its interfaces
            `dbus_interface` : str
                An interface the `object` implements
        N)�
isinstancerr�proxy_object�_objr+)r�objectr1rrrr�s	

zInterface.__init__cCs|jjS)N)rur.)rrrrrMszInterface.<lambda>Nz.The D-Bus object path of the underlying objectcCs|jjS)N)rur-)rrrrrMsz:The bus name to which the underlying proxy object is boundcCs|jjS)N)rurp)rrrrrM	szGThe bus name which was requested when the underlying object was createdcCs|jS)N)ru)rrrrrM
szThe underlying proxy objectcCs|jS)N)r+)rrrrrMszThe D-Bus interface representedcKs|s
|j}|jj|||f|�S)aaArrange for a function to be called when the given signal is
        emitted.

        The parameters and keyword arguments are the same as for
        `dbus.proxies.ProxyObject.connect_to_signal`, except that if
        `dbus_interface` is None (the default), the D-Bus interface that
        was passed to the `Interface` constructor is used.
        )r+rurQ)rrNrPr1rrrrrQs

zInterface.connect_to_signalcCs2|jd�r|jd�rt|��n|jj||j�SdS)Nrc)rdrerfrurgr+)rrhrrrri"s
zInterface.__getattr__cCs|dkr|j}|jj||�S)a&Return a proxy method representing the given D-Bus method.

        This is the same as `dbus.proxies.ProxyObject.get_dbus_method`
        except that if `dbus_interface` is None (the default),
        the D-Bus interface that was passed to the `Interface` constructor
        is used.
        N)r+rurg)rrhr1rrrrg(szInterface.get_dbus_methodcCsd|j|jt|�fS)Nz%<Interface %r implementing %r at %#x>)rur+rm)rrrrrn4szInterface.__repr__)N)N)r!r"r#r$rror.rDr-rprtr1rQrirgrnrqrrrrrr�s&

rr)r[Z	threadingr�ImportErrorZdummy_threadingr*Zdbus._expat_introspect_parserrZdbus.exceptionsrrrrZ
__docformat__Z	getLoggerr\rr	r
rrZdbus._compatr
rr%rvr7rrrrrr�<module>s"
`BPKMW�\���ĭ�&__pycache__/types.cpython-36.opt-1.pycnu�[���3

iR�V�@s�dddddddddd	d
ddd
dddgZddlmZmZmZmZmZmZmZm	Z	m
Z
mZmZm
Z
mZmZmZmZmZddlmZer�ddlmZejd�dS)�
ObjectPath�	ByteArray�	Signature�Byte�Boolean�Int16�UInt16�Int32�UInt32�Int64�UInt64�Double�String�Array�Struct�
Dictionary�UnixFd�)rrrrrrrrr
rrr
rrr	rr)�is_py2)�
UTF8StringrN)�__all__Z_dbus_bindingsrrrrrrrrr
rrr
rrr	rrZdbus._compatrr�append�rr�/usr/lib64/python3.6/types.py�<module>s

LPKMW�\��h��&__pycache__/_dbus.cpython-36.opt-1.pycnu�[���3

iR�Vd"�@s�dZddlmZdZdZddlmZdd	lmZm	Z	m
Z
mZmZm
Z
mZmZmZmZmZmZdd
lmZddlmZddlmZer�dd
lmZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)z9Implementation for dbus.Bus. Not to be imported directly.�)�
generators�Bus�	SystemBus�
SessionBus�
StarterBusZreStructuredText)�
DBusException)�BUS_DAEMON_IFACE�BUS_DAEMON_NAME�BUS_DAEMON_PATH�BUS_SESSION�BUS_STARTER�
BUS_SYSTEM� DBUS_START_REPLY_ALREADY_RUNNING�DBUS_START_REPLY_SUCCESS�validate_bus_name�validate_interface_name�validate_member_name�validate_object_path)�
BusConnection)�
SignalMessage)�is_py2)�
UTF8Stringcs�eZdZdZiZejddfdd�Z�fdd�Zdd	�Z	e
e	ddd
�Zddd�Ze
e�Zdd
d�Ze
e�Zddd�Ze
e�Zdd�ZeZ�ZS)ra A connection to one of three possible standard buses, the SESSION,
    SYSTEM, or STARTER bus. This class manages shared connections to those
    buses.

    If you're trying to subclass `Bus`, you may be better off subclassing
    `BusConnection`, which doesn't have all this magic.
    FNcCsx|r||jkr|j|S|tkr(t}n(|tkr6t}n|tkrDt}ntd|��tj	|||d�}||_
|st||j|<|S)a�Constructor, returning an existing instance where appropriate.

        The returned instance is actually always an instance of `SessionBus`,
        `SystemBus` or `StarterBus`.

        :Parameters:
            `bus_type` : cls.TYPE_SESSION, cls.TYPE_SYSTEM or cls.TYPE_STARTER
                Connect to the appropriate bus
            `private` : bool
                If true, never return an existing shared instance, but instead
                return a private connection.

                :Deprecated: since 0.82.3. Use dbus.bus.BusConnection for
                    private connections.

            `mainloop` : dbus.mainloop.NativeMainLoop
                The main loop to use. The default is to use the default
                main loop if one has been set up, or raise an exception
                if none has been.
        :Changed: in dbus-python 0.80:
            converted from a wrapper around a Connection to a Connection
            subclass.
        zinvalid bus_type %s)�mainloop)�_shared_instancesrrr
rrr�
ValueErrorr�__new__�	_bus_type)�clsZbus_type�privater�subclassZbus�r �/usr/lib64/python3.6/_dbus.pyr:s

zBus.__new__cs4|j}|jjj|�|kr"|jj|=tt|�j�dS)N)r�	__class__r�get�superr�close)�self�t)r"r r!r%ms
z	Bus.closecCs|S)z�Return self, for backwards compatibility with earlier dbus-python
        versions where Bus was not a subclass of Connection.

        :Deprecated: since 0.80.0
        r )r&r r r!�get_connectionsszBus.get_connectionz�self._connection == self, for backwards
                           compatibility with earlier dbus-python versions
                           where Bus was not a subclass of Connection.cCs
t|d�S)z�Static method that returns a connection to the session bus.

        :Parameters:
            `private` : bool
                If true, do not return a shared connection.
        )r)r)rr r r!�get_sessionszBus.get_sessioncCs
t|d�S)z�Static method that returns a connection to the system bus.

        :Parameters:
            `private` : bool
                If true, do not return a shared connection.
        )r)r)rr r r!�
get_system�szBus.get_systemcCs
t|d�S)z�Static method that returns a connection to the starter bus.

        :Parameters:
            `private` : bool
                If true, do not return a shared connection.
        )r)r)rr r r!�get_starter�szBus.get_startercCsP|jtkrd}n$|jtkr d}n|jtkr0d}nd}d|jj|jj|t|�fS)NZsession�systemZstarterzunknown bus typez<%s.%s (%s) at %#x>)rrr
rr"�
__module__�__name__�id)r&�namer r r!�__repr__�s


zBus.__repr__)F)F)F)r.r-�__qualname__�__doc__rr�TYPE_SESSIONrr%r(�propertyZ_connectionr)�staticmethodr*r+r1�__str__�
__classcell__r r )r"r!r/s 2
	
	
	
c@seZdZdZddd�ZdS)rzThe system-wide message bus.FNcCstj|tj||d�S)a�Return a connection to the system bus.

        :Parameters:
            `private` : bool
                If true, never return an existing shared instance, but instead
                return a private connection.
            `mainloop` : dbus.mainloop.NativeMainLoop
                The main loop to use. The default is to use the default
                main loop if one has been set up, or raise an exception
                if none has been.
        )rr)rrZTYPE_SYSTEM)rrrr r r!r�szSystemBus.__new__)FN)r.r-r2r3rr r r r!r�sc@seZdZdZddd�ZdS)rz(The session (current login) message bus.FNcCstj|tj||d�S)a�Return a connection to the session bus.

        :Parameters:
            `private` : bool
                If true, never return an existing shared instance, but instead
                return a private connection.
            `mainloop` : dbus.mainloop.NativeMainLoop
                The main loop to use. The default is to use the default
                main loop if one has been set up, or raise an exception
                if none has been.
        )rr)rrr4)rrrr r r!r�szSessionBus.__new__)FN)r.r-r2r3rr r r r!r�sc@seZdZdZddd�ZdS)rzjThe bus that activated this process (only valid if
    this process was launched by DBus activation).
    FNcCstj|tj||d�S)a�Return a connection to the bus that activated this process.

        :Parameters:
            `private` : bool
                If true, never return an existing shared instance, but instead
                return a private connection.
            `mainloop` : dbus.mainloop.NativeMainLoop
                The main loop to use. The default is to use the default
                main loop if one has been set up, or raise an exception
                if none has been.
        )rr)rrZTYPE_STARTER)rrrr r r!r�szStarterBus.__new__)FN)r.r-r2r3rr r r r!r�sN)rrrr)r3Z
__future__r�__all__Z
__docformat__Zdbus.exceptionsrZ_dbus_bindingsrr	r
rrr
rrrrrrZdbus.busrZ
dbus.lowlevelrZdbus._compatrrrrrrr r r r!�<module>s8PKMW�\���7��)__pycache__/lowlevel.cpython-36.opt-1.pycnu�[���3

iR�V'�
@sHdZdZddlmZmZmZmZmZmZm	Z	m
Z
mZmZm
Z
mZmZdS)zLow-level interface to D-Bus.�PendingCall�Message�MethodCallMessage�MethodReturnMessage�ErrorMessage�
SignalMessage�HANDLER_RESULT_HANDLED�HANDLER_RESULT_NOT_YET_HANDLED�MESSAGE_TYPE_INVALID�MESSAGE_TYPE_METHOD_CALL�MESSAGE_TYPE_METHOD_RETURN�MESSAGE_TYPE_ERROR�MESSAGE_TYPE_SIGNAL�)
rrrrr	r
rr
rrrrrN)
rrrrrrrrr	r
rrr
)�__doc__�__all__Z_dbus_bindingsrrrrr	r
rr
rrrrr�rr� /usr/lib64/python3.6/lowlevel.py�<module>sPKMW�\���3��3__pycache__/_expat_introspect_parser.cpython-36.pycnu�[���3

iR�V0
�@s4ddlmZddlmZGdd�de�Zdd�ZdS)�)�ParserCreate)�IntrospectionParserExceptionc@s0eZdZdZdd�Zdd�Zd	d
�Zdd�Zd
S)�_Parser�map�in_iface�	in_method�sigcCsi|_d|_d|_d|_dS)N�)rrrr)�self�r�0/usr/lib64/python3.6/_expat_introspect_parser.py�__init__sz_Parser.__init__cCs0tdd�}d|_|j|_|j|_|j|�|jS)NzUTF-8� T)rZbuffer_text�StartElementHandler�EndElementHandlerZParser)r
�data�parserrrr�parse%s

z
_Parser.parsecCsr|js"|jrn|dkrn|d|_nL|jr>|dkr>|d|_n0|jrn|dkrn|jdd�dkrn|j|d7_dS)N�	interface�name�method�arg�	direction�in�type)rr�getr)r
rZ
attributesrrrr-sz_Parser.StartElementHandlercCsT|jrP|jr|dkrd|_n2|jrP|dkrP|j|j|jd|j<d|_d|_dS)Nrr	r�.)rrrr)r
rrrrr8sz_Parser.EndElementHandlerN)rrrr)�__name__�
__module__�__qualname__�	__slots__r
rrrrrrrrs
rcCsFyt�j|�Stk
r@}ztd|j|f��WYdd}~XnXdS)a�Return a dict mapping ``interface.method`` strings to the
    concatenation of all their 'in' parameters, and mapping
    ``interface.signal`` strings to the concatenation of all their
    parameters.

    Example output::

        {
            'com.example.SignalEmitter.OneString': 's',
            'com.example.MethodImplementor.OneInt32Argument': 'i',
        }

    :Parameters:
        `data` : str
            The introspection XML. Must be an 8-bit string of UTF-8.
    z%s: %sN)rr�	Exceptionr�	__class__)r�errr�process_introspection_dataAsr$N)Zxml.parsers.expatrZdbus.exceptionsr�objectrr$rrrr�<module>s$PKMW�\Ϥ���U�U(__pycache__/service.cpython-36.opt-1.pycnu�[���3

iR�V��@s:dZdZddlZddlZddlZddlZddlmZddlZdd	l	m
Z
mZmZm
Z
mZmZmZdd
lmZmZddlmZmZmZddlmZmZmZdd
lmZddlmZej d�Z!Gdd�de"�Z#Gdd�de"�Z$dd�Z%dd�Z&dd�Z'Gdd�de(�Z)e)de"fi�Z*e"�Z+Gdd�de*�Z,Gdd�de,�Z-dS)�BusName�Object�FallbackObject�method�signalZrestructuredtext�N)�Sequence)�INTROSPECTABLE_IFACE�
ObjectPath�
SessionBus�	Signature�Struct�validate_bus_name�validate_object_path)rr)�
DBusException�NameExistsException�UnknownMethodException)�ErrorMessage�MethodReturnMessage�MethodCallMessage)�
LOCAL_PATH)�is_py2zdbus.servicec@s(eZdZdZdd�Zdd�Zer$eZdS)�_VariantSignaturez�A fake method signature which, when iterated, yields an endless stream
    of 'v' characters representing variants (handy with zip()).

    It has no string representation.
    cCs|S)zReturn self.�)�selfrr�/usr/lib64/python3.6/service.py�__iter__8sz_VariantSignature.__iter__cCsdS)zReturn 'v' whenever called.�vr)rrrr�__next__<sz_VariantSignature.__next__N)�__name__�
__module__�__qualname__�__doc__rrr�nextrrrrr2s
rc@sFeZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	e	Z
dS)ra^A base class for exporting your own Named Services across the Bus.

    When instantiated, objects of this class attempt to claim the given
    well-known name on the given bus for the current process. The name is
    released when the BusName object becomes unreferenced.

    If a well-known name is requested multiple times, multiple references
    to the same BusName object will be returned.

    Caveats
    -------
    - Assumes that named services are only ever requested using this class -
      if you request names from the bus directly, confusion may occur.
    - Does not handle queueing.
    NFc
Cs�t|ddd�|dkr4ddl}|jdtdd�t�}||jkrH|j|S|rRtjpTd|r^tjp`dB|rltj	pndB}|j
||�}|tjkr�n<|tjkr�n0|tj
kr�t|��n|tjkr�ntd	||f��tj|�}	||	_||	_|	|j|<|	S)
aSConstructor, which may either return an existing cached object
        or a new object.

        :Parameters:
            `name` : str
                The well-known name to be advertised
            `bus` : dbus.Bus
                A Bus on which this service will be advertised.

                Omitting this parameter or setting it to None has been
                deprecated since version 0.82.1. For backwards compatibility,
                if this is done, the global shared connection to the session
                bus will be used.

            `allow_replacement` : bool
                If True, other processes trying to claim the same well-known
                name will take precedence over this one.
            `replace_existing` : bool
                If True, this process can take over the well-known name
                from other processes already holding it.
            `do_not_queue` : bool
                If True, this service will not be placed in the queue of
                services waiting for the requested name if another service
                already holds it.
        TF)Zallow_well_knownZallow_uniqueNrzKOmitting the "bus" parameter to dbus.service.BusName.__init__ is deprecated�)�
stacklevelz3requesting bus name %s returned unexpected value %s)r
�warnings�warn�DeprecationWarningr
Z
_bus_names�_dbus_bindingsZNAME_FLAG_ALLOW_REPLACEMENTZNAME_FLAG_REPLACE_EXISTINGZNAME_FLAG_DO_NOT_QUEUEZrequest_nameZ REQUEST_NAME_REPLY_PRIMARY_OWNERZREQUEST_NAME_REPLY_IN_QUEUEZREQUEST_NAME_REPLY_EXISTSrZ REQUEST_NAME_REPLY_ALREADY_OWNER�RuntimeError�object�__new__�_bus�_name)
�cls�nameZbusZallow_replacementZreplace_existingZdo_not_queuer%Z
name_flags�retval�bus_namerrrr+Ts2









zBusName.__new__cOsdS)Nr)r�args�keywordsrrr�__init__�szBusName.__init__cCs|jj|j�dS)N)r,Zrelease_namer-)rrrr�__del__�szBusName.__del__cCs|jS)zGet the Bus this Service is on)r,)rrrr�get_bus�szBusName.get_buscCs|jS)zGet the name of this service)r-)rrrr�get_name�szBusName.get_namecCsd|j|jt|�fS)Nz&<dbus.service.BusName %s on %r at %#x>)r-r,�id)rrrr�__repr__�szBusName.__repr__)NFFF)rrr r!r+r4r5r6r7r9�__str__rrrrrDs
OcCs^d}d}d}|r�x�|jjD]�}|rz||jkrzd|j|jkrvd|j|jkrv|j|j|krz|}|j|}d}Pqzn|}|r||jkrd|j|jkrd|j|jkr|j|j|kr|j|}d}PqWnTxR|jjD]F}|r�||jkr�|}|r�||jkr�d|j|jkr�|j|}d}Pq�W|�r6|j||fS|�rNtd||f��ntd|��dS)z�Walks the Python MRO of the given class to find the method to invoke.

    Returns two methods, the one to call, and the one it inherits from which
    defines its D-Bus interface name, signature, and attributes.
    NF�_dbus_is_method�_dbus_interfaceTz(%s is not a valid method of interface %sz%s is not a valid method)�	__class__�__mro__�__dict__r<r)r�method_nameZdbus_interface�
parent_methodZcandidate_classZ
successfulr.rrr�_method_lookup�sF


rBc Gs�t|�}y|j|d|i�Wn�tk
r�}zvtj�|dkr�y|j|�d}Wn6tk
r�}ztjd||j|��WYdd}~XnXtjd|||j|��WYdd}~XnX|j	|�dS)N�	signaturez
 (guessed)z2Unable to guess signature for arguments %r: %s: %sz8Unable to append %r to message with signature %s: %s: %s)
r�append�	Exception�loggingZbasicConfigZguess_signature�_logger�errorr=�send_message)�
connection�messager@rCr0�reply�errr�_method_reply_return�s rNc	Cs�t|dd�}|dk	rn0t|dd�dkr4d|jj}nd|j|jjf}tj�\}}}t|t�rp|jrp|j	�}n2||kr�dj
tj|||��}ndj
tj
|j|��}t|||�}|j|�dS)NZ_dbus_error_namer��__main__zorg.freedesktop.DBus.Python.%sz!org.freedesktop.DBus.Python.%s.%s)rOrP)�getattrr=rr�sys�exc_info�
isinstancerZinclude_tracebackZget_dbus_message�join�	traceback�format_exception�format_exception_onlyrrI)	rJrK�	exceptionr/ZetZevZetb�contentsrLrrr�_method_reply_errors
r[cs,eZdZ�fdd�Zdd�Zdd�Z�ZS)�
InterfaceTypecs�t|di�}||_i}||jd|<xX|D]P}|jd|j}t|dd�r.x.||j�D]\}}	|j|i�}
|
j|	�q\Wq.Wx4|j�D](}t|dd�r�|j|ji�}	||	|j<q�Wt	t
|�j|||�dS)N�_dbus_class_table�.Fr<)rQr]rr�items�
setdefault�update�valuesr<�superr\r4)r.r/�basesZdctZclass_tableZinterface_table�bZ	base_nameZ	interfaceZmethod_tableZour_method_table�func)r=rrr4,s
zInterfaceType.__init__cCs�|j}|jrtt|j��}nt�}|jr4t|j�}ng}d|j}xt||�D]}|d|7}qNWx|D]}|d|7}qhW|d7}|S)Nz    <method name="%s">
z2      <arg direction="in"  type="%s" name="%s" />
z(      <arg direction="out" type="%s" />
z    </method>
)�
_dbus_argsZ_dbus_in_signature�tuplerr�_dbus_out_signaturer�zip)r.rfr2Zin_sigZout_sig�reflection_data�pair�typerrr�_reflect_on_methodFs

z InterfaceType._reflect_on_methodcCsX|j}|jrtt|j��}nt�}d|j}xt||�D]}|d|}q8W|d}|S)Nz    <signal name="%s">
z"      <arg type="%s" name="%s" />
z    </signal>
)rgZ_dbus_signaturerhrrrrj)r.rfr2Zsigrkrlrrr�_reflect_on_signalcs
z InterfaceType._reflect_on_signal)rrr r4rnro�
__classcell__rr)r=rr\+sr\�	Interfacec@s�eZdZdZdZdZddd�Zedd��Zedd	��Z	ed
d��Z
dd
�Zddd�Zdd�Z
dd�Zeeddddd�dd��Zdd�ZeZdS)ra�A base class for exporting your own Objects across the Bus.

    Just inherit from Object and mark exported methods with the
    @\ `dbus.service.method` or @\ `dbus.service.signal` decorator.

    Example::

        class Example(dbus.service.object):
            def __init__(self, object_path):
                dbus.service.Object.__init__(self, dbus.SessionBus(), path)
                self._last_input = None

            @dbus.service.method(interface='com.example.Sample',
                                 in_signature='v', out_signature='s')
            def StringifyVariant(self, var):
                self.LastInputChanged(var)      # emits the signal
                return str(var)

            @dbus.service.signal(interface='com.example.Sample',
                                 signature='v')
            def LastInputChanged(self, var):
                # run just before the signal is actually emitted
                # just put "pass" if nothing should happen
                self._last_input = var

            @dbus.service.method(interface='com.example.Sample',
                                 in_signature='', out_signature='v')
            def GetLastInput(self):
                return self._last_input
    FNcCs�|dk	rt|�t|t�r(|}|j�}n|dkr@|dk	r@|j�}d|_d|_g|_tj�|_	d|_
||_|dkr�|dk	r�td��|dk	r�|dk	r�|j
||�dS)aConstructor. Either conn or bus_name is required; object_path
        is also required.

        :Parameters:
            `conn` : dbus.connection.Connection or None
                The connection on which to export this object.

                If None, use the Bus associated with the given ``bus_name``.
                If there is no ``bus_name`` either, the object is not
                initially available on any Connection.

                For backwards compatibility, if an instance of
                dbus.service.BusName is passed as the first parameter,
                this is equivalent to passing its associated Bus as
                ``conn``, and passing the BusName itself as ``bus_name``.

            `object_path` : str or None
                A D-Bus object path at which to make this Object available
                immediately. If this is not None, a `conn` or `bus_name` must
                also be provided.

            `bus_name` : dbus.service.BusName or None
                Represents a well-known name claimed by this process. A
                reference to the BusName object will be held by this
                Object, preventing the name from being released during this
                Object's lifetime (unless it's released manually).
        NFz<If object_path is given, either conn or bus_name is required)rrTrr6�_object_path�_connection�
_locations�	threadingZLock�_locations_lock�	_fallbackr-�	TypeError�add_to_connection)r�conn�object_pathr1rrrr4�s$


zObject.__init__cCs:|jtkrtd|��n|jdkr0td|��n|jSdS)z�The object-path at which this object is available.
        Access raises AttributeError if there is no object path, or more than
        one object path.

        Changed in 0.82.0: AttributeError can be raised.
        zEObject %r has more than one object path: use Object.locations insteadNz Object %r has no object path yet)rr�_MANY�AttributeError)rrrr�__dbus_object_path__�s


zObject.__dbus_object_path__cCs:|jtkrtd|��n|jdkr0td|��n|jSdS)z�The Connection on which this object is available.
        Access raises AttributeError if there is no Connection, or more than
        one Connection.

        Changed in 0.82.0: AttributeError can be raised.
        zFObject %r is on more than one Connection: use Object.locations insteadNzObject %r has no Connection yet)rsr|r})rrrrrJ�s


zObject.connectioncCs
t|j�S)aeAn iterable over tuples representing locations at which this
        object is available.

        Each tuple has at least two items, but may have more in future
        versions of dbus-python, so do not rely on their exact length.
        The first two items are the dbus.connection.Connection and the object
        path.

        :Since: 0.82.0
        )�iterrt)rrrr�	locationsszObject.locationscCs�|tkrtdt��|jj�z�|jdk	rN|j|k	rN|jrNtd||jf��|jdk	r||jr||j|kr|td||jf��|j||j	|j
|j�|jdkr�||_n|j|k	r�t|_|jdkr�||_n|j|kr�t|_|j
j|||jf�Wd|jj�XdS)aNMake this object accessible via the given D-Bus connection and
        object path.

        :Parameters:
            `connection` : dbus.connection.Connection
                Export the object on this connection. If the class attribute
                SUPPORTS_MULTIPLE_CONNECTIONS is False (default), this object
                can only be made available on one connection; if the class
                attribute is set True by a subclass, the object can be made
                available on more than one connection.

            `path` : dbus.ObjectPath or other str
                Place the object at this object path. If the class attribute
                SUPPORTS_MULTIPLE_OBJECT_PATHS is False (default), this object
                can only be made available at one object path; if the class
                attribute is set True by a subclass, the object can be made
                available with more than one object path.

        :Raises ValueError: if the object's class attributes do not allow the
            object to be exported in the desired way.
        :Since: 0.82.0
        z3Objects may not be exported on the reserved path %sNz'%r is already exported on connection %rz(%r is already exported at object path %s)r�
ValueErrorrv�acquirers�SUPPORTS_MULTIPLE_CONNECTIONSrr�SUPPORTS_MULTIPLE_OBJECT_PATHSZ_register_object_path�_message_cb�_unregister_cbrwr|rtrD�release)rrJ�pathrrrrys8









zObject.add_to_connectioncCs$|jj��z|jdks"|jdkr.td|��|dk	s>|dk	r�g}xN|jD]6}|dksb|d|krJ|dksv|d|krJ|j|�qJWn|j}g|_|s�td|||f��xf|D]^}y|dj|d�Wntk
r�YnX|jr�y|jj|�Wq�t	k
�r
Yq�Xq�WWd|jj
�XdS)aMake this object inaccessible via the given D-Bus connection
        and object path. If no connection or path is specified,
        the object ceases to be accessible via any connection or path.

        :Parameters:
            `connection` : dbus.connection.Connection or None
                Only remove the object from this Connection. If None,
                remove from all Connections on which it's exported.
            `path` : dbus.ObjectPath or other str, or None
                Only remove the object from this object path. If None,
                remove from all object paths.
        :Raises LookupError:
            if the object was not exported on the requested connection
            or path, or (if both are None) was not exported at all.
        :Since: 0.81.1
        Nz%r is not exportedr�z1%r is not exported at a location matching (%r,%r))rvr�rrrs�LookupErrorrtrDZ_unregister_object_path�remover�r�)rrJr�Zdropped�locationrrr�remove_from_connectionPs4

zObject.remove_from_connectioncCstjd||�dS)Nz5Unregistering exported object %r from some path on %r)rG�info)rrJrrrr��szObject._unregister_cbcs�t�t�sdS�y`�j���j�}t|�|�\}}�jf|j�}i}|jdk	rZt|j��nd�|j	r�|j	\}}	����fdd�||<��fdd�||	<|j
r��j�||j
<|jr��j
�||j<|j�r^�j
�}
|
}xx|jD]n}|d�kr�|
|dk�r�d}P|ddk�rq�|
j|dd�r�|
t|d�d�}
t|
�t|�kr�|
}q�Wt|�}|||j<|j�rt�j�||j<|j�r��||j<|j�r��||j<||f|�|�}|j	�r�dS�dk	�r(t��}t|�dk�r�|dk�r�f}ntd���n4t|�dk�r|f}nt|t��rntd��f��n2|dk�r8f}n"t|t��rTt|t��rTn|f}t����f|��Wn0tk
�r�}zt��|�WYdd}~XnXdS)	Ncst����f|��S)N)rN)r0)rJrKr@rCrr�<lambda>�sz$Object._message_cb.<locals>.<lambda>cst��|�S)N)r[)rY)rJrKrrr��srr��/z8%s has an empty output signature but did not return NonezK%s has multiple output values in signature %s but did not return a sequence)rTrZ
get_memberZ
get_interfacerBZ
get_args_listZ_dbus_get_args_optionsrirZ_dbus_async_callbacksZ_dbus_sender_keywordZ
get_senderZ_dbus_path_keyword�get_pathZ_dbus_rel_path_keywordrt�
startswith�lenr	Z_dbus_destination_keywordZget_destinationZ_dbus_message_keywordZ_dbus_connection_keywordrhrxrrrNrEr[)rrJrKZinterface_nameZcandidate_methodrAr2r3Zreturn_callbackZerror_callbackr�Zrel_pathZexp�suffixr0Zsignature_tuplerYr)rJrKr@rCrr��s�









zObject._message_cbrO�sr{rJ)Zin_signatureZ
out_signatureZpath_keywordZconnection_keywordcCs�tj}|d|7}|j|jjd|jj}xt|j�D]h\}}|d|7}xJ|j�D]>}t|dd�rv||jj	|�7}qTt|dd�rT||jj
|�7}qTW|d7}q6Wx|j|�D]}|d|7}q�W|d	7}|S)
ziReturn a string of XML encoding this object's supported interfaces,
        methods and signals.
        z<node name="%s">
r^z  <interface name="%s">
r;FZ_dbus_is_signalz  </interface>
z  <node name="%s"/>
z</node>
)r(Z)DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODEr]r=rrr_rbrQrnroZlist_exported_child_objects)rr{rJrkZ
interfacesr/Zfuncsrfrrr�
Introspect�szObject.IntrospectcCs>d}|jtk	r"|jdk	r"d|j}d|jj|jj|t|�fS)NrOz at %sz<%s.%s%s at %#x>)rrr|r=rrr8)r�whererrrr9s


zObject.__repr__)NNN)NN)rrr r!r�r�r4�propertyr~rJr�ryr�r�r�rrr�r9r:rrrrrs
=;
1ncs&eZdZdZdZd�fdd�	Z�ZS)rzaAn object that implements an entire subtree of the object-path
    tree.

    :Since: 0.82.0
    TNcsPtt|�j�d|_|dkr.|dk	rLtd��n|dkr@td��n|j||�dS)aHConstructor.

        Note that the superclass' ``bus_name`` __init__ argument is not
        supported here.

        :Parameters:
            `conn` : dbus.connection.Connection or None
                The connection on which to export this object. If this is not
                None, an `object_path` must also be provided.

                If None, the object is not initially available on any
                Connection.

            `object_path` : str or None
                A D-Bus object path at which to make this Object available
                immediately. If this is not None, a `conn` must also be
                provided.

                This object will implements all object-paths in the subtree
                starting at this object-path, except where a more specific
                object has been added.
        TNz)If object_path is given, conn is requiredz)If conn is given, object_path is required)rcrr4rwrxry)rrzr{)r=rrr4#s

zFallbackObject.__init__)NN)rrr r!r�r4rprr)r=rrs)rrrrr).�__all__Z
__docformat__rRrFrurV�collectionsrr(Zdbusrr	r
rrr
rZdbus.decoratorsrrZdbus.exceptionsrrrZ
dbus.lowlevelrrrZdbus.proxiesrZdbus._compatrZ	getLoggerrGr*rrrBrNr[rmr\rqr|rrrrrr�<module>s6$
uBMPKMW�\���3��9__pycache__/_expat_introspect_parser.cpython-36.opt-1.pycnu�[���3

iR�V0
�@s4ddlmZddlmZGdd�de�Zdd�ZdS)�)�ParserCreate)�IntrospectionParserExceptionc@s0eZdZdZdd�Zdd�Zd	d
�Zdd�Zd
S)�_Parser�map�in_iface�	in_method�sigcCsi|_d|_d|_d|_dS)N�)rrrr)�self�r�0/usr/lib64/python3.6/_expat_introspect_parser.py�__init__sz_Parser.__init__cCs0tdd�}d|_|j|_|j|_|j|�|jS)NzUTF-8� T)rZbuffer_text�StartElementHandler�EndElementHandlerZParser)r
�data�parserrrr�parse%s

z
_Parser.parsecCsr|js"|jrn|dkrn|d|_nL|jr>|dkr>|d|_n0|jrn|dkrn|jdd�dkrn|j|d7_dS)N�	interface�name�method�arg�	direction�in�type)rr�getr)r
rZ
attributesrrrr-sz_Parser.StartElementHandlercCsT|jrP|jr|dkrd|_n2|jrP|dkrP|j|j|jd|j<d|_d|_dS)Nrr	r�.)rrrr)r
rrrrr8sz_Parser.EndElementHandlerN)rrrr)�__name__�
__module__�__qualname__�	__slots__r
rrrrrrrrs
rcCsFyt�j|�Stk
r@}ztd|j|f��WYdd}~XnXdS)a�Return a dict mapping ``interface.method`` strings to the
    concatenation of all their 'in' parameters, and mapping
    ``interface.signal`` strings to the concatenation of all their
    parameters.

    Example output::

        {
            'com.example.SignalEmitter.OneString': 's',
            'com.example.MethodImplementor.OneInt32Argument': 'i',
        }

    :Parameters:
        `data` : str
            The introspection XML. Must be an 8-bit string of UTF-8.
    z%s: %sN)rr�	Exceptionr�	__class__)r�errr�process_introspection_dataAsr$N)Zxml.parsers.expatrZdbus.exceptionsr�objectrr$rrrr�<module>s$PKMW�\�V`��
�

gi_service.pynu�[���"""Support code for implementing D-Bus services via PyGI."""

# Copyright (C) 2007 Collabora Ltd. <http://www.collabora.co.uk/>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

__all__ = ['ExportedGObject']

from gi.repository import GObject
import dbus.service

# The odd syntax used here is required so that the code is compatible with
# both Python 2 and Python 3.  It essentially creates a new class called
# ExportedGObject with a metaclass of ExportGObjectType and an __init__()
# function.
#
# Because GObject and `dbus.service.Object` both have custom metaclasses, the
# naive approach using simple multiple inheritance won't work. This class has
# `ExportedGObjectType` as its metaclass, which is sufficient to make it work
# correctly.

class ExportedGObjectType(GObject.GObject.__class__, dbus.service.InterfaceType):
    """A metaclass which inherits from both GObjectMeta and
    `dbus.service.InterfaceType`. Used as the metaclass for `ExportedGObject`.
    """
    def __init__(cls, name, bases, dct):
        GObject.GObject.__class__.__init__(cls, name, bases, dct)
        dbus.service.InterfaceType.__init__(cls, name, bases, dct)


def ExportedGObject__init__(self, conn=None, object_path=None, **kwargs):
    """Initialize an exported GObject.

    :Parameters:
        `conn` : dbus.connection.Connection
            The D-Bus connection or bus
        `object_path` : str
            The object path at which to register this object.
    :Keywords:
        `bus_name` : dbus.service.BusName
            A bus name to be held on behalf of this object, or None.
        `gobject_properties` : dict
            GObject properties to be set on the constructed object.

            Any unrecognised keyword arguments will also be interpreted
            as GObject properties.
        """
    bus_name = kwargs.pop('bus_name', None)
    gobject_properties = kwargs.pop('gobject_properties', None)

    if gobject_properties is not None:
        kwargs.update(gobject_properties)
    GObject.GObject.__init__(self, **kwargs)
    dbus.service.Object.__init__(self, conn=conn,
                                 object_path=object_path,
                                 bus_name=bus_name)

ExportedGObject__doc__ = 'A GObject which is exported on the D-Bus.'

ExportedGObject = ExportedGObjectType(
    'ExportedGObject',
    (GObject.GObject, dbus.service.Object),
    {'__init__': ExportedGObject__init__,
     '__doc__': ExportedGObject__doc__,
     })
PKNW�\G�AFFbus.pynu�[���# Copyright (C) 2007 Collabora Ltd. <http://www.collabora.co.uk/>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

__all__ = ('BusConnection',)
__docformat__ = 'reStructuredText'

import logging
import weakref

from _dbus_bindings import (
    BUS_DAEMON_IFACE, BUS_DAEMON_NAME, BUS_DAEMON_PATH, BUS_SESSION,
    BUS_STARTER, BUS_SYSTEM, DBUS_START_REPLY_ALREADY_RUNNING,
    DBUS_START_REPLY_SUCCESS, NAME_FLAG_ALLOW_REPLACEMENT,
    NAME_FLAG_DO_NOT_QUEUE, NAME_FLAG_REPLACE_EXISTING,
    RELEASE_NAME_REPLY_NON_EXISTENT, RELEASE_NAME_REPLY_NOT_OWNER,
    RELEASE_NAME_REPLY_RELEASED, REQUEST_NAME_REPLY_ALREADY_OWNER,
    REQUEST_NAME_REPLY_EXISTS, REQUEST_NAME_REPLY_IN_QUEUE,
    REQUEST_NAME_REPLY_PRIMARY_OWNER, validate_bus_name, validate_error_name,
    validate_interface_name, validate_member_name, validate_object_path)
from dbus.connection import Connection
from dbus.exceptions import DBusException
from dbus.lowlevel import HANDLER_RESULT_NOT_YET_HANDLED
from dbus._compat import is_py2


_NAME_OWNER_CHANGE_MATCH = ("type='signal',sender='%s',"
                            "interface='%s',member='NameOwnerChanged',"
                            "path='%s',arg0='%%s'"
                            % (BUS_DAEMON_NAME, BUS_DAEMON_IFACE,
                               BUS_DAEMON_PATH))
"""(_NAME_OWNER_CHANGE_MATCH % sender) matches relevant NameOwnerChange
messages"""

_NAME_HAS_NO_OWNER = 'org.freedesktop.DBus.Error.NameHasNoOwner'

_logger = logging.getLogger('dbus.bus')


class NameOwnerWatch(object):
    __slots__ = ('_match', '_pending_call')

    def __init__(self, bus_conn, bus_name, callback):
        validate_bus_name(bus_name)

        def signal_cb(owned, old_owner, new_owner):
            callback(new_owner)

        def error_cb(e):
            if e.get_dbus_name() == _NAME_HAS_NO_OWNER:
                callback('')
            else:
                logging.basicConfig()
                _logger.debug('GetNameOwner(%s) failed:', bus_name,
                              exc_info=(e.__class__, e, None))

        self._match = bus_conn.add_signal_receiver(signal_cb,
                                                   'NameOwnerChanged',
                                                   BUS_DAEMON_IFACE,
                                                   BUS_DAEMON_NAME,
                                                   BUS_DAEMON_PATH,
                                                   arg0=bus_name)
        keywords = {}
        if is_py2:
            keywords['utf8_strings'] = True
        self._pending_call = bus_conn.call_async(BUS_DAEMON_NAME,
                                                 BUS_DAEMON_PATH,
                                                 BUS_DAEMON_IFACE,
                                                 'GetNameOwner',
                                                 's', (bus_name,),
                                                 callback, error_cb,
                                                 **keywords)

    def cancel(self):
        if self._match is not None:
            self._match.remove()
        if self._pending_call is not None:
            self._pending_call.cancel()
        self._match = None
        self._pending_call = None


class BusConnection(Connection):
    """A connection to a D-Bus daemon that implements the
    ``org.freedesktop.DBus`` pseudo-service.

    :Since: 0.81.0
    """

    TYPE_SESSION    = BUS_SESSION
    """Represents a session bus (same as the global dbus.BUS_SESSION)"""

    TYPE_SYSTEM     = BUS_SYSTEM
    """Represents the system bus (same as the global dbus.BUS_SYSTEM)"""

    TYPE_STARTER = BUS_STARTER
    """Represents the bus that started this service by activation (same as
    the global dbus.BUS_STARTER)"""

    START_REPLY_SUCCESS = DBUS_START_REPLY_SUCCESS
    START_REPLY_ALREADY_RUNNING = DBUS_START_REPLY_ALREADY_RUNNING

    def __new__(cls, address_or_type=TYPE_SESSION, mainloop=None):
        bus = cls._new_for_bus(address_or_type, mainloop=mainloop)

        # _bus_names is used by dbus.service.BusName!
        bus._bus_names = weakref.WeakValueDictionary()

        bus._signal_sender_matches = {}
        """Map from SignalMatch to NameOwnerWatch."""

        return bus

    def add_signal_receiver(self, handler_function, signal_name=None,
                            dbus_interface=None, bus_name=None,
                            path=None, **keywords):
        named_service = keywords.pop('named_service', None)
        if named_service is not None:
            if bus_name is not None:
                raise TypeError('bus_name and named_service cannot both be '
                                'specified')
            bus_name = named_service
            from warnings import warn
            warn('Passing the named_service parameter to add_signal_receiver '
                 'by name is deprecated: please use positional parameters',
                 DeprecationWarning, stacklevel=2)

        match = super(BusConnection, self).add_signal_receiver(
                handler_function, signal_name, dbus_interface, bus_name,
                path, **keywords)

        if (bus_name is not None and bus_name != BUS_DAEMON_NAME):
            if bus_name[:1] == ':':
                def callback(new_owner):
                    if new_owner == '':
                        match.remove()
            else:
                callback = match.set_sender_name_owner
            watch = self.watch_name_owner(bus_name, callback)
            self._signal_sender_matches[match] = watch

        self.add_match_string(str(match))

        return match

    def _clean_up_signal_match(self, match):
        # The signals lock is no longer held here (it was in <= 0.81.0)
        self.remove_match_string_non_blocking(str(match))
        watch = self._signal_sender_matches.pop(match, None)
        if watch is not None:
            watch.cancel()

    def activate_name_owner(self, bus_name):
        if (bus_name is not None and bus_name[:1] != ':'
            and bus_name != BUS_DAEMON_NAME):
            try:
                return self.get_name_owner(bus_name)
            except DBusException as e:
                if e.get_dbus_name() != _NAME_HAS_NO_OWNER:
                    raise
                # else it doesn't exist: try to start it
                self.start_service_by_name(bus_name)
                return self.get_name_owner(bus_name)
        else:
            # already unique
            return bus_name

    def get_object(self, bus_name, object_path, introspect=True,
                   follow_name_owner_changes=False, **kwargs):
        """Return a local proxy for the given remote object.

        Method calls on the proxy are translated into method calls on the
        remote object.

        :Parameters:
            `bus_name` : str
                A bus name (either the unique name or a well-known name)
                of the application owning the object. The keyword argument
                named_service is a deprecated alias for this.
            `object_path` : str
                The object path of the desired object
            `introspect` : bool
                If true (default), attempt to introspect the remote
                object to find out supported methods and their signatures
            `follow_name_owner_changes` : bool
                If the object path is a well-known name and this parameter
                is false (default), resolve the well-known name to the unique
                name of its current owner and bind to that instead; if the
                ownership of the well-known name changes in future,
                keep communicating with the original owner.
                This is necessary if the D-Bus API used is stateful.

                If the object path is a well-known name and this parameter
                is true, whenever the well-known name changes ownership in
                future, bind to the new owner, if any.

                If the given object path is a unique name, this parameter
                has no effect.

        :Returns: a `dbus.proxies.ProxyObject`
        :Raises `DBusException`: if resolving the well-known name to a
            unique name fails
        """
        if follow_name_owner_changes:
            self._require_main_loop()   # we don't get the signals otherwise

        named_service = kwargs.pop('named_service', None)
        if named_service is not None:
            if bus_name is not None:
                raise TypeError('bus_name and named_service cannot both '
                                'be specified')
            from warnings import warn
            warn('Passing the named_service parameter to get_object by name '
                 'is deprecated: please use positional parameters',
                 DeprecationWarning, stacklevel=2)
            bus_name = named_service
        if kwargs:
            raise TypeError('get_object does not take these keyword '
                            'arguments: %s' % ', '.join(kwargs.keys()))

        return self.ProxyObjectClass(self, bus_name, object_path,
                                     introspect=introspect,
                                     follow_name_owner_changes=follow_name_owner_changes)

    def get_unix_user(self, bus_name):
        """Get the numeric uid of the process owning the given bus name.

        :Parameters:
            `bus_name` : str
                A bus name, either unique or well-known
        :Returns: a `dbus.UInt32`
        :Since: 0.80.0
        """
        validate_bus_name(bus_name)
        return self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH,
                                  BUS_DAEMON_IFACE, 'GetConnectionUnixUser',
                                  's', (bus_name,))

    def start_service_by_name(self, bus_name, flags=0):
        """Start a service which will implement the given bus name on this Bus.

        :Parameters:
            `bus_name` : str
                The well-known bus name to be activated.
            `flags` : dbus.UInt32
                Flags to pass to StartServiceByName (currently none are
                defined)

        :Returns: A tuple of 2 elements. The first is always True, the
            second is either START_REPLY_SUCCESS or
            START_REPLY_ALREADY_RUNNING.

        :Raises `DBusException`: if the service could not be started.
        :Since: 0.80.0
        """
        validate_bus_name(bus_name)
        return (True, self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH,
                                         BUS_DAEMON_IFACE,
                                         'StartServiceByName',
                                         'su', (bus_name, flags)))

    # XXX: it might be nice to signal IN_QUEUE, EXISTS by exception,
    # but this would not be backwards-compatible
    def request_name(self, name, flags=0):
        """Request a bus name.

        :Parameters:
            `name` : str
                The well-known name to be requested
            `flags` : dbus.UInt32
                A bitwise-OR of 0 or more of the flags
                `NAME_FLAG_ALLOW_REPLACEMENT`,
                `NAME_FLAG_REPLACE_EXISTING`
                and `NAME_FLAG_DO_NOT_QUEUE`
        :Returns: `REQUEST_NAME_REPLY_PRIMARY_OWNER`,
            `REQUEST_NAME_REPLY_IN_QUEUE`,
            `REQUEST_NAME_REPLY_EXISTS` or
            `REQUEST_NAME_REPLY_ALREADY_OWNER`
        :Raises `DBusException`: if the bus daemon cannot be contacted or
            returns an error.
        """
        validate_bus_name(name, allow_unique=False)
        return self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH,
                                  BUS_DAEMON_IFACE, 'RequestName',
                                  'su', (name, flags))

    def release_name(self, name):
        """Release a bus name.

        :Parameters:
            `name` : str
                The well-known name to be released
        :Returns: `RELEASE_NAME_REPLY_RELEASED`,
            `RELEASE_NAME_REPLY_NON_EXISTENT`
            or `RELEASE_NAME_REPLY_NOT_OWNER`
        :Raises `DBusException`: if the bus daemon cannot be contacted or
            returns an error.
        """
        validate_bus_name(name, allow_unique=False)
        return self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH,
                                  BUS_DAEMON_IFACE, 'ReleaseName',
                                  's', (name,))

    def list_names(self):
        """Return a list of all currently-owned names on the bus.

        :Returns: a dbus.Array of dbus.UTF8String
        :Since: 0.81.0
        """
        keywords = {}
        if is_py2:
            keywords['utf8_strings'] = True
        return self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH,
                                  BUS_DAEMON_IFACE, 'ListNames',
                                  '', (), **keywords)

    def list_activatable_names(self):
        """Return a list of all names that can be activated on the bus.

        :Returns: a dbus.Array of dbus.UTF8String
        :Since: 0.81.0
        """
        keywords = {}
        if is_py2:
            keywords['utf8_strings'] = True
        return self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH,
                                  BUS_DAEMON_IFACE, 'ListActivatableNames',
                                  '', (), **keywords)

    def get_name_owner(self, bus_name):
        """Return the unique connection name of the primary owner of the
        given name.

        :Raises `DBusException`: if the `bus_name` has no owner
        :Since: 0.81.0
        """
        keywords = {}
        if is_py2:
            keywords['utf8_strings'] = True
        validate_bus_name(bus_name, allow_unique=False)
        return self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH,
                                  BUS_DAEMON_IFACE, 'GetNameOwner',
                                  's', (bus_name,), **keywords)

    def watch_name_owner(self, bus_name, callback):
        """Watch the unique connection name of the primary owner of the
        given name.

        `callback` will be called with one argument, which is either the
        unique connection name, or the empty string (meaning the name is
        not owned).

        :Since: 0.81.0
        """
        return NameOwnerWatch(self, bus_name, callback)

    def name_has_owner(self, bus_name):
        """Return True iff the given bus name has an owner on this bus.

        :Parameters:
            `bus_name` : str
                The bus name to look up
        :Returns: a `bool`
        """
        return bool(self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH,
                                       BUS_DAEMON_IFACE, 'NameHasOwner',
                                       's', (bus_name,)))

    def add_match_string(self, rule):
        """Arrange for this application to receive messages on the bus that
        match the given rule. This version will block.

        :Parameters:
            `rule` : str
                The match rule
        :Raises `DBusException`: on error.
        :Since: 0.80.0
        """
        self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH,
                           BUS_DAEMON_IFACE, 'AddMatch', 's', (rule,))

    # FIXME: add an async success/error handler capability?
    # (and the same for remove_...)
    def add_match_string_non_blocking(self, rule):
        """Arrange for this application to receive messages on the bus that
        match the given rule. This version will not block, but any errors
        will be ignored.


        :Parameters:
            `rule` : str
                The match rule
        :Raises `DBusException`: on error.
        :Since: 0.80.0
        """
        self.call_async(BUS_DAEMON_NAME, BUS_DAEMON_PATH,
                        BUS_DAEMON_IFACE, 'AddMatch', 's', (rule,),
                        None, None)

    def remove_match_string(self, rule):
        """Arrange for this application to receive messages on the bus that
        match the given rule. This version will block.

        :Parameters:
            `rule` : str
                The match rule
        :Raises `DBusException`: on error.
        :Since: 0.80.0
        """
        self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH,
                           BUS_DAEMON_IFACE, 'RemoveMatch', 's', (rule,))

    def remove_match_string_non_blocking(self, rule):
        """Arrange for this application to receive messages on the bus that
        match the given rule. This version will not block, but any errors
        will be ignored.


        :Parameters:
            `rule` : str
                The match rule
        :Raises `DBusException`: on error.
        :Since: 0.80.0
        """
        self.call_async(BUS_DAEMON_NAME, BUS_DAEMON_PATH,
                        BUS_DAEMON_IFACE, 'RemoveMatch', 's', (rule,),
                        None, None)
PKNW�\=����__init__.pynu�[���"""\
Implements the public API for a D-Bus client. See the dbus.service module
to export objects or claim well-known names.

..
  for epydoc's benefit

:NewField SupportedUsage: Supported usage
:NewField Constructor: Constructor
"""

# Copyright (C) 2003, 2004, 2005, 2006 Red Hat Inc. <http://www.redhat.com/>
# Copyright (C) 2003 David Zeuthen
# Copyright (C) 2004 Rob Taylor
# Copyright (C) 2005, 2006 Collabora Ltd. <http://www.collabora.co.uk/>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

__all__ = [
           # from _dbus
           'Bus', 'SystemBus', 'SessionBus', 'StarterBus',

           # from proxies
           'Interface',

           # from _dbus_bindings
           'get_default_main_loop', 'set_default_main_loop',

           'validate_interface_name', 'validate_member_name',
           'validate_bus_name', 'validate_object_path',
           'validate_error_name',

           'BUS_DAEMON_NAME', 'BUS_DAEMON_PATH', 'BUS_DAEMON_IFACE',
           'LOCAL_PATH', 'LOCAL_IFACE', 'PEER_IFACE',
           'INTROSPECTABLE_IFACE', 'PROPERTIES_IFACE',

           'ObjectPath', 'ByteArray', 'Signature', 'Byte', 'Boolean',
           'Int16', 'UInt16', 'Int32', 'UInt32', 'Int64', 'UInt64',
           'Double', 'String', 'Array', 'Struct', 'Dictionary',

           # from exceptions
           'DBusException',
           'MissingErrorHandlerException', 'MissingReplyHandlerException',
           'ValidationException', 'IntrospectionParserException',
           'UnknownMethodException', 'NameExistsException',

           # submodules
           'service', 'mainloop', 'lowlevel'
           ]

from dbus._compat import is_py2
if is_py2:
    __all__.append('UTF8String')

__docformat__ = 'restructuredtext'

# OLPC Sugar compatibility
import dbus.exceptions as exceptions
import dbus.types as types

from _dbus_bindings import __version__
version = tuple(map(int, __version__.split('.')))

from _dbus_bindings import (
    get_default_main_loop, set_default_main_loop, validate_bus_name,
    validate_error_name, validate_interface_name, validate_member_name,
    validate_object_path)
from _dbus_bindings import (
    BUS_DAEMON_IFACE, BUS_DAEMON_NAME, BUS_DAEMON_PATH, INTROSPECTABLE_IFACE,
    LOCAL_IFACE, LOCAL_PATH, PEER_IFACE, PROPERTIES_IFACE)

from dbus.exceptions import (
    DBusException, IntrospectionParserException, MissingErrorHandlerException,
    MissingReplyHandlerException, NameExistsException, UnknownMethodException,
    ValidationException)
from _dbus_bindings import (
    Array, Boolean, Byte, ByteArray, Dictionary, Double, Int16, Int32, Int64,
    ObjectPath, Signature, String, Struct, UInt16, UInt32, UInt64)

if is_py2:
    from _dbus_bindings import UTF8String

from dbus._dbus import Bus, SystemBus, SessionBus, StarterBus
from dbus.proxies import Interface
PKNW�\����
_compat.pynu�[���# Python 2 / Python 3 compatibility helpers.

import sys

# In Python 2.6, sys.version_info is not a namedtuple, so we can't use
# sys.version_info.major.
is_py3 = (sys.version_info[0] == 3)
is_py2 = not is_py3
PKOW�\Q|��d"d"_dbus.pynu�[���"""Implementation for dbus.Bus. Not to be imported directly."""

# Copyright (C) 2003, 2004, 2005, 2006 Red Hat Inc. <http://www.redhat.com/>
# Copyright (C) 2003 David Zeuthen
# Copyright (C) 2004 Rob Taylor
# Copyright (C) 2005, 2006 Collabora Ltd. <http://www.collabora.co.uk/>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

from __future__ import generators

__all__ = ('Bus', 'SystemBus', 'SessionBus', 'StarterBus')
__docformat__ = 'reStructuredText'

from dbus.exceptions import DBusException
from _dbus_bindings import (
    BUS_DAEMON_IFACE, BUS_DAEMON_NAME, BUS_DAEMON_PATH, BUS_SESSION,
    BUS_STARTER, BUS_SYSTEM, DBUS_START_REPLY_ALREADY_RUNNING,
    DBUS_START_REPLY_SUCCESS, validate_bus_name,
    validate_interface_name, validate_member_name, validate_object_path)
from dbus.bus import BusConnection
from dbus.lowlevel import SignalMessage
from dbus._compat import is_py2

if is_py2:
    from _dbus_bindings import UTF8String


class Bus(BusConnection):
    """A connection to one of three possible standard buses, the SESSION,
    SYSTEM, or STARTER bus. This class manages shared connections to those
    buses.

    If you're trying to subclass `Bus`, you may be better off subclassing
    `BusConnection`, which doesn't have all this magic.
    """

    _shared_instances = {}

    def __new__(cls, bus_type=BusConnection.TYPE_SESSION, private=False,
                mainloop=None):
        """Constructor, returning an existing instance where appropriate.

        The returned instance is actually always an instance of `SessionBus`,
        `SystemBus` or `StarterBus`.

        :Parameters:
            `bus_type` : cls.TYPE_SESSION, cls.TYPE_SYSTEM or cls.TYPE_STARTER
                Connect to the appropriate bus
            `private` : bool
                If true, never return an existing shared instance, but instead
                return a private connection.

                :Deprecated: since 0.82.3. Use dbus.bus.BusConnection for
                    private connections.

            `mainloop` : dbus.mainloop.NativeMainLoop
                The main loop to use. The default is to use the default
                main loop if one has been set up, or raise an exception
                if none has been.
        :Changed: in dbus-python 0.80:
            converted from a wrapper around a Connection to a Connection
            subclass.
        """
        if (not private and bus_type in cls._shared_instances):
            return cls._shared_instances[bus_type]

        # this is a bit odd, but we create instances of the subtypes
        # so we can return the shared instances if someone tries to
        # construct one of them (otherwise we'd eg try and return an
        # instance of Bus from __new__ in SessionBus). why are there
        # three ways to construct this class? we just don't know.
        if bus_type == BUS_SESSION:
            subclass = SessionBus
        elif bus_type == BUS_SYSTEM:
            subclass = SystemBus
        elif bus_type == BUS_STARTER:
            subclass = StarterBus
        else:
            raise ValueError('invalid bus_type %s' % bus_type)

        bus = BusConnection.__new__(subclass, bus_type, mainloop=mainloop)

        bus._bus_type = bus_type

        if not private:
            cls._shared_instances[bus_type] = bus

        return bus

    def close(self):
        t = self._bus_type
        if self.__class__._shared_instances.get(t) is self:
            del self.__class__._shared_instances[t]
        super(Bus, self).close()

    def get_connection(self):
        """Return self, for backwards compatibility with earlier dbus-python
        versions where Bus was not a subclass of Connection.

        :Deprecated: since 0.80.0
        """
        return self
    _connection = property(get_connection, None, None,
                           """self._connection == self, for backwards
                           compatibility with earlier dbus-python versions
                           where Bus was not a subclass of Connection.""")

    def get_session(private=False):
        """Static method that returns a connection to the session bus.

        :Parameters:
            `private` : bool
                If true, do not return a shared connection.
        """
        return SessionBus(private=private)

    get_session = staticmethod(get_session)

    def get_system(private=False):
        """Static method that returns a connection to the system bus.

        :Parameters:
            `private` : bool
                If true, do not return a shared connection.
        """
        return SystemBus(private=private)

    get_system = staticmethod(get_system)


    def get_starter(private=False):
        """Static method that returns a connection to the starter bus.

        :Parameters:
            `private` : bool
                If true, do not return a shared connection.
        """
        return StarterBus(private=private)

    get_starter = staticmethod(get_starter)

    def __repr__(self):
        if self._bus_type == BUS_SESSION:
            name = 'session'
        elif self._bus_type == BUS_SYSTEM:
            name = 'system'
        elif self._bus_type == BUS_STARTER:
            name = 'starter'
        else:
            name = 'unknown bus type'

        return '<%s.%s (%s) at %#x>' % (self.__class__.__module__,
                                        self.__class__.__name__,
                                        name, id(self))
    __str__ = __repr__


# FIXME: Drop the subclasses here? I can't think why we'd ever want
# polymorphism
class SystemBus(Bus):
    """The system-wide message bus."""
    def __new__(cls, private=False, mainloop=None):
        """Return a connection to the system bus.

        :Parameters:
            `private` : bool
                If true, never return an existing shared instance, but instead
                return a private connection.
            `mainloop` : dbus.mainloop.NativeMainLoop
                The main loop to use. The default is to use the default
                main loop if one has been set up, or raise an exception
                if none has been.
        """
        return Bus.__new__(cls, Bus.TYPE_SYSTEM, mainloop=mainloop,
                           private=private)

class SessionBus(Bus):
    """The session (current login) message bus."""
    def __new__(cls, private=False, mainloop=None):
        """Return a connection to the session bus.

        :Parameters:
            `private` : bool
                If true, never return an existing shared instance, but instead
                return a private connection.
            `mainloop` : dbus.mainloop.NativeMainLoop
                The main loop to use. The default is to use the default
                main loop if one has been set up, or raise an exception
                if none has been.
        """
        return Bus.__new__(cls, Bus.TYPE_SESSION, private=private,
                           mainloop=mainloop)

class StarterBus(Bus):
    """The bus that activated this process (only valid if
    this process was launched by DBus activation).
    """
    def __new__(cls, private=False, mainloop=None):
        """Return a connection to the bus that activated this process.

        :Parameters:
            `private` : bool
                If true, never return an existing shared instance, but instead
                return a private connection.
            `mainloop` : dbus.mainloop.NativeMainLoop
                The main loop to use. The default is to use the default
                main loop if one has been set up, or raise an exception
                if none has been.
        """
        return Bus.__new__(cls, Bus.TYPE_STARTER, private=private,
                           mainloop=mainloop)
PKOW�\��ig;g;
decorators.pynu�[���"""Service-side D-Bus decorators."""

# Copyright (C) 2003, 2004, 2005, 2006 Red Hat Inc. <http://www.redhat.com/>
# Copyright (C) 2003 David Zeuthen
# Copyright (C) 2004 Rob Taylor
# Copyright (C) 2005, 2006 Collabora Ltd. <http://www.collabora.co.uk/>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

__all__ = ('method', 'signal')
__docformat__ = 'restructuredtext'

import inspect

from dbus import validate_interface_name, Signature, validate_member_name
from dbus.lowlevel import SignalMessage
from dbus.exceptions import DBusException
from dbus._compat import is_py2


def method(dbus_interface, in_signature=None, out_signature=None,
           async_callbacks=None,
           sender_keyword=None, path_keyword=None, destination_keyword=None,
           message_keyword=None, connection_keyword=None,
           byte_arrays=False,
           rel_path_keyword=None, **kwargs):
    """Factory for decorators used to mark methods of a `dbus.service.Object`
    to be exported on the D-Bus.

    The decorated method will be exported over D-Bus as the method of the
    same name on the given D-Bus interface.

    :Parameters:
        `dbus_interface` : str
            Name of a D-Bus interface
        `in_signature` : str or None
            If not None, the signature of the method parameters in the usual
            D-Bus notation
        `out_signature` : str or None
            If not None, the signature of the return value in the usual
            D-Bus notation
        `async_callbacks` : tuple containing (str,str), or None
            If None (default) the decorated method is expected to return
            values matching the `out_signature` as usual, or raise
            an exception on error. If not None, the following applies:

            `async_callbacks` contains the names of two keyword arguments to
            the decorated function, which will be used to provide a success
            callback and an error callback (in that order).

            When the decorated method is called via the D-Bus, its normal
            return value will be ignored; instead, a pair of callbacks are
            passed as keyword arguments, and the decorated method is
            expected to arrange for one of them to be called.

            On success the success callback must be called, passing the
            results of this method as positional parameters in the format
            given by the `out_signature`.

            On error the decorated method may either raise an exception
            before it returns, or arrange for the error callback to be
            called with an Exception instance as parameter.

        `sender_keyword` : str or None
            If not None, contains the name of a keyword argument to the
            decorated function, conventionally ``'sender'``. When the
            method is called, the sender's unique name will be passed as
            this keyword argument.

        `path_keyword` : str or None
            If not None (the default), the decorated method will receive
            the destination object path as a keyword argument with this
            name. Normally you already know the object path, but in the
            case of "fallback paths" you'll usually want to use the object
            path in the method's implementation.

            For fallback objects, `rel_path_keyword` (new in 0.82.2) is
            likely to be more useful.

            :Since: 0.80.0?

        `rel_path_keyword` : str or None
            If not None (the default), the decorated method will receive
            the destination object path, relative to the path at which the
            object was exported, as a keyword argument with this
            name. For non-fallback objects the relative path will always be
            '/'.

            :Since: 0.82.2

        `destination_keyword` : str or None
            If not None (the default), the decorated method will receive
            the destination bus name as a keyword argument with this name.
            Included for completeness - you shouldn't need this.

            :Since: 0.80.0?

        `message_keyword` : str or None
            If not None (the default), the decorated method will receive
            the `dbus.lowlevel.MethodCallMessage` as a keyword argument
            with this name.

            :Since: 0.80.0?

        `connection_keyword` : str or None
            If not None (the default), the decorated method will receive
            the `dbus.connection.Connection` as a keyword argument
            with this name. This is generally only useful for objects
            that are available on more than one connection.

            :Since: 0.82.0

        `utf8_strings` : bool
            If False (default), D-Bus strings are passed to the decorated
            method as objects of class dbus.String, a unicode subclass.

            If True, D-Bus strings are passed to the decorated method
            as objects of class dbus.UTF8String, a str subclass guaranteed
            to be encoded in UTF-8.

            This option does not affect object-paths and signatures, which
            are always 8-bit strings (str subclass) encoded in ASCII.

            :Since: 0.80.0

        `byte_arrays` : bool
            If False (default), a byte array will be passed to the decorated
            method as an `Array` (a list subclass) of `Byte` objects.

            If True, a byte array will be passed to the decorated method as
            a `ByteArray`, a str subclass. This is usually what you want,
            but is switched off by default to keep dbus-python's API
            consistent.

            :Since: 0.80.0
    """
    validate_interface_name(dbus_interface)

    def decorator(func):
        if hasattr(inspect, 'Signature'):
            args = []

            for arg in inspect.signature(func).parameters.values():
                if arg.kind in (inspect.Parameter.POSITIONAL_ONLY,
                        inspect.Parameter.POSITIONAL_OR_KEYWORD):
                    args.append(arg.name)
        else:
            args = inspect.getargspec(func)[0]

        args.pop(0)

        if async_callbacks:
            if type(async_callbacks) != tuple:
                raise TypeError('async_callbacks must be a tuple of (keyword for return callback, keyword for error callback)')
            if len(async_callbacks) != 2:
                raise ValueError('async_callbacks must be a tuple of (keyword for return callback, keyword for error callback)')
            args.remove(async_callbacks[0])
            args.remove(async_callbacks[1])

        if sender_keyword:
            args.remove(sender_keyword)
        if rel_path_keyword:
            args.remove(rel_path_keyword)
        if path_keyword:
            args.remove(path_keyword)
        if destination_keyword:
            args.remove(destination_keyword)
        if message_keyword:
            args.remove(message_keyword)
        if connection_keyword:
            args.remove(connection_keyword)

        if in_signature:
            in_sig = tuple(Signature(in_signature))

            if len(in_sig) > len(args):
                raise ValueError('input signature is longer than the number of arguments taken')
            elif len(in_sig) < len(args):
                raise ValueError('input signature is shorter than the number of arguments taken')

        func._dbus_is_method = True
        func._dbus_async_callbacks = async_callbacks
        func._dbus_interface = dbus_interface
        func._dbus_in_signature = in_signature
        func._dbus_out_signature = out_signature
        func._dbus_sender_keyword = sender_keyword
        func._dbus_path_keyword = path_keyword
        func._dbus_rel_path_keyword = rel_path_keyword
        func._dbus_destination_keyword = destination_keyword
        func._dbus_message_keyword = message_keyword
        func._dbus_connection_keyword = connection_keyword
        func._dbus_args = args
        func._dbus_get_args_options = dict(byte_arrays=byte_arrays)
        if is_py2:
            func._dbus_get_args_options['utf8_strings'] = kwargs.get(
                'utf8_strings', False)
        elif 'utf8_strings' in kwargs:
            raise TypeError("unexpected keyword argument 'utf8_strings'")
        return func

    return decorator


def signal(dbus_interface, signature=None, path_keyword=None,
           rel_path_keyword=None):
    """Factory for decorators used to mark methods of a `dbus.service.Object`
    to emit signals on the D-Bus.

    Whenever the decorated method is called in Python, after the method
    body is executed, a signal with the same name as the decorated method,
    with the given D-Bus interface, will be emitted from this object.

    :Parameters:
        `dbus_interface` : str
            The D-Bus interface whose signal is emitted
        `signature` : str
            The signature of the signal in the usual D-Bus notation

        `path_keyword` : str or None
            A keyword argument to the decorated method. If not None,
            that argument will not be emitted as an argument of
            the signal, and when the signal is emitted, it will appear
            to come from the object path given by the keyword argument.

            Note that when calling the decorated method, you must always
            pass in the object path as a keyword argument, not as a
            positional argument.

            This keyword argument cannot be used on objects where
            the class attribute ``SUPPORTS_MULTIPLE_OBJECT_PATHS`` is true.

            :Deprecated: since 0.82.0. Use `rel_path_keyword` instead.

        `rel_path_keyword` : str or None
            A keyword argument to the decorated method. If not None,
            that argument will not be emitted as an argument of
            the signal.

            When the signal is emitted, if the named keyword argument is given,
            the signal will appear to come from the object path obtained by
            appending the keyword argument to the object's object path.
            This is useful to implement "fallback objects" (objects which
            own an entire subtree of the object-path tree).

            If the object is available at more than one object-path on the
            same or different connections, the signal will be emitted at
            an appropriate object-path on each connection - for instance,
            if the object is exported at /abc on connection 1 and at
            /def and /x/y/z on connection 2, and the keyword argument is
            /foo, then signals will be emitted from /abc/foo and /def/foo
            on connection 1, and /x/y/z/foo on connection 2.

            :Since: 0.82.0
    """
    validate_interface_name(dbus_interface)

    if path_keyword is not None:
        from warnings import warn
        warn(DeprecationWarning('dbus.service.signal::path_keyword has been '
                                'deprecated since dbus-python 0.82.0, and '
                                'will not work on objects that support '
                                'multiple object paths'),
             DeprecationWarning, stacklevel=2)
        if rel_path_keyword is not None:
            raise TypeError('dbus.service.signal::path_keyword and '
                            'rel_path_keyword cannot both be used')

    def decorator(func):
        member_name = func.__name__
        validate_member_name(member_name)

        def emit_signal(self, *args, **keywords):
            abs_path = None
            if path_keyword is not None:
                if self.SUPPORTS_MULTIPLE_OBJECT_PATHS:
                    raise TypeError('path_keyword cannot be used on the '
                                    'signals of an object that supports '
                                    'multiple object paths')
                abs_path = keywords.pop(path_keyword, None)
                if (abs_path != self.__dbus_object_path__ and
                    not self.__dbus_object_path__.startswith(abs_path + '/')):
                    raise ValueError('Path %r is not below %r', abs_path,
                                     self.__dbus_object_path__)

            rel_path = None
            if rel_path_keyword is not None:
                rel_path = keywords.pop(rel_path_keyword, None)

            func(self, *args, **keywords)

            for location in self.locations:
                if abs_path is None:
                    # non-deprecated case
                    if rel_path is None or rel_path in ('/', ''):
                        object_path = location[1]
                    else:
                        # will be validated by SignalMessage ctor in a moment
                        object_path = location[1] + rel_path
                else:
                    object_path = abs_path

                message = SignalMessage(object_path,
                                                       dbus_interface,
                                                       member_name)
                message.append(signature=signature, *args)

                location[0].send_message(message)
        # end emit_signal

        args = inspect.getargspec(func)[0]
        args.pop(0)

        for keyword in rel_path_keyword, path_keyword:
            if keyword is not None:
                try:
                    args.remove(keyword)
                except ValueError:
                    raise ValueError('function has no argument "%s"' % keyword)

        if signature:
            sig = tuple(Signature(signature))

            if len(sig) > len(args):
                raise ValueError('signal signature is longer than the number of arguments provided')
            elif len(sig) < len(args):
                raise ValueError('signal signature is shorter than the number of arguments provided')

        emit_signal.__name__ = func.__name__
        emit_signal.__doc__ = func.__doc__
        emit_signal._dbus_is_signal = True
        emit_signal._dbus_interface = dbus_interface
        emit_signal._dbus_signature = signature
        emit_signal._dbus_args = args
        return emit_signal

    return decorator
PKOW�\W~ޯ	server.pynu�[���# Copyright (C) 2008 Openismus GmbH <http://openismus.com/>
# Copyright (C) 2008 Collabora Ltd. <http://www.collabora.co.uk/>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

__all__ = ('Server', )
__docformat__ = 'reStructuredText'

from _dbus_bindings import _Server
from dbus.connection import Connection

class Server(_Server):
    """An opaque object representing a server that listens for connections from
    other applications.

    This class is not useful to instantiate directly: you must subclass it and
    either extend the method connection_added, or append to the
    list on_connection_added.

    :Since: 0.83
    """

    def __new__(cls, address, connection_class=Connection,
        mainloop=None, auth_mechanisms=None):
        """Construct a new Server.

        :Parameters:
            `address` : str
                Listen on this address.
            `connection_class` : type
                When new connections come in, instantiate this subclass
                of dbus.connection.Connection to represent them.
                The default is Connection.
            `mainloop` : dbus.mainloop.NativeMainLoop or None
                The main loop with which to associate the new connections.
            `auth_mechanisms` : sequence of str
                Authentication mechanisms to allow. The default is to allow
                any authentication mechanism supported by ``libdbus``.
        """
        return super(Server, cls).__new__(cls, address, connection_class,
                mainloop, auth_mechanisms)

    def __init__(self, *args, **kwargs):

        self.__connections = {}

        self.on_connection_added = []
        """A list of callbacks to invoke when a connection is added.
        They receive two arguments: this Server and the new Connection."""

        self.on_connection_removed = []
        """A list of callbacks to invoke when a connection becomes
        disconnected. They receive two arguments: this Server and the removed
        Connection."""

    # This method name is hard-coded in _dbus_bindings._Server.
    # This is not public API.
    def _on_new_connection(self, conn):
        conn.call_on_disconnection(self.connection_removed)
        self.connection_added(conn)

    def connection_added(self, conn):
        """Respond to the creation of a new Connection.

        This base-class implementation just invokes the callbacks in
        the on_connection_added attribute.

        :Parameters:
            `conn` : dbus.connection.Connection
                A D-Bus connection which has just been added.

                The type of this parameter is whatever was passed
                to the Server constructor as the ``connection_class``.
        """
        if self.on_connection_added:
            for cb in self.on_connection_added:
                cb(conn)

    def connection_removed(self, conn):
        """Respond to the disconnection of a Connection.

        This base-class implementation just invokes the callbacks in
        the on_connection_removed attribute.

        :Parameters:
            `conn` : dbus.connection.Connection
                A D-Bus connection which has just become disconnected.

                The type of this parameter is whatever was passed
                to the Server constructor as the ``connection_class``.
        """
        if self.on_connection_removed:
            for cb in self.on_connection_removed:
                cb(conn)

    address      = property(_Server.get_address)
    id           = property(_Server.get_id)
    is_connected = property(_Server.get_is_connected)

PKOW�\������
service.pynu�[���# Copyright (C) 2003-2006 Red Hat Inc. <http://www.redhat.com/>
# Copyright (C) 2003 David Zeuthen
# Copyright (C) 2004 Rob Taylor
# Copyright (C) 2005-2006 Collabora Ltd. <http://www.collabora.co.uk/>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

__all__ = ('BusName', 'Object', 'FallbackObject', 'method', 'signal')
__docformat__ = 'restructuredtext'

import sys
import logging
import threading
import traceback
from collections import Sequence

import _dbus_bindings
from dbus import (
    INTROSPECTABLE_IFACE, ObjectPath, SessionBus, Signature, Struct,
    validate_bus_name, validate_object_path)
from dbus.decorators import method, signal
from dbus.exceptions import (
    DBusException, NameExistsException, UnknownMethodException)
from dbus.lowlevel import ErrorMessage, MethodReturnMessage, MethodCallMessage
from dbus.proxies import LOCAL_PATH
from dbus._compat import is_py2


_logger = logging.getLogger('dbus.service')


class _VariantSignature(object):
    """A fake method signature which, when iterated, yields an endless stream
    of 'v' characters representing variants (handy with zip()).

    It has no string representation.
    """
    def __iter__(self):
        """Return self."""
        return self

    def __next__(self):
        """Return 'v' whenever called."""
        return 'v'

    if is_py2:
        next = __next__


class BusName(object):
    """A base class for exporting your own Named Services across the Bus.

    When instantiated, objects of this class attempt to claim the given
    well-known name on the given bus for the current process. The name is
    released when the BusName object becomes unreferenced.

    If a well-known name is requested multiple times, multiple references
    to the same BusName object will be returned.

    Caveats
    -------
    - Assumes that named services are only ever requested using this class -
      if you request names from the bus directly, confusion may occur.
    - Does not handle queueing.
    """
    def __new__(cls, name, bus=None, allow_replacement=False , replace_existing=False, do_not_queue=False):
        """Constructor, which may either return an existing cached object
        or a new object.

        :Parameters:
            `name` : str
                The well-known name to be advertised
            `bus` : dbus.Bus
                A Bus on which this service will be advertised.

                Omitting this parameter or setting it to None has been
                deprecated since version 0.82.1. For backwards compatibility,
                if this is done, the global shared connection to the session
                bus will be used.

            `allow_replacement` : bool
                If True, other processes trying to claim the same well-known
                name will take precedence over this one.
            `replace_existing` : bool
                If True, this process can take over the well-known name
                from other processes already holding it.
            `do_not_queue` : bool
                If True, this service will not be placed in the queue of
                services waiting for the requested name if another service
                already holds it.
        """
        validate_bus_name(name, allow_well_known=True, allow_unique=False)

        # if necessary, get default bus (deprecated)
        if bus is None:
            import warnings
            warnings.warn('Omitting the "bus" parameter to '
                          'dbus.service.BusName.__init__ is deprecated',
                          DeprecationWarning, stacklevel=2)
            bus = SessionBus()

        # see if this name is already defined, return it if so
        # FIXME: accessing internals of Bus
        if name in bus._bus_names:
            return bus._bus_names[name]

        # otherwise register the name
        name_flags = (
            (allow_replacement and _dbus_bindings.NAME_FLAG_ALLOW_REPLACEMENT or 0) |
            (replace_existing and _dbus_bindings.NAME_FLAG_REPLACE_EXISTING or 0) |
            (do_not_queue and _dbus_bindings.NAME_FLAG_DO_NOT_QUEUE or 0))

        retval = bus.request_name(name, name_flags)

        # TODO: more intelligent tracking of bus name states?
        if retval == _dbus_bindings.REQUEST_NAME_REPLY_PRIMARY_OWNER:
            pass
        elif retval == _dbus_bindings.REQUEST_NAME_REPLY_IN_QUEUE:
            # queueing can happen by default, maybe we should
            # track this better or let the user know if they're
            # queued or not?
            pass
        elif retval == _dbus_bindings.REQUEST_NAME_REPLY_EXISTS:
            raise NameExistsException(name)
        elif retval == _dbus_bindings.REQUEST_NAME_REPLY_ALREADY_OWNER:
            # if this is a shared bus which is being used by someone
            # else in this process, this can happen legitimately
            pass
        else:
            raise RuntimeError('requesting bus name %s returned unexpected value %s' % (name, retval))

        # and create the object
        bus_name = object.__new__(cls)
        bus_name._bus = bus
        bus_name._name = name

        # cache instance (weak ref only)
        # FIXME: accessing Bus internals again
        bus._bus_names[name] = bus_name

        return bus_name

    # do nothing because this is called whether or not the bus name
    # object was retrieved from the cache or created new
    def __init__(self, *args, **keywords):
        pass

    # we can delete the low-level name here because these objects
    # are guaranteed to exist only once for each bus name
    def __del__(self):
        self._bus.release_name(self._name)
        pass

    def get_bus(self):
        """Get the Bus this Service is on"""
        return self._bus

    def get_name(self):
        """Get the name of this service"""
        return self._name

    def __repr__(self):
        return '<dbus.service.BusName %s on %r at %#x>' % (self._name, self._bus, id(self))
    __str__ = __repr__


def _method_lookup(self, method_name, dbus_interface):
    """Walks the Python MRO of the given class to find the method to invoke.

    Returns two methods, the one to call, and the one it inherits from which
    defines its D-Bus interface name, signature, and attributes.
    """
    parent_method = None
    candidate_class = None
    successful = False

    # split up the cases when we do and don't have an interface because the
    # latter is much simpler
    if dbus_interface:
        # search through the class hierarchy in python MRO order
        for cls in self.__class__.__mro__:
            # if we haven't got a candidate class yet, and we find a class with a
            # suitably named member, save this as a candidate class
            if (not candidate_class and method_name in cls.__dict__):
                if ("_dbus_is_method" in cls.__dict__[method_name].__dict__
                    and "_dbus_interface" in cls.__dict__[method_name].__dict__):
                    # however if it is annotated for a different interface
                    # than we are looking for, it cannot be a candidate
                    if cls.__dict__[method_name]._dbus_interface == dbus_interface:
                        candidate_class = cls
                        parent_method = cls.__dict__[method_name]
                        successful = True
                        break
                    else:
                        pass
                else:
                    candidate_class = cls

            # if we have a candidate class, carry on checking this and all
            # superclasses for a method annoated as a dbus method
            # on the correct interface
            if (candidate_class and method_name in cls.__dict__
                and "_dbus_is_method" in cls.__dict__[method_name].__dict__
                and "_dbus_interface" in cls.__dict__[method_name].__dict__
                and cls.__dict__[method_name]._dbus_interface == dbus_interface):
                # the candidate class has a dbus method on the correct interface,
                # or overrides a method that is, success!
                parent_method = cls.__dict__[method_name]
                successful = True
                break

    else:
        # simpler version of above
        for cls in self.__class__.__mro__:
            if (not candidate_class and method_name in cls.__dict__):
                candidate_class = cls

            if (candidate_class and method_name in cls.__dict__
                and "_dbus_is_method" in cls.__dict__[method_name].__dict__):
                parent_method = cls.__dict__[method_name]
                successful = True
                break

    if successful:
        return (candidate_class.__dict__[method_name], parent_method)
    else:
        if dbus_interface:
            raise UnknownMethodException('%s is not a valid method of interface %s' % (method_name, dbus_interface))
        else:
            raise UnknownMethodException('%s is not a valid method' % method_name)


def _method_reply_return(connection, message, method_name, signature, *retval):
    reply = MethodReturnMessage(message)
    try:
        reply.append(signature=signature, *retval)
    except Exception as e:
        logging.basicConfig()
        if signature is None:
            try:
                signature = reply.guess_signature(retval) + ' (guessed)'
            except Exception as e:
                _logger.error('Unable to guess signature for arguments %r: '
                              '%s: %s', retval, e.__class__, e)
                raise
        _logger.error('Unable to append %r to message with signature %s: '
                      '%s: %s', retval, signature, e.__class__, e)
        raise

    connection.send_message(reply)


def _method_reply_error(connection, message, exception):
    name = getattr(exception, '_dbus_error_name', None)

    if name is not None:
        pass
    elif getattr(exception, '__module__', '') in ('', '__main__'):
        name = 'org.freedesktop.DBus.Python.%s' % exception.__class__.__name__
    else:
        name = 'org.freedesktop.DBus.Python.%s.%s' % (exception.__module__, exception.__class__.__name__)

    et, ev, etb = sys.exc_info()
    if isinstance(exception, DBusException) and not exception.include_traceback:
        # We don't actually want the traceback anyway
        contents = exception.get_dbus_message()
    elif ev is exception:
        # The exception was actually thrown, so we can get a traceback
        contents = ''.join(traceback.format_exception(et, ev, etb))
    else:
        # We don't have any traceback for it, e.g.
        #   async_err_cb(MyException('Failed to badger the mushroom'))
        # see also https://bugs.freedesktop.org/show_bug.cgi?id=12403
        contents = ''.join(traceback.format_exception_only(exception.__class__,
            exception))
    reply = ErrorMessage(message, name, contents)

    connection.send_message(reply)


class InterfaceType(type):
    def __init__(cls, name, bases, dct):
        # these attributes are shared between all instances of the Interface
        # object, so this has to be a dictionary that maps class names to
        # the per-class introspection/interface data
        class_table = getattr(cls, '_dbus_class_table', {})
        cls._dbus_class_table = class_table
        interface_table = class_table[cls.__module__ + '.' + name] = {}

        # merge all the name -> method tables for all the interfaces
        # implemented by our base classes into our own
        for b in bases:
            base_name = b.__module__ + '.' + b.__name__
            if getattr(b, '_dbus_class_table', False):
                for (interface, method_table) in class_table[base_name].items():
                    our_method_table = interface_table.setdefault(interface, {})
                    our_method_table.update(method_table)

        # add in all the name -> method entries for our own methods/signals
        for func in dct.values():
            if getattr(func, '_dbus_interface', False):
                method_table = interface_table.setdefault(func._dbus_interface, {})
                method_table[func.__name__] = func

        super(InterfaceType, cls).__init__(name, bases, dct)

    # methods are different to signals, so we have two functions... :)
    def _reflect_on_method(cls, func):
        args = func._dbus_args

        if func._dbus_in_signature:
            # convert signature into a tuple so length refers to number of
            # types, not number of characters. the length is checked by
            # the decorator to make sure it matches the length of args.
            in_sig = tuple(Signature(func._dbus_in_signature))
        else:
            # magic iterator which returns as many v's as we need
            in_sig = _VariantSignature()

        if func._dbus_out_signature:
            out_sig = Signature(func._dbus_out_signature)
        else:
            # its tempting to default to Signature('v'), but
            # for methods that return nothing, providing incorrect
            # introspection data is worse than providing none at all
            out_sig = []

        reflection_data = '    <method name="%s">\n' % (func.__name__)
        for pair in zip(in_sig, args):
            reflection_data += '      <arg direction="in"  type="%s" name="%s" />\n' % pair
        for type in out_sig:
            reflection_data += '      <arg direction="out" type="%s" />\n' % type
        reflection_data += '    </method>\n'

        return reflection_data

    def _reflect_on_signal(cls, func):
        args = func._dbus_args

        if func._dbus_signature:
            # convert signature into a tuple so length refers to number of
            # types, not number of characters
            sig = tuple(Signature(func._dbus_signature))
        else:
            # magic iterator which returns as many v's as we need
            sig = _VariantSignature()

        reflection_data = '    <signal name="%s">\n' % (func.__name__)
        for pair in zip(sig, args):
            reflection_data = reflection_data + '      <arg type="%s" name="%s" />\n' % pair
        reflection_data = reflection_data + '    </signal>\n'

        return reflection_data


# Define Interface as an instance of the metaclass InterfaceType, in a way
# that is compatible across both Python 2 and Python 3.
Interface = InterfaceType('Interface', (object,), {})


#: A unique object used as the value of Object._object_path and
#: Object._connection if it's actually in more than one place
_MANY = object()

class Object(Interface):
    r"""A base class for exporting your own Objects across the Bus.

    Just inherit from Object and mark exported methods with the
    @\ `dbus.service.method` or @\ `dbus.service.signal` decorator.

    Example::

        class Example(dbus.service.object):
            def __init__(self, object_path):
                dbus.service.Object.__init__(self, dbus.SessionBus(), path)
                self._last_input = None

            @dbus.service.method(interface='com.example.Sample',
                                 in_signature='v', out_signature='s')
            def StringifyVariant(self, var):
                self.LastInputChanged(var)      # emits the signal
                return str(var)

            @dbus.service.signal(interface='com.example.Sample',
                                 signature='v')
            def LastInputChanged(self, var):
                # run just before the signal is actually emitted
                # just put "pass" if nothing should happen
                self._last_input = var

            @dbus.service.method(interface='com.example.Sample',
                                 in_signature='', out_signature='v')
            def GetLastInput(self):
                return self._last_input
    """

    #: If True, this object can be made available at more than one object path.
    #: If True but `SUPPORTS_MULTIPLE_CONNECTIONS` is False, the object may
    #: handle more than one object path, but they must all be on the same
    #: connection.
    SUPPORTS_MULTIPLE_OBJECT_PATHS = False

    #: If True, this object can be made available on more than one connection.
    #: If True but `SUPPORTS_MULTIPLE_OBJECT_PATHS` is False, the object must
    #: have the same object path on all its connections.
    SUPPORTS_MULTIPLE_CONNECTIONS = False

    def __init__(self, conn=None, object_path=None, bus_name=None):
        """Constructor. Either conn or bus_name is required; object_path
        is also required.

        :Parameters:
            `conn` : dbus.connection.Connection or None
                The connection on which to export this object.

                If None, use the Bus associated with the given ``bus_name``.
                If there is no ``bus_name`` either, the object is not
                initially available on any Connection.

                For backwards compatibility, if an instance of
                dbus.service.BusName is passed as the first parameter,
                this is equivalent to passing its associated Bus as
                ``conn``, and passing the BusName itself as ``bus_name``.

            `object_path` : str or None
                A D-Bus object path at which to make this Object available
                immediately. If this is not None, a `conn` or `bus_name` must
                also be provided.

            `bus_name` : dbus.service.BusName or None
                Represents a well-known name claimed by this process. A
                reference to the BusName object will be held by this
                Object, preventing the name from being released during this
                Object's lifetime (unless it's released manually).
        """
        if object_path is not None:
            validate_object_path(object_path)

        if isinstance(conn, BusName):
            # someone's using the old API; don't gratuitously break them
            bus_name = conn
            conn = bus_name.get_bus()
        elif conn is None:
            if bus_name is not None:
                # someone's using the old API but naming arguments, probably
                conn = bus_name.get_bus()

        #: Either an object path, None or _MANY
        self._object_path = None
        #: Either a dbus.connection.Connection, None or _MANY
        self._connection = None
        #: A list of tuples (Connection, object path, False) where the False
        #: is for future expansion (to support fallback paths)
        self._locations = []
        #: Lock protecting `_locations`, `_connection` and `_object_path`
        self._locations_lock = threading.Lock()

        #: True if this is a fallback object handling a whole subtree.
        self._fallback = False

        self._name = bus_name

        if conn is None and object_path is not None:
            raise TypeError('If object_path is given, either conn or bus_name '
                            'is required')
        if conn is not None and object_path is not None:
            self.add_to_connection(conn, object_path)

    @property
    def __dbus_object_path__(self):
        """The object-path at which this object is available.
        Access raises AttributeError if there is no object path, or more than
        one object path.

        Changed in 0.82.0: AttributeError can be raised.
        """
        if self._object_path is _MANY:
            raise AttributeError('Object %r has more than one object path: '
                                 'use Object.locations instead' % self)
        elif self._object_path is None:
            raise AttributeError('Object %r has no object path yet' % self)
        else:
            return self._object_path

    @property
    def connection(self):
        """The Connection on which this object is available.
        Access raises AttributeError if there is no Connection, or more than
        one Connection.

        Changed in 0.82.0: AttributeError can be raised.
        """
        if self._connection is _MANY:
            raise AttributeError('Object %r is on more than one Connection: '
                                 'use Object.locations instead' % self)
        elif self._connection is None:
            raise AttributeError('Object %r has no Connection yet' % self)
        else:
            return self._connection

    @property
    def locations(self):
        """An iterable over tuples representing locations at which this
        object is available.

        Each tuple has at least two items, but may have more in future
        versions of dbus-python, so do not rely on their exact length.
        The first two items are the dbus.connection.Connection and the object
        path.

        :Since: 0.82.0
        """
        return iter(self._locations)

    def add_to_connection(self, connection, path):
        """Make this object accessible via the given D-Bus connection and
        object path.

        :Parameters:
            `connection` : dbus.connection.Connection
                Export the object on this connection. If the class attribute
                SUPPORTS_MULTIPLE_CONNECTIONS is False (default), this object
                can only be made available on one connection; if the class
                attribute is set True by a subclass, the object can be made
                available on more than one connection.

            `path` : dbus.ObjectPath or other str
                Place the object at this object path. If the class attribute
                SUPPORTS_MULTIPLE_OBJECT_PATHS is False (default), this object
                can only be made available at one object path; if the class
                attribute is set True by a subclass, the object can be made
                available with more than one object path.

        :Raises ValueError: if the object's class attributes do not allow the
            object to be exported in the desired way.
        :Since: 0.82.0
        """
        if path == LOCAL_PATH:
            raise ValueError('Objects may not be exported on the reserved '
                             'path %s' % LOCAL_PATH)

        self._locations_lock.acquire()
        try:
            if (self._connection is not None and
                self._connection is not connection and
                not self.SUPPORTS_MULTIPLE_CONNECTIONS):
                raise ValueError('%r is already exported on '
                                 'connection %r' % (self, self._connection))

            if (self._object_path is not None and
                not self.SUPPORTS_MULTIPLE_OBJECT_PATHS and
                self._object_path != path):
                raise ValueError('%r is already exported at object '
                                 'path %s' % (self, self._object_path))

            connection._register_object_path(path, self._message_cb,
                                             self._unregister_cb,
                                             self._fallback)

            if self._connection is None:
                self._connection = connection
            elif self._connection is not connection:
                self._connection = _MANY

            if self._object_path is None:
                self._object_path = path
            elif self._object_path != path:
                self._object_path = _MANY

            self._locations.append((connection, path, self._fallback))
        finally:
            self._locations_lock.release()

    def remove_from_connection(self, connection=None, path=None):
        """Make this object inaccessible via the given D-Bus connection
        and object path. If no connection or path is specified,
        the object ceases to be accessible via any connection or path.

        :Parameters:
            `connection` : dbus.connection.Connection or None
                Only remove the object from this Connection. If None,
                remove from all Connections on which it's exported.
            `path` : dbus.ObjectPath or other str, or None
                Only remove the object from this object path. If None,
                remove from all object paths.
        :Raises LookupError:
            if the object was not exported on the requested connection
            or path, or (if both are None) was not exported at all.
        :Since: 0.81.1
        """
        self._locations_lock.acquire()
        try:
            if self._object_path is None or self._connection is None:
                raise LookupError('%r is not exported' % self)

            if connection is not None or path is not None:
                dropped = []
                for location in self._locations:
                    if ((connection is None or location[0] is connection) and
                        (path is None or location[1] == path)):
                        dropped.append(location)
            else:
                dropped = self._locations
                self._locations = []

            if not dropped:
                raise LookupError('%r is not exported at a location matching '
                                  '(%r,%r)' % (self, connection, path))

            for location in dropped:
                try:
                    location[0]._unregister_object_path(location[1])
                except LookupError:
                    pass
                if self._locations:
                    try:
                        self._locations.remove(location)
                    except ValueError:
                        pass
        finally:
            self._locations_lock.release()

    def _unregister_cb(self, connection):
        # there's not really enough information to do anything useful here
        _logger.info('Unregistering exported object %r from some path '
                     'on %r', self, connection)

    def _message_cb(self, connection, message):
        if not isinstance(message, MethodCallMessage):
            return

        try:
            # lookup candidate method and parent method
            method_name = message.get_member()
            interface_name = message.get_interface()
            (candidate_method, parent_method) = _method_lookup(self, method_name, interface_name)

            # set up method call parameters
            args = message.get_args_list(**parent_method._dbus_get_args_options)
            keywords = {}

            if parent_method._dbus_out_signature is not None:
                signature = Signature(parent_method._dbus_out_signature)
            else:
                signature = None

            # set up async callback functions
            if parent_method._dbus_async_callbacks:
                (return_callback, error_callback) = parent_method._dbus_async_callbacks
                keywords[return_callback] = lambda *retval: _method_reply_return(connection, message, method_name, signature, *retval)
                keywords[error_callback] = lambda exception: _method_reply_error(connection, message, exception)

            # include the sender etc. if desired
            if parent_method._dbus_sender_keyword:
                keywords[parent_method._dbus_sender_keyword] = message.get_sender()
            if parent_method._dbus_path_keyword:
                keywords[parent_method._dbus_path_keyword] = message.get_path()
            if parent_method._dbus_rel_path_keyword:
                path = message.get_path()
                rel_path = path
                for exp in self._locations:
                    # pathological case: if we're exported in two places,
                    # one of which is a subtree of the other, then pick the
                    # subtree by preference (i.e. minimize the length of
                    # rel_path)
                    if exp[0] is connection:
                        if path == exp[1]:
                            rel_path = '/'
                            break
                        if exp[1] == '/':
                            # we already have rel_path == path at the beginning
                            continue
                        if path.startswith(exp[1] + '/'):
                            # yes we're in this exported subtree
                            suffix = path[len(exp[1]):]
                            if len(suffix) < len(rel_path):
                                rel_path = suffix
                rel_path = ObjectPath(rel_path)
                keywords[parent_method._dbus_rel_path_keyword] = rel_path

            if parent_method._dbus_destination_keyword:
                keywords[parent_method._dbus_destination_keyword] = message.get_destination()
            if parent_method._dbus_message_keyword:
                keywords[parent_method._dbus_message_keyword] = message
            if parent_method._dbus_connection_keyword:
                keywords[parent_method._dbus_connection_keyword] = connection

            # call method
            retval = candidate_method(self, *args, **keywords)

            # we're done - the method has got callback functions to reply with
            if parent_method._dbus_async_callbacks:
                return

            # otherwise we send the return values in a reply. if we have a
            # signature, use it to turn the return value into a tuple as
            # appropriate
            if signature is not None:
                signature_tuple = tuple(signature)
                # if we have zero or one return values we want make a tuple
                # for the _method_reply_return function, otherwise we need
                # to check we're passing it a sequence
                if len(signature_tuple) == 0:
                    if retval == None:
                        retval = ()
                    else:
                        raise TypeError('%s has an empty output signature but did not return None' %
                            method_name)
                elif len(signature_tuple) == 1:
                    retval = (retval,)
                else:
                    if isinstance(retval, Sequence):
                        # multi-value signature, multi-value return... proceed
                        # unchanged
                        pass
                    else:
                        raise TypeError('%s has multiple output values in signature %s but did not return a sequence' %
                            (method_name, signature))

            # no signature, so just turn the return into a tuple and send it as normal
            else:
                if retval is None:
                    retval = ()
                elif (isinstance(retval, tuple)
                      and not isinstance(retval, Struct)):
                # If the return is a tuple that is not a Struct, we use it
                # as-is on the assumption that there are multiple return
                # values - this is the usual Python idiom. (fd.o #10174)
                    pass
                else:
                    retval = (retval,)

            _method_reply_return(connection, message, method_name, signature, *retval)
        except Exception as exception:
            # send error reply
            _method_reply_error(connection, message, exception)

    @method(INTROSPECTABLE_IFACE, in_signature='', out_signature='s',
            path_keyword='object_path', connection_keyword='connection')
    def Introspect(self, object_path, connection):
        """Return a string of XML encoding this object's supported interfaces,
        methods and signals.
        """
        reflection_data = _dbus_bindings.DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
        reflection_data += '<node name="%s">\n' % object_path

        interfaces = self._dbus_class_table[self.__class__.__module__ + '.' + self.__class__.__name__]
        for (name, funcs) in interfaces.items():
            reflection_data += '  <interface name="%s">\n' % (name)

            for func in funcs.values():
                if getattr(func, '_dbus_is_method', False):
                    reflection_data += self.__class__._reflect_on_method(func)
                elif getattr(func, '_dbus_is_signal', False):
                    reflection_data += self.__class__._reflect_on_signal(func)

            reflection_data += '  </interface>\n'

        for name in connection.list_exported_child_objects(object_path):
            reflection_data += '  <node name="%s"/>\n' % name

        reflection_data += '</node>\n'

        return reflection_data

    def __repr__(self):
        where = ''
        if (self._object_path is not _MANY
            and self._object_path is not None):
            where = ' at %s' % self._object_path
        return '<%s.%s%s at %#x>' % (self.__class__.__module__,
                                   self.__class__.__name__, where,
                                   id(self))
    __str__ = __repr__

class FallbackObject(Object):
    """An object that implements an entire subtree of the object-path
    tree.

    :Since: 0.82.0
    """

    SUPPORTS_MULTIPLE_OBJECT_PATHS = True

    def __init__(self, conn=None, object_path=None):
        """Constructor.

        Note that the superclass' ``bus_name`` __init__ argument is not
        supported here.

        :Parameters:
            `conn` : dbus.connection.Connection or None
                The connection on which to export this object. If this is not
                None, an `object_path` must also be provided.

                If None, the object is not initially available on any
                Connection.

            `object_path` : str or None
                A D-Bus object path at which to make this Object available
                immediately. If this is not None, a `conn` must also be
                provided.

                This object will implements all object-paths in the subtree
                starting at this object-path, except where a more specific
                object has been added.
        """
        super(FallbackObject, self).__init__()
        self._fallback = True

        if conn is None:
            if object_path is not None:
                raise TypeError('If object_path is given, conn is required')
        elif object_path is None:
            raise TypeError('If conn is given, object_path is required')
        else:
            self.add_to_connection(conn, object_path)
PKOW�\����0
0
_expat_introspect_parser.pynu�[���# Copyright (C) 2003, 2004, 2005, 2006 Red Hat Inc. <http://www.redhat.com/>
# Copyright (C) 2003 David Zeuthen
# Copyright (C) 2004 Rob Taylor
# Copyright (C) 2005, 2006 Collabora Ltd. <http://www.collabora.co.uk/>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

from xml.parsers.expat import ParserCreate
from dbus.exceptions import IntrospectionParserException

class _Parser(object):
    __slots__ = ('map', 'in_iface', 'in_method', 'sig')
    def __init__(self):
        self.map = {}
        self.in_iface = ''
        self.in_method = ''
        self.sig = ''

    def parse(self, data):
        parser = ParserCreate('UTF-8', ' ')
        parser.buffer_text = True
        parser.StartElementHandler = self.StartElementHandler
        parser.EndElementHandler = self.EndElementHandler
        parser.Parse(data)
        return self.map

    def StartElementHandler(self, name, attributes):
        if not self.in_iface:
            if (not self.in_method and name == 'interface'):
                self.in_iface = attributes['name']
        else:
            if (not self.in_method and name == 'method'):
                self.in_method = attributes['name']
            elif (self.in_method and name == 'arg'):
                if attributes.get('direction', 'in') == 'in':
                    self.sig += attributes['type']

    def EndElementHandler(self, name):
        if self.in_iface:
            if (not self.in_method and name == 'interface'):
                self.in_iface = ''
            elif (self.in_method and name == 'method'):
                self.map[self.in_iface + '.' + self.in_method] = self.sig
                self.in_method = ''
                self.sig = ''

def process_introspection_data(data):
    """Return a dict mapping ``interface.method`` strings to the
    concatenation of all their 'in' parameters, and mapping
    ``interface.signal`` strings to the concatenation of all their
    parameters.

    Example output::

        {
            'com.example.SignalEmitter.OneString': 's',
            'com.example.MethodImplementor.OneInt32Argument': 'i',
        }

    :Parameters:
        `data` : str
            The introspection XML. Must be an 8-bit string of UTF-8.
    """
    try:
        return _Parser().parse(data)
    except Exception as e:
        raise IntrospectionParserException('%s: %s' % (e.__class__, e))
PKOW�\�	�
types.pynu�[���__all__ = ['ObjectPath', 'ByteArray', 'Signature', 'Byte', 'Boolean',
           'Int16', 'UInt16', 'Int32', 'UInt32', 'Int64', 'UInt64',
           'Double', 'String', 'Array', 'Struct', 'Dictionary',
           'UnixFd']

from _dbus_bindings import (
    Array, Boolean, Byte, ByteArray, Dictionary, Double, Int16, Int32, Int64,
    ObjectPath, Signature, String, Struct, UInt16, UInt32, UInt64,
    UnixFd)

from dbus._compat import is_py2
if is_py2:
    from _dbus_bindings import UTF8String
    __all__.append('UTF8String')
PKOW�\���$11glib.pynu�[���# Copyright (C) 2004 Anders Carlsson
# Copyright (C) 2004, 2005, 2006 Red Hat Inc. <http://www.redhat.com/>
# Copyright (C) 2005, 2006 Collabora Ltd. <http://www.collabora.co.uk/>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

"""Deprecated module which sets the default GLib main context as the mainloop
implementation within D-Bus, as a side-effect of being imported!

This API is highly non-obvious, so instead of importing this module,
new programs which don't need pre-0.80 compatibility should use this
equivalent code::

    from dbus.mainloop.glib import DBusGMainLoop
    DBusGMainLoop(set_as_default=True)
"""
__docformat__ = 'restructuredtext'

from dbus.mainloop.glib import DBusGMainLoop, threads_init
from warnings import warn as _warn

init_threads = threads_init

DBusGMainLoop(set_as_default=True)

_warn(DeprecationWarning("""\
Importing dbus.glib to use the GLib main loop with dbus-python is deprecated.
Instead, use this sequence:

    from dbus.mainloop.glib import DBusGMainLoop

    DBusGMainLoop(set_as_default=True)
"""), DeprecationWarning, stacklevel=2)
PKOW�\��2J}l}l
connection.pynu�[���# Copyright (C) 2007 Collabora Ltd. <http://www.collabora.co.uk/>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

__all__ = ('Connection', 'SignalMatch')
__docformat__ = 'reStructuredText'

import logging
import threading
import weakref

from _dbus_bindings import (
    Connection as _Connection, LOCAL_IFACE, LOCAL_PATH, validate_bus_name,
    validate_interface_name, validate_member_name, validate_object_path)
from dbus.exceptions import DBusException
from dbus.lowlevel import (
    ErrorMessage, HANDLER_RESULT_NOT_YET_HANDLED, MethodCallMessage,
    MethodReturnMessage, SignalMessage)
from dbus.proxies import ProxyObject
from dbus._compat import is_py2, is_py3

if is_py3:
    from _dbus_bindings import String
else:
    from _dbus_bindings import UTF8String


_logger = logging.getLogger('dbus.connection')


def _noop(*args, **kwargs):
    pass


class SignalMatch(object):
    _slots = ['_sender_name_owner', '_member', '_interface', '_sender',
              '_path', '_handler', '_args_match', '_rule',
              '_byte_arrays', '_conn_weakref',
              '_destination_keyword', '_interface_keyword',
              '_message_keyword', '_member_keyword',
              '_sender_keyword', '_path_keyword', '_int_args_match']
    if is_py2:
        _slots.append('_utf8_strings')

    __slots__ = tuple(_slots)

    def __init__(self, conn, sender, object_path, dbus_interface,
                 member, handler, byte_arrays=False,
                 sender_keyword=None, path_keyword=None,
                 interface_keyword=None, member_keyword=None,
                 message_keyword=None, destination_keyword=None,
                 **kwargs):
        if member is not None:
            validate_member_name(member)
        if dbus_interface is not None:
            validate_interface_name(dbus_interface)
        if sender is not None:
            validate_bus_name(sender)
        if object_path is not None:
            validate_object_path(object_path)

        self._rule = None
        self._conn_weakref = weakref.ref(conn)
        self._sender = sender
        self._interface = dbus_interface
        self._member = member
        self._path = object_path
        self._handler = handler

        # if the connection is actually a bus, it's responsible for changing
        # this later
        self._sender_name_owner = sender

        if is_py2:
            self._utf8_strings = kwargs.pop('utf8_strings', False)
        elif 'utf8_strings' in kwargs:
            raise TypeError("unexpected keyword argument 'utf8_strings'")

        self._byte_arrays = byte_arrays
        self._sender_keyword = sender_keyword
        self._path_keyword = path_keyword
        self._member_keyword = member_keyword
        self._interface_keyword = interface_keyword
        self._message_keyword = message_keyword
        self._destination_keyword = destination_keyword

        self._args_match = kwargs
        if not kwargs:
            self._int_args_match = None
        else:
            self._int_args_match = {}
            for kwarg in kwargs:
                if not kwarg.startswith('arg'):
                    raise TypeError('SignalMatch: unknown keyword argument %s'
                                    % kwarg)
                try:
                    index = int(kwarg[3:])
                except ValueError:
                    raise TypeError('SignalMatch: unknown keyword argument %s'
                                    % kwarg)
                if index < 0 or index > 63:
                    raise TypeError('SignalMatch: arg match index must be in '
                                    'range(64), not %d' % index)
                self._int_args_match[index] = kwargs[kwarg]

    def __hash__(self):
        """SignalMatch objects are compared by identity."""
        return hash(id(self))

    def __eq__(self, other):
        """SignalMatch objects are compared by identity."""
        return self is other

    def __ne__(self, other):
        """SignalMatch objects are compared by identity."""
        return self is not other

    sender = property(lambda self: self._sender)

    def __str__(self):
        if self._rule is None:
            rule = ["type='signal'"]
            if self._sender is not None:
                rule.append("sender='%s'" % self._sender)
            if self._path is not None:
                rule.append("path='%s'" % self._path)
            if self._interface is not None:
                rule.append("interface='%s'" % self._interface)
            if self._member is not None:
                rule.append("member='%s'" % self._member)
            if self._int_args_match is not None:
                for index, value in self._int_args_match.items():
                    rule.append("arg%d='%s'" % (index, value))

            self._rule = ','.join(rule)

        return self._rule

    def __repr__(self):
        return ('<%s at %x "%s" on conn %r>'
                % (self.__class__, id(self), self._rule, self._conn_weakref()))

    def set_sender_name_owner(self, new_name):
        self._sender_name_owner = new_name

    def matches_removal_spec(self, sender, object_path,
                             dbus_interface, member, handler, **kwargs):
        if handler not in (None, self._handler):
            return False
        if sender != self._sender:
            return False
        if object_path != self._path:
            return False
        if dbus_interface != self._interface:
            return False
        if member != self._member:
            return False
        if kwargs != self._args_match:
            return False
        return True

    def maybe_handle_message(self, message):
        args = None

        # these haven't been checked yet by the match tree
        if self._sender_name_owner not in (None, message.get_sender()):
            return False
        if self._int_args_match is not None:
            # extracting args with utf8_strings and byte_arrays is less work
            kwargs = dict(byte_arrays=True)
            arg_type = (String if is_py3 else UTF8String)
            if is_py2:
                kwargs['utf8_strings'] = True
            args = message.get_args_list(**kwargs)
            for index, value in self._int_args_match.items():
                if (index >= len(args)
                    or not isinstance(args[index], arg_type)
                    or args[index] != value):
                    return False

        # these have likely already been checked by the match tree
        if self._member not in (None, message.get_member()):
            return False
        if self._interface not in (None, message.get_interface()):
            return False
        if self._path not in (None, message.get_path()):
            return False

        try:
            # minor optimization: if we already extracted the args with the
            # right calling convention to do the args match, don't bother
            # doing so again
            utf8_strings = (is_py2 and self._utf8_strings)
            if args is None or not utf8_strings or not self._byte_arrays:
                kwargs = dict(byte_arrays=self._byte_arrays)
                if is_py2:
                    kwargs['utf8_strings'] = self._utf8_strings
                args = message.get_args_list(**kwargs)
            kwargs = {}
            if self._sender_keyword is not None:
                kwargs[self._sender_keyword] = message.get_sender()
            if self._destination_keyword is not None:
                kwargs[self._destination_keyword] = message.get_destination()
            if self._path_keyword is not None:
                kwargs[self._path_keyword] = message.get_path()
            if self._member_keyword is not None:
                kwargs[self._member_keyword] = message.get_member()
            if self._interface_keyword is not None:
                kwargs[self._interface_keyword] = message.get_interface()
            if self._message_keyword is not None:
                kwargs[self._message_keyword] = message
            self._handler(*args, **kwargs)
        except:
            # basicConfig is a no-op if logging is already configured
            logging.basicConfig()
            _logger.error('Exception in handler for D-Bus signal:', exc_info=1)

        return True

    def remove(self):
        conn = self._conn_weakref()
        # do nothing if the connection has already vanished
        if conn is not None:
            conn.remove_signal_receiver(self, self._member,
                                        self._interface, self._sender,
                                        self._path,
                                        **self._args_match)


class Connection(_Connection):
    """A connection to another application. In this base class there is
    assumed to be no bus daemon.

    :Since: 0.81.0
    """

    ProxyObjectClass = ProxyObject

    def __init__(self, *args, **kwargs):
        super(Connection, self).__init__(*args, **kwargs)

        # this if-block is needed because shared bus connections can be
        # __init__'ed more than once
        if not hasattr(self, '_dbus_Connection_initialized'):
            self._dbus_Connection_initialized = 1

            self.__call_on_disconnection = []

            self._signal_recipients_by_object_path = {}
            """Map from object path to dict mapping dbus_interface to dict
            mapping member to list of SignalMatch objects."""

            self._signals_lock = threading.Lock()
            """Lock used to protect signal data structures"""

            self.add_message_filter(self.__class__._signal_func)

    def activate_name_owner(self, bus_name):
        """Return the unique name for the given bus name, activating it
        if necessary and possible.

        If the name is already unique or this connection is not to a
        bus daemon, just return it.

        :Returns: a bus name. If the given `bus_name` exists, the returned
            name identifies its current owner; otherwise the returned name
            does not exist.
        :Raises DBusException: if the implementation has failed
            to activate the given bus name.
        :Since: 0.81.0
        """
        return bus_name

    def get_object(self, bus_name=None, object_path=None, introspect=True,
                   **kwargs):
        """Return a local proxy for the given remote object.

        Method calls on the proxy are translated into method calls on the
        remote object.

        :Parameters:
            `bus_name` : str
                A bus name (either the unique name or a well-known name)
                of the application owning the object. The keyword argument
                named_service is a deprecated alias for this.
            `object_path` : str
                The object path of the desired object
            `introspect` : bool
                If true (default), attempt to introspect the remote
                object to find out supported methods and their signatures

        :Returns: a `dbus.proxies.ProxyObject`
        """
        named_service = kwargs.pop('named_service', None)
        if named_service is not None:
            if bus_name is not None:
                raise TypeError('bus_name and named_service cannot both '
                                'be specified')
            from warnings import warn
            warn('Passing the named_service parameter to get_object by name '
                 'is deprecated: please use positional parameters',
                 DeprecationWarning, stacklevel=2)
            bus_name = named_service
        if kwargs:
            raise TypeError('get_object does not take these keyword '
                            'arguments: %s' % ', '.join(kwargs.keys()))

        return self.ProxyObjectClass(self, bus_name, object_path,
                                     introspect=introspect)

    def add_signal_receiver(self, handler_function,
                                  signal_name=None,
                                  dbus_interface=None,
                                  bus_name=None,
                                  path=None,
                                  **keywords):
        """Arrange for the given function to be called when a signal matching
        the parameters is received.

        :Parameters:
            `handler_function` : callable
                The function to be called. Its positional arguments will
                be the arguments of the signal. By default it will receive
                no keyword arguments, but see the description of
                the optional keyword arguments below.
            `signal_name` : str
                The signal name; None (the default) matches all names
            `dbus_interface` : str
                The D-Bus interface name with which to qualify the signal;
                None (the default) matches all interface names
            `bus_name` : str
                A bus name for the sender, which will be resolved to a
                unique name if it is not already; None (the default) matches
                any sender.
            `path` : str
                The object path of the object which must have emitted the
                signal; None (the default) matches any object path
        :Keywords:
            `utf8_strings` : bool
                If True, the handler function will receive any string
                arguments as dbus.UTF8String objects (a subclass of str
                guaranteed to be UTF-8). If False (default) it will receive
                any string arguments as dbus.String objects (a subclass of
                unicode).
            `byte_arrays` : bool
                If True, the handler function will receive any byte-array
                arguments as dbus.ByteArray objects (a subclass of str).
                If False (default) it will receive any byte-array
                arguments as a dbus.Array of dbus.Byte (subclasses of:
                a list of ints).
            `sender_keyword` : str
                If not None (the default), the handler function will receive
                the unique name of the sending endpoint as a keyword
                argument with this name.
            `destination_keyword` : str
                If not None (the default), the handler function will receive
                the bus name of the destination (or None if the signal is a
                broadcast, as is usual) as a keyword argument with this name.
            `interface_keyword` : str
                If not None (the default), the handler function will receive
                the signal interface as a keyword argument with this name.
            `member_keyword` : str
                If not None (the default), the handler function will receive
                the signal name as a keyword argument with this name.
            `path_keyword` : str
                If not None (the default), the handler function will receive
                the object-path of the sending object as a keyword argument
                with this name.
            `message_keyword` : str
                If not None (the default), the handler function will receive
                the `dbus.lowlevel.SignalMessage` as a keyword argument with
                this name.
            `arg...` : unicode or UTF-8 str
                If there are additional keyword parameters of the form
                ``arg``\ *n*, match only signals where the *n*\ th argument
                is the value given for that keyword parameter. As of this
                time only string arguments can be matched (in particular,
                object paths and signatures can't).
            `named_service` : str
                A deprecated alias for `bus_name`.
        """
        self._require_main_loop()

        named_service = keywords.pop('named_service', None)
        if named_service is not None:
            if bus_name is not None:
                raise TypeError('bus_name and named_service cannot both be '
                                'specified')
            bus_name = named_service
            from warnings import warn
            warn('Passing the named_service parameter to add_signal_receiver '
                 'by name is deprecated: please use positional parameters',
                 DeprecationWarning, stacklevel=2)

        match = SignalMatch(self, bus_name, path, dbus_interface,
                            signal_name, handler_function, **keywords)

        self._signals_lock.acquire()
        try:
            by_interface = self._signal_recipients_by_object_path.setdefault(
                    path, {})
            by_member = by_interface.setdefault(dbus_interface, {})
            matches = by_member.setdefault(signal_name, [])

            matches.append(match)
        finally:
            self._signals_lock.release()

        return match

    def _iter_easy_matches(self, path, dbus_interface, member):
        if path is not None:
            path_keys = (None, path)
        else:
            path_keys = (None,)
        if dbus_interface is not None:
            interface_keys = (None, dbus_interface)
        else:
            interface_keys = (None,)
        if member is not None:
            member_keys = (None, member)
        else:
            member_keys = (None,)

        for path in path_keys:
            by_interface = self._signal_recipients_by_object_path.get(path)
            if by_interface is None:
                continue
            for dbus_interface in interface_keys:
                by_member = by_interface.get(dbus_interface, None)
                if by_member is None:
                    continue
                for member in member_keys:
                    matches = by_member.get(member, None)
                    if matches is None:
                        continue
                    for m in matches:
                        yield m

    def remove_signal_receiver(self, handler_or_match,
                               signal_name=None,
                               dbus_interface=None,
                               bus_name=None,
                               path=None,
                               **keywords):
        named_service = keywords.pop('named_service', None)
        if named_service is not None:
            if bus_name is not None:
                raise TypeError('bus_name and named_service cannot both be '
                                'specified')
            bus_name = named_service
            from warnings import warn
            warn('Passing the named_service parameter to '
                 'remove_signal_receiver by name is deprecated: please use '
                 'positional parameters',
                 DeprecationWarning, stacklevel=2)

        new = []
        deletions = []
        self._signals_lock.acquire()
        try:
            by_interface = self._signal_recipients_by_object_path.get(path,
                                                                      None)
            if by_interface is None:
                return
            by_member = by_interface.get(dbus_interface, None)
            if by_member is None:
                return
            matches = by_member.get(signal_name, None)
            if matches is None:
                return

            for match in matches:
                if (handler_or_match is match
                    or match.matches_removal_spec(bus_name,
                                                  path,
                                                  dbus_interface,
                                                  signal_name,
                                                  handler_or_match,
                                                  **keywords)):
                    deletions.append(match)
                else:
                    new.append(match)

            if new:
                by_member[signal_name] = new
            else:
                del by_member[signal_name]
                if not by_member:
                    del by_interface[dbus_interface]
                    if not by_interface:
                        del self._signal_recipients_by_object_path[path]
        finally:
            self._signals_lock.release()

        for match in deletions:
            self._clean_up_signal_match(match)

    def _clean_up_signal_match(self, match):
        # Now called without the signals lock held (it was held in <= 0.81.0)
        pass

    def _signal_func(self, message):
        """D-Bus filter function. Handle signals by dispatching to Python
        callbacks kept in the match-rule tree.
        """

        if not isinstance(message, SignalMessage):
            return HANDLER_RESULT_NOT_YET_HANDLED

        dbus_interface = message.get_interface()
        path = message.get_path()
        signal_name = message.get_member()

        for match in self._iter_easy_matches(path, dbus_interface,
                                             signal_name):
            match.maybe_handle_message(message)

        if (dbus_interface == LOCAL_IFACE and
            path == LOCAL_PATH and
            signal_name == 'Disconnected'):
            for cb in self.__call_on_disconnection:
                try:
                    cb(self)
                except Exception:
                    # basicConfig is a no-op if logging is already configured
                    logging.basicConfig()
                    _logger.error('Exception in handler for Disconnected '
                        'signal:', exc_info=1)

        return HANDLER_RESULT_NOT_YET_HANDLED

    def call_async(self, bus_name, object_path, dbus_interface, method,
                   signature, args, reply_handler, error_handler,
                   timeout=-1.0, byte_arrays=False,
                   require_main_loop=True, **kwargs):
        """Call the given method, asynchronously.

        If the reply_handler is None, successful replies will be ignored.
        If the error_handler is None, failures will be ignored. If both
        are None, the implementation may request that no reply is sent.

        :Returns: The dbus.lowlevel.PendingCall.
        :Since: 0.81.0
        """
        if object_path == LOCAL_PATH:
            raise DBusException('Methods may not be called on the reserved '
                                'path %s' % LOCAL_PATH)
        if dbus_interface == LOCAL_IFACE:
            raise DBusException('Methods may not be called on the reserved '
                                'interface %s' % LOCAL_IFACE)
        # no need to validate other args - MethodCallMessage ctor will do

        get_args_opts = dict(byte_arrays=byte_arrays)
        if is_py2:
            get_args_opts['utf8_strings'] = kwargs.get('utf8_strings', False)
        elif 'utf8_strings' in kwargs:
            raise TypeError("unexpected keyword argument 'utf8_strings'")

        message = MethodCallMessage(destination=bus_name,
                                    path=object_path,
                                    interface=dbus_interface,
                                    method=method)
        # Add the arguments to the function
        try:
            message.append(signature=signature, *args)
        except Exception as e:
            logging.basicConfig()
            _logger.error('Unable to set arguments %r according to '
                          'signature %r: %s: %s',
                          args, signature, e.__class__, e)
            raise

        if reply_handler is None and error_handler is None:
            # we don't care what happens, so just send it
            self.send_message(message)
            return

        if reply_handler is None:
            reply_handler = _noop
        if error_handler is None:
            error_handler = _noop

        def msg_reply_handler(message):
            if isinstance(message, MethodReturnMessage):
                reply_handler(*message.get_args_list(**get_args_opts))
            elif isinstance(message, ErrorMessage):
                error_handler(DBusException(name=message.get_error_name(),
                                            *message.get_args_list()))
            else:
                error_handler(TypeError('Unexpected type for reply '
                                        'message: %r' % message))
        return self.send_message_with_reply(message, msg_reply_handler,
                                        timeout,
                                        require_main_loop=require_main_loop)

    def call_blocking(self, bus_name, object_path, dbus_interface, method,
                      signature, args, timeout=-1.0,
                      byte_arrays=False, **kwargs):
        """Call the given method, synchronously.
        :Since: 0.81.0
        """
        if object_path == LOCAL_PATH:
            raise DBusException('Methods may not be called on the reserved '
                                'path %s' % LOCAL_PATH)
        if dbus_interface == LOCAL_IFACE:
            raise DBusException('Methods may not be called on the reserved '
                                'interface %s' % LOCAL_IFACE)
        # no need to validate other args - MethodCallMessage ctor will do

        get_args_opts = dict(byte_arrays=byte_arrays)
        if is_py2:
            get_args_opts['utf8_strings'] = kwargs.get('utf8_strings', False)
        elif 'utf8_strings' in kwargs:
            raise TypeError("unexpected keyword argument 'utf8_strings'")

        message = MethodCallMessage(destination=bus_name,
                                    path=object_path,
                                    interface=dbus_interface,
                                    method=method)
        # Add the arguments to the function
        try:
            message.append(signature=signature, *args)
        except Exception as e:
            logging.basicConfig()
            _logger.error('Unable to set arguments %r according to '
                          'signature %r: %s: %s',
                          args, signature, e.__class__, e)
            raise

        # make a blocking call
        reply_message = self.send_message_with_reply_and_block(
            message, timeout)
        args_list = reply_message.get_args_list(**get_args_opts)
        if len(args_list) == 0:
            return None
        elif len(args_list) == 1:
            return args_list[0]
        else:
            return tuple(args_list)

    def call_on_disconnection(self, callable):
        """Arrange for `callable` to be called with one argument (this
        Connection object) when the Connection becomes
        disconnected.

        :Since: 0.83.0
        """
        self.__call_on_disconnection.append(callable)
PKPW�\��Qnn.mainloop/__pycache__/glib.cpython-36.opt-1.pycnu�[���3

iR�V��@s(dZdZddlmZmZdadd�ZdS)	z.GLib main loop integration using libdbus-glib.�
DBusGMainLoop�threads_init�)r�
gthreads_initFcCstst�dadS)z�Initialize threads in dbus-glib, if this has not already been done.

    This must be called before creating a second thread in a program that
    uses this module.
    TN)�_dbus_gthreads_initializedr�rr�/usr/lib64/python3.6/glib.pyr sN)rr)�__doc__�__all__Z_dbus_glib_bindingsrrrrrrrr�<module>sPKPW�\�0���,mainloop/__pycache__/__init__.cpython-36.pycnu�[���3

iR�V 	�@s8dZddlZejZejZejZejZejZejZd
ZdS)z3Base definitions, etc. for main loop integration.

�N�NativeMainLoop�WATCH_READABLE�WATCH_WRITABLE�WATCH_HANGUP�WATCH_ERROR�NULL_MAIN_LOOP�glib)rrrrrrr)	�__doc__Z_dbus_bindingsrrrrrr�__all__�rr� /usr/lib64/python3.6/__init__.py�<module>sPKPW�\��Qnn(mainloop/__pycache__/glib.cpython-36.pycnu�[���3

iR�V��@s(dZdZddlmZmZdadd�ZdS)	z.GLib main loop integration using libdbus-glib.�
DBusGMainLoop�threads_init�)r�
gthreads_initFcCstst�dadS)z�Initialize threads in dbus-glib, if this has not already been done.

    This must be called before creating a second thread in a program that
    uses this module.
    TN)�_dbus_gthreads_initializedr�rr�/usr/lib64/python3.6/glib.pyr sN)rr)�__doc__�__all__Z_dbus_glib_bindingsrrrrrrrr�<module>sPKPW�\�0���2mainloop/__pycache__/__init__.cpython-36.opt-1.pycnu�[���3

iR�V 	�@s8dZddlZejZejZejZejZejZejZd
ZdS)z3Base definitions, etc. for main loop integration.

�N�NativeMainLoop�WATCH_READABLE�WATCH_WRITABLE�WATCH_HANGUP�WATCH_ERROR�NULL_MAIN_LOOP�glib)rrrrrrr)	�__doc__Z_dbus_bindingsrrrrrr�__all__�rr� /usr/lib64/python3.6/__init__.py�<module>sPKPW�\TP 	 	mainloop/__init__.pynu�[���# Copyright (C) 2006 Collabora Ltd. <http://www.collabora.co.uk/>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

"""Base definitions, etc. for main loop integration.

"""

import _dbus_bindings

NativeMainLoop = _dbus_bindings.NativeMainLoop

NULL_MAIN_LOOP = _dbus_bindings.NULL_MAIN_LOOP
"""A null mainloop which doesn't actually do anything.

For advanced users who want to dispatch events by hand. This is almost
certainly a bad idea - if in doubt, use the GLib main loop found in
`dbus.mainloop.glib`.
"""

WATCH_READABLE = _dbus_bindings.WATCH_READABLE
"""Represents a file descriptor becoming readable.
Used to implement file descriptor watches."""

WATCH_WRITABLE = _dbus_bindings.WATCH_WRITABLE
"""Represents a file descriptor becoming readable.
Used to implement file descriptor watches."""

WATCH_HANGUP = _dbus_bindings.WATCH_HANGUP
"""Represents a file descriptor reaching end-of-file.
Used to implement file descriptor watches."""

WATCH_ERROR = _dbus_bindings.WATCH_ERROR
"""Represents an error condition on a file descriptor.
Used to implement file descriptor watches."""

__all__ = (
           # Imported into this module
           'NativeMainLoop', 'WATCH_READABLE', 'WATCH_WRITABLE',
           'WATCH_HANGUP', 'WATCH_ERROR', 'NULL_MAIN_LOOP',

           # Submodules
           'glib'
           )
PKPW�\�����mainloop/glib.pynu�[���# Copyright (C) 2004 Anders Carlsson
# Copyright (C) 2004-2006 Red Hat Inc. <http://www.redhat.com/>
# Copyright (C) 2005-2006 Collabora Ltd. <http://www.collabora.co.uk/>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

"""GLib main loop integration using libdbus-glib."""

__all__ = ('DBusGMainLoop', 'threads_init')

from _dbus_glib_bindings import DBusGMainLoop, gthreads_init

_dbus_gthreads_initialized = False
def threads_init():
    """Initialize threads in dbus-glib, if this has not already been done.

    This must be called before creating a second thread in a program that
    uses this module.
    """
    global _dbus_gthreads_initialized
    if not _dbus_gthreads_initialized:
        gthreads_init()
        _dbus_gthreads_initialized = True
PKPW�\�k��''lowlevel.pynu�[���# Copyright (C) 2006 Collabora Ltd. <http://www.collabora.co.uk/>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

"""Low-level interface to D-Bus."""

__all__ = ('PendingCall', 'Message', 'MethodCallMessage',
           'MethodReturnMessage', 'ErrorMessage', 'SignalMessage',
           'HANDLER_RESULT_HANDLED', 'HANDLER_RESULT_NOT_YET_HANDLED',
           'MESSAGE_TYPE_INVALID', 'MESSAGE_TYPE_METHOD_CALL',
           'MESSAGE_TYPE_METHOD_RETURN', 'MESSAGE_TYPE_ERROR',
           'MESSAGE_TYPE_SIGNAL')

from _dbus_bindings import (
    ErrorMessage, HANDLER_RESULT_HANDLED, HANDLER_RESULT_NOT_YET_HANDLED,
    MESSAGE_TYPE_ERROR, MESSAGE_TYPE_INVALID, MESSAGE_TYPE_METHOD_CALL,
    MESSAGE_TYPE_METHOD_RETURN, MESSAGE_TYPE_SIGNAL, Message,
    MethodCallMessage, MethodReturnMessage, PendingCall, SignalMessage)
PKPW�\7Fa�BB
exceptions.pynu�[���"""D-Bus exceptions."""

# Copyright (C) 2007 Collabora Ltd. <http://www.collabora.co.uk/>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

__all__ = ('DBusException', 'MissingErrorHandlerException',
           'MissingReplyHandlerException', 'ValidationException',
           'IntrospectionParserException', 'UnknownMethodException',
           'NameExistsException')

from dbus._compat import is_py3


class DBusException(Exception):

    include_traceback = False
    """If True, tracebacks will be included in the exception message sent to
    D-Bus clients.

    Exceptions that are not DBusException subclasses always behave
    as though this is True. Set this to True on DBusException subclasses
    that represent a programming error, and leave it False on subclasses that
    represent an expected failure condition (e.g. a network server not
    responding)."""

    def __init__(self, *args, **kwargs):
        name = kwargs.pop('name', None)
        if name is not None or getattr(self, '_dbus_error_name', None) is None:
            self._dbus_error_name = name
        if kwargs:
            raise TypeError('DBusException does not take keyword arguments: %s'
                            % ', '.join(kwargs.keys()))
        Exception.__init__(self, *args)

    def __unicode__(self):
        """Return a unicode error"""
        # We can't just use Exception.__unicode__ because it chains up weirdly.
        # https://code.launchpad.net/~mvo/ubuntu/quantal/dbus-python/lp846044/+merge/129214
        if len(self.args) > 1:
            s = unicode(self.args)
        else:
            s = ''.join(self.args)

        if self._dbus_error_name is not None:
            return '%s: %s' % (self._dbus_error_name, s)
        else:
            return s

    def __str__(self):
        """Return a str error"""
        s = Exception.__str__(self)
        if self._dbus_error_name is not None:
            return '%s: %s' % (self._dbus_error_name, s)
        else:
            return s

    def get_dbus_message(self):
        if len(self.args) > 1:
            if is_py3:
                s = str(self.args)
            else:
                s = unicode(self.args)
        else:
            s = ''.join(self.args)

        if isinstance(s, bytes):
            return s.decode('utf-8', 'replace')

        return s

    def get_dbus_name(self):
        return self._dbus_error_name

class MissingErrorHandlerException(DBusException):

    include_traceback = True

    def __init__(self):
        DBusException.__init__(self, "error_handler not defined: if you define a reply_handler you must also define an error_handler")

class MissingReplyHandlerException(DBusException):

    include_traceback = True

    def __init__(self):
        DBusException.__init__(self, "reply_handler not defined: if you define an error_handler you must also define a reply_handler")

class ValidationException(DBusException):

    include_traceback = True

    def __init__(self, msg=''):
        DBusException.__init__(self, "Error validating string: %s"%msg)

class IntrospectionParserException(DBusException):

    include_traceback = True

    def __init__(self, msg=''):
        DBusException.__init__(self, "Error parsing introspect data: %s"%msg)

class UnknownMethodException(DBusException):

    include_traceback = True
    _dbus_error_name = 'org.freedesktop.DBus.Error.UnknownMethod'

    def __init__(self, method):
        DBusException.__init__(self, "Unknown method: %s"%method)

class NameExistsException(DBusException):

    include_traceback = True

    def __init__(self, name):
        DBusException.__init__(self, "Bus name already exists: %s"%name)
PKPW�\Z��`�`
proxies.pynu�[���# Copyright (C) 2003-2007 Red Hat Inc. <http://www.redhat.com/>
# Copyright (C) 2003 David Zeuthen
# Copyright (C) 2004 Rob Taylor
# Copyright (C) 2005-2007 Collabora Ltd. <http://www.collabora.co.uk/>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, sublicense, and/or sell copies
# of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

import logging

try:
    from threading import RLock
except ImportError:
    from dummy_threading import RLock

import _dbus_bindings
from dbus._expat_introspect_parser import process_introspection_data
from dbus.exceptions import (
    DBusException, IntrospectionParserException, MissingErrorHandlerException,
    MissingReplyHandlerException)

__docformat__ = 'restructuredtext'


_logger = logging.getLogger('dbus.proxies')

from _dbus_bindings import (
    BUS_DAEMON_IFACE, BUS_DAEMON_NAME, BUS_DAEMON_PATH, INTROSPECTABLE_IFACE,
    LOCAL_PATH)
from dbus._compat import is_py2


class _DeferredMethod:
    """A proxy method which will only get called once we have its
    introspection reply.
    """
    def __init__(self, proxy_method, append, block):
        self._proxy_method = proxy_method
        # the test suite relies on the existence of this property
        self._method_name = proxy_method._method_name
        self._append = append
        self._block = block

    def __call__(self, *args, **keywords):
        if ('reply_handler' in keywords or
            keywords.get('ignore_reply', False)):
            # defer the async call til introspection finishes
            self._append(self._proxy_method, args, keywords)
            return None
        else:
            # we're being synchronous, so block
            self._block()
            return self._proxy_method(*args, **keywords)

    def call_async(self, *args, **keywords):
        self._append(self._proxy_method, args, keywords)


class _ProxyMethod:
    """A proxy method.

    Typically a member of a ProxyObject. Calls to the
    method produce messages that travel over the Bus and are routed
    to a specific named Service.
    """
    def __init__(self, proxy, connection, bus_name, object_path, method_name,
                 iface):
        if object_path == LOCAL_PATH:
            raise DBusException('Methods may not be called on the reserved '
                                'path %s' % LOCAL_PATH)

        # trust that the proxy, and the properties it had, are OK
        self._proxy          = proxy
        self._connection     = connection
        self._named_service  = bus_name
        self._object_path    = object_path
        # fail early if the method name is bad
        _dbus_bindings.validate_member_name(method_name)
        # the test suite relies on the existence of this property
        self._method_name    = method_name
        # fail early if the interface name is bad
        if iface is not None:
            _dbus_bindings.validate_interface_name(iface)
        self._dbus_interface = iface

    def __call__(self, *args, **keywords):
        reply_handler = keywords.pop('reply_handler', None)
        error_handler = keywords.pop('error_handler', None)
        ignore_reply = keywords.pop('ignore_reply', False)
        signature = keywords.pop('signature', None)

        if reply_handler is not None or error_handler is not None:
            if reply_handler is None:
                raise MissingReplyHandlerException()
            elif error_handler is None:
                raise MissingErrorHandlerException()
            elif ignore_reply:
                raise TypeError('ignore_reply and reply_handler cannot be '
                                'used together')

        dbus_interface = keywords.pop('dbus_interface', self._dbus_interface)

        if signature is None:
            if dbus_interface is None:
                key = self._method_name
            else:
                key = dbus_interface + '.' + self._method_name

            signature = self._proxy._introspect_method_map.get(key, None)

        if ignore_reply or reply_handler is not None:
            self._connection.call_async(self._named_service,
                                        self._object_path,
                                        dbus_interface,
                                        self._method_name,
                                        signature,
                                        args,
                                        reply_handler,
                                        error_handler,
                                        **keywords)
        else:
            return self._connection.call_blocking(self._named_service,
                                                  self._object_path,
                                                  dbus_interface,
                                                  self._method_name,
                                                  signature,
                                                  args,
                                                  **keywords)

    def call_async(self, *args, **keywords):
        reply_handler = keywords.pop('reply_handler', None)
        error_handler = keywords.pop('error_handler', None)
        signature = keywords.pop('signature', None)

        dbus_interface = keywords.pop('dbus_interface', self._dbus_interface)

        if signature is None:
            if dbus_interface:
                key = dbus_interface + '.' + self._method_name
            else:
                key = self._method_name
            signature = self._proxy._introspect_method_map.get(key, None)

        self._connection.call_async(self._named_service,
                                    self._object_path,
                                    dbus_interface,
                                    self._method_name,
                                    signature,
                                    args,
                                    reply_handler,
                                    error_handler,
                                    **keywords)


class ProxyObject(object):
    """A proxy to the remote Object.

    A ProxyObject is provided by the Bus. ProxyObjects
    have member functions, and can be called like normal Python objects.
    """
    ProxyMethodClass = _ProxyMethod
    DeferredMethodClass = _DeferredMethod

    INTROSPECT_STATE_DONT_INTROSPECT = 0
    INTROSPECT_STATE_INTROSPECT_IN_PROGRESS = 1
    INTROSPECT_STATE_INTROSPECT_DONE = 2

    def __init__(self, conn=None, bus_name=None, object_path=None,
                 introspect=True, follow_name_owner_changes=False, **kwargs):
        """Initialize the proxy object.

        :Parameters:
            `conn` : `dbus.connection.Connection`
                The bus or connection on which to find this object.
                The keyword argument `bus` is a deprecated alias for this.
            `bus_name` : str
                A bus name for the application owning the object, to be used
                as the destination for method calls and the sender for
                signal matches. The keyword argument ``named_service`` is a
                deprecated alias for this.
            `object_path` : str
                The object path at which the application exports the object
            `introspect` : bool
                If true (default), attempt to introspect the remote
                object to find out supported methods and their signatures
            `follow_name_owner_changes` : bool
                If true (default is false) and the `bus_name` is a
                well-known name, follow ownership changes for that name
        """
        bus = kwargs.pop('bus', None)
        if bus is not None:
            if conn is not None:
                raise TypeError('conn and bus cannot both be specified')
            conn = bus
            from warnings import warn
            warn('Passing the bus parameter to ProxyObject by name is '
                 'deprecated: please use positional parameters',
                 DeprecationWarning, stacklevel=2)
        named_service = kwargs.pop('named_service', None)
        if named_service is not None:
            if bus_name is not None:
                raise TypeError('bus_name and named_service cannot both be '
                                'specified')
            bus_name = named_service
            from warnings import warn
            warn('Passing the named_service parameter to ProxyObject by name '
                 'is deprecated: please use positional parameters',
                 DeprecationWarning, stacklevel=2)
        if kwargs:
            raise TypeError('ProxyObject.__init__ does not take these '
                            'keyword arguments: %s'
                            % ', '.join(kwargs.keys()))

        if follow_name_owner_changes:
            # we don't get the signals unless the Bus has a main loop
            # XXX: using Bus internals
            conn._require_main_loop()

        self._bus = conn

        if bus_name is not None:
            _dbus_bindings.validate_bus_name(bus_name)
        # the attribute is still called _named_service for the moment,
        # for the benefit of telepathy-python
        self._named_service = self._requested_bus_name = bus_name

        _dbus_bindings.validate_object_path(object_path)
        self.__dbus_object_path__ = object_path

        if not follow_name_owner_changes:
            self._named_service = conn.activate_name_owner(bus_name)

        #PendingCall object for Introspect call
        self._pending_introspect = None
        #queue of async calls waiting on the Introspect to return
        self._pending_introspect_queue = []
        #dictionary mapping method names to their input signatures
        self._introspect_method_map = {}

        # must be a recursive lock because block() is called while locked,
        # and calls the callback which re-takes the lock
        self._introspect_lock = RLock()

        if not introspect or self.__dbus_object_path__ == LOCAL_PATH:
            self._introspect_state = self.INTROSPECT_STATE_DONT_INTROSPECT
        else:
            self._introspect_state = self.INTROSPECT_STATE_INTROSPECT_IN_PROGRESS

            self._pending_introspect = self._Introspect()

    bus_name = property(lambda self: self._named_service, None, None,
            """The bus name to which this proxy is bound. (Read-only,
            may change.)

            If the proxy was instantiated using a unique name, this property
            is that unique name.

            If the proxy was instantiated with a well-known name and with
            ``follow_name_owner_changes`` set false (the default), this
            property is the unique name of the connection that owned that
            well-known name when the proxy was instantiated, which might
            not actually own the requested well-known name any more.

            If the proxy was instantiated with a well-known name and with
            ``follow_name_owner_changes`` set true, this property is that
            well-known name.
            """)

    requested_bus_name = property(lambda self: self._requested_bus_name,
            None, None,
            """The bus name which was requested when this proxy was
            instantiated.
            """)

    object_path = property(lambda self: self.__dbus_object_path__,
            None, None,
            """The object-path of this proxy.""")

    # XXX: We don't currently support this because it's the signal receiver
    # that's responsible for tracking name owner changes, but it
    # seems a natural thing to add in future.
    #unique_bus_name = property(lambda self: something, None, None,
    #        """The unique name of the connection to which this proxy is
    #        currently bound. (Read-only, may change.)
    #        """)

    def connect_to_signal(self, signal_name, handler_function, dbus_interface=None, **keywords):
        """Arrange for the given function to be called when the given signal
        is received.

        :Parameters:
            `signal_name` : str
                The name of the signal
            `handler_function` : callable
                A function to be called when the signal is emitted by
                the remote object. Its positional arguments will be the
                arguments of the signal; optionally, it may be given
                keyword arguments as described below.
            `dbus_interface` : str
                Optional interface with which to qualify the signal name.
                If None (the default) the handler will be called whenever a
                signal of the given member name is received, whatever
                its interface.
        :Keywords:
            `utf8_strings` : bool
                If True, the handler function will receive any string
                arguments as dbus.UTF8String objects (a subclass of str
                guaranteed to be UTF-8). If False (default) it will receive
                any string arguments as dbus.String objects (a subclass of
                unicode).
            `byte_arrays` : bool
                If True, the handler function will receive any byte-array
                arguments as dbus.ByteArray objects (a subclass of str).
                If False (default) it will receive any byte-array
                arguments as a dbus.Array of dbus.Byte (subclasses of:
                a list of ints).
            `sender_keyword` : str
                If not None (the default), the handler function will receive
                the unique name of the sending endpoint as a keyword
                argument with this name
            `destination_keyword` : str
                If not None (the default), the handler function will receive
                the bus name of the destination (or None if the signal is a
                broadcast, as is usual) as a keyword argument with this name.
            `interface_keyword` : str
                If not None (the default), the handler function will receive
                the signal interface as a keyword argument with this name.
            `member_keyword` : str
                If not None (the default), the handler function will receive
                the signal name as a keyword argument with this name.
            `path_keyword` : str
                If not None (the default), the handler function will receive
                the object-path of the sending object as a keyword argument
                with this name
            `message_keyword` : str
                If not None (the default), the handler function will receive
                the `dbus.lowlevel.SignalMessage` as a keyword argument with
                this name.
            `arg...` : unicode or UTF-8 str
                If there are additional keyword parameters of the form
                ``arg``\ *n*, match only signals where the *n*\ th argument
                is the value given for that keyword parameter. As of this time
                only string arguments can be matched (in particular,
                object paths and signatures can't).
        """
        return \
        self._bus.add_signal_receiver(handler_function,
                                      signal_name=signal_name,
                                      dbus_interface=dbus_interface,
                                      bus_name=self._named_service,
                                      path=self.__dbus_object_path__,
                                      **keywords)

    def _Introspect(self):
        kwargs = {}
        if is_py2:
            kwargs['utf8_strings'] = True
        return self._bus.call_async(self._named_service,
                                    self.__dbus_object_path__,
                                    INTROSPECTABLE_IFACE, 'Introspect', '', (),
                                    self._introspect_reply_handler,
                                    self._introspect_error_handler,
                                    require_main_loop=False, **kwargs)

    def _introspect_execute_queue(self):
        # FIXME: potential to flood the bus
        # We should make sure mainloops all have idle handlers
        # and do one message per idle
        for (proxy_method, args, keywords) in self._pending_introspect_queue:
            proxy_method(*args, **keywords)
        self._pending_introspect_queue = []

    def _introspect_reply_handler(self, data):
        self._introspect_lock.acquire()
        try:
            try:
                self._introspect_method_map = process_introspection_data(data)
            except IntrospectionParserException as e:
                self._introspect_error_handler(e)
                return

            self._introspect_state = self.INTROSPECT_STATE_INTROSPECT_DONE
            self._pending_introspect = None
            self._introspect_execute_queue()
        finally:
            self._introspect_lock.release()

    def _introspect_error_handler(self, error):
        logging.basicConfig()
        _logger.error("Introspect error on %s:%s: %s.%s: %s",
                      self._named_service, self.__dbus_object_path__,
                      error.__class__.__module__, error.__class__.__name__,
                      error)
        self._introspect_lock.acquire()
        try:
            _logger.debug('Executing introspect queue due to error')
            self._introspect_state = self.INTROSPECT_STATE_DONT_INTROSPECT
            self._pending_introspect = None
            self._introspect_execute_queue()
        finally:
            self._introspect_lock.release()

    def _introspect_block(self):
        self._introspect_lock.acquire()
        try:
            if self._pending_introspect is not None:
                self._pending_introspect.block()
            # else someone still has a _DeferredMethod from before we
            # finished introspection: no need to do anything special any more
        finally:
            self._introspect_lock.release()

    def _introspect_add_to_queue(self, callback, args, kwargs):
        self._introspect_lock.acquire()
        try:
            if self._introspect_state == self.INTROSPECT_STATE_INTROSPECT_IN_PROGRESS:
                self._pending_introspect_queue.append((callback, args, kwargs))
            else:
                # someone still has a _DeferredMethod from before we
                # finished introspection
                callback(*args, **kwargs)
        finally:
            self._introspect_lock.release()

    def __getattr__(self, member):
        if member.startswith('__') and member.endswith('__'):
            raise AttributeError(member)
        else:
            return self.get_dbus_method(member)

    def get_dbus_method(self, member, dbus_interface=None):
        """Return a proxy method representing the given D-Bus method. The
        returned proxy method can be called in the usual way. For instance, ::

            proxy.get_dbus_method("Foo", dbus_interface='com.example.Bar')(123)

        is equivalent to::

            proxy.Foo(123, dbus_interface='com.example.Bar')

        or even::

            getattr(proxy, "Foo")(123, dbus_interface='com.example.Bar')

        However, using `get_dbus_method` is the only way to call D-Bus
        methods with certain awkward names - if the author of a service
        implements a method called ``connect_to_signal`` or even
        ``__getattr__``, you'll need to use `get_dbus_method` to call them.

        For services which follow the D-Bus convention of CamelCaseMethodNames
        this won't be a problem.
        """

        ret = self.ProxyMethodClass(self, self._bus,
                                    self._named_service,
                                    self.__dbus_object_path__, member,
                                    dbus_interface)

        # this can be done without taking the lock - the worst that can
        # happen is that we accidentally return a _DeferredMethod just after
        # finishing introspection, in which case _introspect_add_to_queue and
        # _introspect_block will do the right thing anyway
        if self._introspect_state == self.INTROSPECT_STATE_INTROSPECT_IN_PROGRESS:
            ret = self.DeferredMethodClass(ret, self._introspect_add_to_queue,
                                           self._introspect_block)

        return ret

    def __repr__(self):
        return '<ProxyObject wrapping %s %s %s at %#x>'%(
            self._bus, self._named_service, self.__dbus_object_path__, id(self))
    __str__ = __repr__


class Interface(object):
    """An interface into a remote object.

    An Interface can be used to wrap ProxyObjects
    so that calls can be routed to their correct
    D-Bus interface.
    """

    def __init__(self, object, dbus_interface):
        """Construct a proxy for the given interface on the given object.

        :Parameters:
            `object` : `dbus.proxies.ProxyObject` or `dbus.Interface`
                The remote object or another of its interfaces
            `dbus_interface` : str
                An interface the `object` implements
        """
        if isinstance(object, Interface):
            self._obj = object.proxy_object
        else:
            self._obj = object
        self._dbus_interface = dbus_interface

    object_path = property (lambda self: self._obj.object_path, None, None,
                            "The D-Bus object path of the underlying object")
    __dbus_object_path__ = object_path
    bus_name = property (lambda self: self._obj.bus_name, None, None,
                         "The bus name to which the underlying proxy object "
                         "is bound")
    requested_bus_name = property (lambda self: self._obj.requested_bus_name,
                                   None, None,
                                   "The bus name which was requested when the "
                                   "underlying object was created")
    proxy_object = property (lambda self: self._obj, None, None,
                             """The underlying proxy object""")
    dbus_interface = property (lambda self: self._dbus_interface, None, None,
                               """The D-Bus interface represented""")

    def connect_to_signal(self, signal_name, handler_function,
                          dbus_interface=None, **keywords):
        """Arrange for a function to be called when the given signal is
        emitted.

        The parameters and keyword arguments are the same as for
        `dbus.proxies.ProxyObject.connect_to_signal`, except that if
        `dbus_interface` is None (the default), the D-Bus interface that
        was passed to the `Interface` constructor is used.
        """
        if not dbus_interface:
            dbus_interface = self._dbus_interface

        return self._obj.connect_to_signal(signal_name, handler_function,
                                           dbus_interface, **keywords)

    def __getattr__(self, member):
        if member.startswith('__') and member.endswith('__'):
            raise AttributeError(member)
        else:
            return self._obj.get_dbus_method(member, self._dbus_interface)

    def get_dbus_method(self, member, dbus_interface=None):
        """Return a proxy method representing the given D-Bus method.

        This is the same as `dbus.proxies.ProxyObject.get_dbus_method`
        except that if `dbus_interface` is None (the default),
        the D-Bus interface that was passed to the `Interface` constructor
        is used.
        """
        if dbus_interface is None:
            dbus_interface = self._dbus_interface
        return self._obj.get_dbus_method(member, dbus_interface)

    def __repr__(self):
        return '<Interface %r implementing %r at %#x>'%(
        self._obj, self._dbus_interface, id(self))
    __str__ = __repr__
PKJW�\Ww�}I-I-%__pycache__/decorators.cpython-36.pycnu�[���PKKW�\$R�a
a
!�-__pycache__/server.cpython-36.pycnu�[���PKLW�\���ĭ� P;__pycache__/types.cpython-36.pycnu�[���PKLW�\��w��F�F%M>__pycache__/connection.cpython-36.pycnu�[���PKLW�\ܟ �yy%3�__pycache__/gi_service.cpython-36.pycnu�[���PKLW�\͑���(�__pycache__/_compat.cpython-36.opt-1.pycnu�[���PKLW�\$R�a
a
'�__pycache__/server.cpython-36.opt-1.pycnu�[���PKMW�\��h�� ͛__pycache__/_dbus.cpython-36.pycnu�[���PKMW�\Ϥ���U�U"�__pycache__/service.cpython-36.pycnu�[���PKMW�\ܟ �yy+�__pycache__/gi_service.cpython-36.opt-1.pycnu�[���PKMW�\�Y=��%�__pycache__/exceptions.cpython-36.pycnu�[���PKMW�\���rDrD"w&__pycache__/proxies.cpython-36.pycnu�[���PKMW�\@�l���%;k__pycache__/glib.cpython-36.opt-1.pycnu�[���PKMW�\���7��#mo__pycache__/lowlevel.cpython-36.pycnu�[���PKMW�\�O��#�r__pycache__/__init__.cpython-36.pycnu�[���PKMW�\@�l����{__pycache__/glib.cpython-36.pycnu�[���PKMW�\͑���"�__pycache__/_compat.cpython-36.pycnu�[���PKMW�\�Y=��+��__pycache__/exceptions.cpython-36.opt-1.pycnu�[���PKMW�\Ww�}I-I-+��__pycache__/decorators.cpython-36.opt-1.pycnu�[���PKMW�\��w��F�F+B�__pycache__/connection.cpython-36.opt-1.pycnu�[���PKMW�\h�,(;7;7$.__pycache__/bus.cpython-36.opt-1.pycnu�[���PKMW�\�O��)�<__pycache__/__init__.cpython-36.opt-1.pycnu�[���PKMW�\h�,(;7;7�E__pycache__/bus.cpython-36.pycnu�[���PKMW�\���rDrD(8}__pycache__/proxies.cpython-36.opt-1.pycnu�[���PKMW�\���ĭ�&�__pycache__/types.cpython-36.opt-1.pycnu�[���PKMW�\��h��&�__pycache__/_dbus.cpython-36.opt-1.pycnu�[���PKMW�\���7��).�__pycache__/lowlevel.cpython-36.opt-1.pycnu�[���PKMW�\���3��3^�__pycache__/_expat_introspect_parser.cpython-36.pycnu�[���PKMW�\Ϥ���U�U(W�__pycache__/service.cpython-36.opt-1.pycnu�[���PKMW�\���3��95D__pycache__/_expat_introspect_parser.cpython-36.opt-1.pycnu�[���PKMW�\�V`��
�

4Mgi_service.pynu�[���PKNW�\G�AFF[bus.pynu�[���PKNW�\=����H�__init__.pynu�[���PKNW�\����
w�_compat.pynu�[���PKOW�\Q|��d"d"��_dbus.pynu�[���PKOW�\��ig;g;
 �decorators.pynu�[���PKOW�\W~ޯ	�server.pynu�[���PKOW�\������

"service.pynu�[���PKOW�\����0
0
f�_expat_introspect_parser.pynu�[���PKOW�\�	�
�types.pynu�[���PKOW�\���$11*�glib.pynu�[���PKOW�\��2J}l}l
��connection.pynu�[���PKPW�\��Qnn.L1mainloop/__pycache__/glib.cpython-36.opt-1.pycnu�[���PKPW�\�0���,4mainloop/__pycache__/__init__.cpython-36.pycnu�[���PKPW�\��Qnn(,6mainloop/__pycache__/glib.cpython-36.pycnu�[���PKPW�\�0���2�8mainloop/__pycache__/__init__.cpython-36.opt-1.pycnu�[���PKPW�\TP 	 	;mainloop/__init__.pynu�[���PKPW�\�����pDmainloop/glib.pynu�[���PKPW�\�k��''�Klowlevel.pynu�[���PKPW�\7Fa�BB
�Rexceptions.pynu�[���PKPW�\Z��`�`
~eproxies.pynu�[���PK33���