o `+@sddlmZddlmZddlTgdZGdddZGdd d eZd d Zd#ddZ d#ddZ d#ddZ d#ddZ GdddZ GdddZGdddZGddde ZGdddeZd efd!d"Zd S)$)Union)warn)*) DBusAddressnew_method_callnew_method_return new_error new_signalMessageGenerator PropertiesIntrospectableDBusErrorResponsec@s*eZdZdZd ddZddZddZdS) raAThis identifies the object and interface a message is for. e.g. messages to display desktop notifications would have this address:: DBusAddress('/org/freedesktop/Notifications', bus_name='org.freedesktop.Notifications', interface='org.freedesktop.Notifications') NcCs||_||_||_dSN) object_pathbus_name interfaceselfrrrr2/usr/lib/python3/dist-packages/jeepney/wrappers.py__init__s zDBusAddress.__init__cCsdt|j|j|j|jS)Nz'{}({!r}, bus_name={!r}, interface={!r}))formattype__name__rrrrrrr__repr__ s  zDBusAddress.__repr__cCst||j|j|Sr)rrr)rrrrrwith_interface$szDBusAddress.with_interfaceNN)r __module__ __qualname____doc__rrrrrrrrs   rcseZdZdfdd ZZS) DBusObjectNcs t|||tddddS)Nz)Deprecated alias, use DBusAddress instead) stacklevel)superrrr __class__rrr(szDBusObject.__init__r)rrr r __classcell__rrr&rr"'sr"c Csttj|ddddidS)Nrr)flagsprotocol_version body_lengthserialfields)Header Endiannesslittle)msg_typerrr new_header,s r3NrcCszttj}|j|jtj<|jdurtd|j|jtj <|j dur(|j |jtj <||jtj <|dur8||jtj <t ||S)aConstruct a new method call message This is a relatively low-level method. In many cases, this will be called from a :class:`MessageGenerator` subclass which provides a more convenient API. :param DBusAddress remote_obj: The object to call a method on :param str method: The name of the method to call :param str signature: The DBus signature of the body data :param tuple body: Body data (i.e. method parameters) Nz3remote_obj.bus_name cannot be None for method calls)r3 MessageType method_callrr. HeaderFieldspathr ValueError destinationrmember signatureMessage) remote_objmethodr;bodyheaderrrrr0s      rcCs^ttj}|jj|jtj<|jjtj d}|dur ||jtj <|dur*||jtj <t ||S)zConstruct a new response message :param Message parent_msg: The method call this is a reply to :param str signature: The DBus signature of the body data :param tuple body: Body data N) r3r4 method_returnr@r-r.r6 reply_serialgetsenderr9r;r<) parent_msgr;r?r@rDrrrrIs    rcCsjttj}|jj|jtj<||jtj<|jj tj d}|dur&||jtj <|dur0||jtj <t ||S)zConstruct a new error response message :param Message parent_msg: The method call this is a reply to :param str error_name: The name of the error :param str signature: The DBus signature of the body data :param tuple body: Body data N)r3r4errorr@r-r.r6rB error_namerCrDr9r;r<)rErGr;r?r@rDrrrr Ys     r cCsbttj}|j|jtj<|jdurtd|j|jtj<||jtj <|dur,||jtj <t ||S)zConstruct a new signal message :param DBusAddress emitter: The object sending the signal :param str signal: The name of the signal :param str signature: The DBus signature of the body data :param tuple body: Body data Nz,emitter.interface cannot be None for signals) r3r4signalrr.r6r7rr8r:r;r<)emitterrHr;r?r@rrrr ks     r c@ eZdZdZddZddZdS)r zSubclass this to define the methods available on a DBus interface. jeepney.bindgen can automatically create subclasses using introspection. cCs||_||_dSr)rr)rrrrrrrs zMessageGenerator.__init__cCsdt|j|j|jS)Nz{}({!r}, bus_name={!r}))rrrrrrrrrrs zMessageGenerator.__repr__N)rrr r!rrrrrrr ~s r c@s(eZdZdZddZddZddZdS) ProxyBasezA proxy is an IO-aware wrapper around a MessageGenerator Calling methods on a proxy object will send a message and wait for the reply. This is a base class for proxy implementations in jeepney.io. cCs ||_dSr)_msggen)rmsggenrrrrs zProxyBase.__init__cCs:|dr t|t|j|d}t|r||St|)N__) startswithAttributeErrorgetattrrLcallable _method_call)ritemmake_msgrrr __getattr__s  zProxyBase.__getattr__cCstd)Nz#Needs to be implemented in subclass)NotImplementedError)rrUrrrrSszProxyBase._method_callN)rrr r!rrVrSrrrrrKs  rKc@s>eZdZdZdeeeffddZddZddZ d d Z d S) r zBuild messages for accessing object properties If a D-Bus object has multiple interfaces, each interface has its own set of properties. This uses the standard DBus interface ``org.freedesktop.DBus.Properties`` objcCs||_t|j|jdd|_dS)Nzorg.freedesktop.DBus.Properties)rr)rXrrrprops_if)rrXrrrrs  zProperties.__init__cCst|jdd|jj|fS)z$Get the value of the property *name*GetssrrYrXr)rnamerrrrCs  zProperties.getcCst|jdd|jjfS)z*Get all property values for this interfaceGetAllsr\rrrrget_alls zProperties.get_allcCst|jdd|jj|||ffS)z?Set the property *name* to *value* (with appropriate signature)Setssvr\)rr]r;valuerrrsets zProperties.setN) rrr r!rrr rrCr`rdrrrrr s  r c@seZdZdZddZdS)r z#org.freedesktop.DBus.IntrospectablecCs t|dS)z3Request D-Bus introspection XML for a remote object Introspect)rrrrrres zIntrospectable.IntrospectN)rrr rrerrrrr s r c@rJ)rz?Raised by proxy method calls when the reply is an error messagecCs|jjtj|_|j|_dSr)r@r.rCr6rGr]r?data)rmsgrrrrs zDBusErrorResponse.__init__cCsd|j|jS)Nz[{}] {})rr]rfrrrr__str__szDBusErrorResponse.__str__N)rrr r!rrhrrrrrs rrgcCs|jjtjkr t||jS)zGet the body of a message, raising DBusErrorResponse for error messages This is to be used with replies to method_call messages, which may be method_return or error. )r@ message_typer4rFrr?)rgrrr unwrap_msgsrj)Nr)typingrwarningsr low_level__all__rr"r3rrr r r rKr r Exceptionrr<rjrrrrs"