a ó z]žlã@sÜdZdZddlZddlZddlZddlmZmZm Z m Z m Z m Z m Z ddlmZddlmZmZmZmZmZddlmZddlmZmZeršdd lmZn dd lmZe d ¡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ú5/usr/lib64/python3.9/site-packages/dbus/connection.pyÚ_noop3src@sˆeZdZgd¢Zere d¡eeƒZddd„Zdd„Z d d „Z d d „Z e d d„ƒZ dd„Zdd„Zdd„Zdd„Zdd„Zdd„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 Ksd|durt|ƒ|dur t|ƒ|dur0t|ƒ|dur@t|ƒd|_t |¡|_||_||_ ||_ ||_ ||_ ||_ trŠ| dd¡|_nd|vrštdƒ‚||_||_| |_| |_| |_| |_| |_||_|sÖd|_nŠi|_|D]~}| d¡sútd|ƒ‚zt|dd…ƒ}Wn ty.td|ƒ‚Yn0|dksD|dkrPtd |ƒ‚|||j|<qàdS) NÚ utf8_stringsFú*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$rrrrr rrÚ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_keywordrÚkwargÚindexrrrÚ__init__Cs^  ÿÿ ÿzSignalMatch.__init__cCs tt|ƒƒS©z-SignalMatch objects are compared by identity.)ÚhashÚid©r9rrrÚ__hash__~szSignalMatch.__hash__cCs||uSrDr©r9ÚotherrrrÚ__eq__‚szSignalMatch.__eq__cCs||uSrDrrIrrrÚ__ne__†szSignalMatch.__ne__cCs|jSr)rrGrrrÚŠózSignalMatch.cCsº|jdur´dg}|jdur*| d|j¡|jdurD| d|j¡|jdur^| d|j¡|jdurx| d|j¡|jdur¨|j ¡D]\}}| d||f¡qŒd |¡|_|jS)Nz type='signal'z sender='%s'z path='%s'zinterface='%s'z member='%s'z arg%d='%s'ú,) r"rÚappendrrrr+ÚitemsÚjoin)r9ZrulerBÚvaluerrrÚ__str__Œs       zSignalMatch.__str__cCsd|jt|ƒ|j| ¡fS)Nz<%s at %x "%s" on conn %r>)Ú __class__rFr"r$rGrrrÚ__repr__ŸsÿzSignalMatch.__repr__cCs ||_dSr)r)r9Únew_namerrrÚset_sender_name_owner£sz!SignalMatch.set_sender_name_ownercKs\|d|jfvrdS||jkr dS||jkr.dS||jkrr?rrrrÚmatches_removal_spec¦s     z SignalMatch.matches_removal_speccCsúd}|jd| ¡fvrdS|jdur–tdd}tr6tnt}trFd|d<|jfi|¤Ž}|j  ¡D]4\}}|t |ƒksŽt |||ƒrŽ|||kr`dSq`|j d|  ¡fvr¬dS|jd| ¡fvrÂdS|jd| ¡fvrØdSzútoâ|j}|dusø|rø|js$t|jd}tr|j|d<|jfi|¤Ž}i}|jdurB| ¡||j<|jdur\| ¡||j<|jdurv| ¡||j<|jdur|  ¡||j<|jdurª| ¡||j<|jdurÀ|||j<|j|i|¤ŽWn"t ¡tjdddYn0dS)NFT©r@r-z&Exception in handler for D-Bus signal:é©Úexc_info) rZ get_senderr+ÚdictrrrrÚ get_args_listrQÚlenÚ isinstancerÚ get_memberrÚ get_interfacerÚget_pathr,r#r)r%Zget_destinationr*r(r&r'r ÚloggingÚ basicConfigÚ_loggerÚerror)r9ÚmessagerrZarg_typerBrSr-rrrÚmaybe_handle_message¶s^     ÿ þ          z SignalMatch.maybe_handle_messagecCs8| ¡}|dur4|j||j|j|j|jfi|j¤ŽdSr)r$Úremove_signal_receiverrrrrr!)r9r:rrrÚremoveðs þýzSignalMatch.remove)FNNNNNN)Ú__name__Ú __module__Ú __qualname__Z_slotsrrPÚtupleÚ __slots__rCrHrKrLÚpropertyr;rTrVrXrYrjrlrrrrr7s& ü ; :rcs~eZdZdZeZ‡fdd„Zdd„Zddd „Zdd d „Z d d „Z ddd„Z dd„Z dd„Z ddd„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 csNtt|ƒj|i|¤Žt|dƒsJd|_g|_i|_t ¡|_ |  |j j ¡dS)NÚ_dbus_Connection_initializedr[) ÚsuperrrCÚhasattrrsÚ"_Connection__call_on_disconnectionÚ!_signal_recipients_by_object_pathÚ threadingÚLockÚ _signals_lockZadd_message_filterrUÚ _signal_func)r9rr©rUrrrCs  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)r9Úbus_namerrrÚactivate_name_ownerszConnection.activate_name_ownerNTcKsn| dd¡}|durB|dur$tdƒ‚ddlm}|dtdd|}|r\td d  | ¡¡ƒ‚|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_serviceNú3bus_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)r4r5Úwarningsr‚ÚDeprecationWarningrRÚkeysÚProxyObjectClass)r9r}r<r†rrr‚rrrÚ get_object&s   þ ÿ ÿzConnection.get_objectc Ks¾| ¡| dd¡}|durJ|dur,tdƒ‚|}ddlm}|dtddt||||||fi|¤Ž} |j ¡z>|j   |i¡} |   |i¡} |   |g¡} |   | ¡W|j  ¡n |j  ¡0| 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`. rNr€rrzrPassing the named_service parameter to add_signal_receiver by name is deprecated: please use positional parametersrƒr„) Z_require_main_loopr4r5r‡r‚rˆrrzÚacquirerwÚ setdefaultrPÚrelease) r9Zhandler_functionÚ signal_namer=r}ÚpathÚkeywordsrr‚ÚmatchÚ by_interfaceÚ by_memberÚmatchesrrrÚadd_signal_receiverKs2G  þ ÿÿ ÿ   zConnection.add_signal_receiverc cs¶|durd|f}nd}|dur(d|f}nd}|dur>d|f}nd}|D]j}|j |¡}|dur`qF|D]J}| |d¡}|dur~qd|D]*}| |d¡} | durœq‚| D] } | Vq q‚qdqFdS)Nr)rwÚget) r9rr=r>Z path_keysZinterface_keysZ member_keysr“r”r•ÚmrrrÚ_iter_easy_matches¯s.      zConnection._iter_easy_matchescKsj| dd¡}|durB|dur$tdƒ‚|}ddlm}|dtddg} g} |j ¡zî|j |d¡} | dur|W|j  ¡dS|  |d¡} | dur W|j  ¡dS|  |d¡} | durÄW|j  ¡dS| D]<}||usî|j |||||fi|¤Žrú|   |¡qÈ|   |¡qÈ| r| | |<n | |=| s6| |=| s6|j|=W|j  ¡n |j  ¡0| D]}|  |¡qTdS)Nrr€rrzuPassing the named_service parameter to remove_signal_receiver by name is deprecated: please use positional parametersrƒr„) r4r5r‡r‚rˆrzrŒrwr—rŽrYrPÚ_clean_up_signal_match)r9Zhandler_or_matchrr=r}rr‘rr‚ÚnewZ deletionsr“r”r•r’rrrrkÌsj  ý ÿ ã  æ  éüûÿ    z!Connection.remove_signal_receivercCsdSrr)r9r’rrrršsz!Connection._clean_up_signal_matchc Cs¢t|tƒstS| ¡}| ¡}| ¡}| |||¡D]}| |¡q4|tkrž|t krž|dkrž|j D]:}z ||ƒWqbt yšt   ¡tjdddYqb0qbtS)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:r[r\)rarr rcrdrbr™rjrrrvÚ Exceptionrerfrgrh)r9rir=rrr’Úcbrrrr{ s. ÿ ÿþ   ÿzConnection._signal_funcçð¿Fc  s|tkrtdtƒ‚|tkr(tdtƒ‚t| d‰trH|  dd¡ˆd<nd| vrXtdƒ‚t||||d} z| j|d|iŽWnBt y¾}z*t   ¡t   d |||j|¡‚WYd }~n d }~00ˆd urÞˆd urÞ| | ¡d Sˆd urêt‰ˆd uröt‰‡‡‡fd d „}|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 ú1Methods may not be called on the reserved path %sú6Methods may not be called on the reserved interface %srZr-Fr.©Z destinationrZ interfaceÚmethodÚ signatureú.msg_reply_handler)Úrequire_main_loop)rr rr^rr—r5r rPrœrerfrgrhrUZ send_messagerZsend_message_with_reply)r9r}r<r=r¢r£rr©r§Útimeoutr@r«rriÚerªrr¦rÚ call_async)sL ÿÿ ý þ  þzConnection.call_asyncc  Ks|tkrtdtƒ‚|tkr(tdtƒ‚t|d} trH|  dd¡| d<nd| vrXtdƒ‚t||||d} z| j|d|iŽWnBt y¾} z*t   ¡t   d ||| j| ¡‚WYd } ~ n d } ~ 00| | |¡} | jfi| ¤Ž}t|ƒd krìd St|ƒd kr|d St|ƒSd S) zECall the given method, synchronously. :Since: 0.81.0 rŸr rZr-Fr.r¡r£r¤Nrr[)rr rr^rr—r5r rPrœrerfrgrhrUZ!send_message_with_reply_and_blockr_r`rp)r9r}r<r=r¢r£rr¬r@rr¨rir­Z reply_messageZ args_listrrrÚ call_blockingisFÿÿ ý þÿ zConnection.call_blockingcCs|j |¡dS)z©Arrange for `callable` to be called with one argument (this Connection object) when the Connection becomes disconnected. :Since: 0.83.0 N)rvrP)r9ÚcallablerrrÚcall_on_disconnection–sz Connection.call_on_disconnection)NNT)NNNN)NNNN)ržFT)ržF)rmrnroÚ__doc__rrŠrCr~r‹r–r™rkršr{r®r¯r±Ú __classcell__rrr|rrús2  &ü dü ; ý Aþ -r)"Ú__all__Z __docformat__rerxr2Z_dbus_bindingsrZ _Connectionrrrrrr Zdbus.exceptionsr Z dbus.lowlevelr r r rrZ dbus.proxiesrZ dbus._compatrrrrZ getLoggerrgrÚobjectrrrrrÚs"$    D