dbus-fast 2.45.1__cp311-cp311-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dbus-fast might be problematic. Click here for more details.
- dbus_fast/__init__.py +82 -0
- dbus_fast/__version__.py +10 -0
- dbus_fast/_private/__init__.py +1 -0
- dbus_fast/_private/_cython_compat.py +14 -0
- dbus_fast/_private/address.cpython-311-darwin.so +0 -0
- dbus_fast/_private/address.pxd +15 -0
- dbus_fast/_private/address.py +117 -0
- dbus_fast/_private/constants.py +20 -0
- dbus_fast/_private/marshaller.cpython-311-darwin.so +0 -0
- dbus_fast/_private/marshaller.pxd +110 -0
- dbus_fast/_private/marshaller.py +228 -0
- dbus_fast/_private/unmarshaller.cpython-311-darwin.so +0 -0
- dbus_fast/_private/unmarshaller.pxd +261 -0
- dbus_fast/_private/unmarshaller.py +902 -0
- dbus_fast/_private/util.py +176 -0
- dbus_fast/aio/__init__.py +5 -0
- dbus_fast/aio/message_bus.py +578 -0
- dbus_fast/aio/message_reader.cpython-311-darwin.so +0 -0
- dbus_fast/aio/message_reader.pxd +13 -0
- dbus_fast/aio/message_reader.py +49 -0
- dbus_fast/aio/proxy_object.py +207 -0
- dbus_fast/auth.py +126 -0
- dbus_fast/constants.py +152 -0
- dbus_fast/errors.py +84 -0
- dbus_fast/glib/__init__.py +3 -0
- dbus_fast/glib/message_bus.py +515 -0
- dbus_fast/glib/proxy_object.py +319 -0
- dbus_fast/introspection.py +683 -0
- dbus_fast/message.cpython-311-darwin.so +0 -0
- dbus_fast/message.pxd +76 -0
- dbus_fast/message.py +387 -0
- dbus_fast/message_bus.cpython-311-darwin.so +0 -0
- dbus_fast/message_bus.pxd +75 -0
- dbus_fast/message_bus.py +1310 -0
- dbus_fast/proxy_object.py +358 -0
- dbus_fast/py.typed +0 -0
- dbus_fast/send_reply.py +61 -0
- dbus_fast/service.cpython-311-darwin.so +0 -0
- dbus_fast/service.pxd +50 -0
- dbus_fast/service.py +686 -0
- dbus_fast/signature.cpython-311-darwin.so +0 -0
- dbus_fast/signature.pxd +31 -0
- dbus_fast/signature.py +481 -0
- dbus_fast/unpack.cpython-311-darwin.so +0 -0
- dbus_fast/unpack.pxd +13 -0
- dbus_fast/unpack.py +24 -0
- dbus_fast/validators.py +199 -0
- dbus_fast-2.45.1.dist-info/METADATA +263 -0
- dbus_fast-2.45.1.dist-info/RECORD +51 -0
- dbus_fast-2.45.1.dist-info/WHEEL +6 -0
- dbus_fast-2.45.1.dist-info/licenses/LICENSE +22 -0
dbus_fast/message.pxd
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""cdefs for message.py"""
|
|
2
|
+
|
|
3
|
+
import cython
|
|
4
|
+
|
|
5
|
+
from ._private.marshaller cimport Marshaller
|
|
6
|
+
from .signature cimport Variant, SignatureTree, SignatureType
|
|
7
|
+
|
|
8
|
+
cdef object ErrorType
|
|
9
|
+
cdef object MessageType
|
|
10
|
+
|
|
11
|
+
cdef object HEADER_PATH
|
|
12
|
+
cdef object HEADER_INTERFACE
|
|
13
|
+
cdef object HEADER_MEMBER
|
|
14
|
+
cdef object HEADER_ERROR_NAME
|
|
15
|
+
cdef object HEADER_REPLY_SERIAL
|
|
16
|
+
cdef object HEADER_DESTINATION
|
|
17
|
+
cdef object HEADER_SENDER
|
|
18
|
+
cdef object HEADER_SIGNATURE
|
|
19
|
+
cdef object HEADER_UNIX_FDS
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
cdef object LITTLE_ENDIAN
|
|
23
|
+
cdef object PROTOCOL_VERSION
|
|
24
|
+
|
|
25
|
+
cdef object MESSAGE_FLAG
|
|
26
|
+
cdef object MESSAGE_FLAG_NONE
|
|
27
|
+
cdef object MESSAGE_TYPE_METHOD_CALL
|
|
28
|
+
|
|
29
|
+
cdef SignatureTree SIGNATURE_TREE_G
|
|
30
|
+
cdef SignatureTree SIGNATURE_TREE_O
|
|
31
|
+
cdef SignatureTree SIGNATURE_TREE_S
|
|
32
|
+
cdef SignatureTree SIGNATURE_TREE_U
|
|
33
|
+
|
|
34
|
+
cdef get_signature_tree
|
|
35
|
+
|
|
36
|
+
cdef class Message:
|
|
37
|
+
|
|
38
|
+
cdef public object destination
|
|
39
|
+
cdef public object path
|
|
40
|
+
cdef public object interface
|
|
41
|
+
cdef public object member
|
|
42
|
+
cdef public object message_type
|
|
43
|
+
cdef public object flags
|
|
44
|
+
cdef public object error_name
|
|
45
|
+
cdef public unsigned int reply_serial
|
|
46
|
+
cdef public object sender
|
|
47
|
+
cdef public list unix_fds
|
|
48
|
+
cdef public str signature
|
|
49
|
+
cdef public SignatureTree signature_tree
|
|
50
|
+
cdef public object body
|
|
51
|
+
cdef public unsigned int serial
|
|
52
|
+
|
|
53
|
+
@cython.locals(
|
|
54
|
+
body_buffer=bytearray,
|
|
55
|
+
header_buffer=bytearray,
|
|
56
|
+
var=Variant
|
|
57
|
+
)
|
|
58
|
+
cpdef _marshall(self, bint negotiate_unix_fd)
|
|
59
|
+
|
|
60
|
+
cdef _fast_init(
|
|
61
|
+
self,
|
|
62
|
+
object destination,
|
|
63
|
+
object path,
|
|
64
|
+
object interface,
|
|
65
|
+
object member,
|
|
66
|
+
object message_type,
|
|
67
|
+
object flags,
|
|
68
|
+
object error_name,
|
|
69
|
+
unsigned int reply_serial,
|
|
70
|
+
object sender,
|
|
71
|
+
list unix_fds,
|
|
72
|
+
SignatureTree signature_tree,
|
|
73
|
+
object body,
|
|
74
|
+
unsigned int serial,
|
|
75
|
+
bint validate
|
|
76
|
+
)
|
dbus_fast/message.py
ADDED
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
from typing import Any, Optional, Union
|
|
2
|
+
|
|
3
|
+
from ._private.constants import LITTLE_ENDIAN, PROTOCOL_VERSION, HeaderField
|
|
4
|
+
from ._private.marshaller import Marshaller
|
|
5
|
+
from .constants import ErrorType, MessageFlag, MessageType
|
|
6
|
+
from .errors import InvalidMessageError
|
|
7
|
+
from .signature import SignatureTree, Variant, get_signature_tree
|
|
8
|
+
from .validators import (
|
|
9
|
+
assert_bus_name_valid,
|
|
10
|
+
assert_interface_name_valid,
|
|
11
|
+
assert_member_name_valid,
|
|
12
|
+
assert_object_path_valid,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
REQUIRED_FIELDS = {
|
|
16
|
+
MessageType.METHOD_CALL.value: ("path", "member"),
|
|
17
|
+
MessageType.SIGNAL.value: ("path", "member", "interface"),
|
|
18
|
+
MessageType.ERROR.value: ("error_name", "reply_serial"),
|
|
19
|
+
MessageType.METHOD_RETURN.value: ("reply_serial",),
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
HEADER_PATH = HeaderField.PATH.value
|
|
23
|
+
HEADER_INTERFACE = HeaderField.INTERFACE.value
|
|
24
|
+
HEADER_MEMBER = HeaderField.MEMBER.value
|
|
25
|
+
HEADER_ERROR_NAME = HeaderField.ERROR_NAME.value
|
|
26
|
+
HEADER_REPLY_SERIAL = HeaderField.REPLY_SERIAL.value
|
|
27
|
+
HEADER_DESTINATION = HeaderField.DESTINATION.value
|
|
28
|
+
HEADER_SIGNATURE = HeaderField.SIGNATURE.value
|
|
29
|
+
HEADER_UNIX_FDS = HeaderField.UNIX_FDS.value
|
|
30
|
+
|
|
31
|
+
MESSAGE_FLAG = MessageFlag
|
|
32
|
+
|
|
33
|
+
MESSAGE_FLAG_NONE = MessageFlag.NONE
|
|
34
|
+
MESSAGE_TYPE_METHOD_CALL = MessageType.METHOD_CALL
|
|
35
|
+
|
|
36
|
+
SIGNATURE_TREE_G = get_signature_tree("g")
|
|
37
|
+
SIGNATURE_TREE_O = get_signature_tree("o")
|
|
38
|
+
SIGNATURE_TREE_S = get_signature_tree("s")
|
|
39
|
+
SIGNATURE_TREE_U = get_signature_tree("u")
|
|
40
|
+
|
|
41
|
+
_int = int
|
|
42
|
+
_str = str
|
|
43
|
+
_bool = bool
|
|
44
|
+
_MessageType = MessageType
|
|
45
|
+
_MessageFlag = MessageFlag
|
|
46
|
+
_list = list
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class Message:
|
|
50
|
+
"""A class for sending and receiving messages through the
|
|
51
|
+
:class:`MessageBus <dbus_fast.message_bus.BaseMessageBus>` with the
|
|
52
|
+
low-level api.
|
|
53
|
+
|
|
54
|
+
A ``Message`` can be constructed by the user to send over the message bus.
|
|
55
|
+
When messages are received, such as from method calls or signal emissions,
|
|
56
|
+
they will use this class as well.
|
|
57
|
+
|
|
58
|
+
:ivar destination: The address of the client for which this message is intended.
|
|
59
|
+
:vartype destination: str
|
|
60
|
+
:ivar path: The intended object path exported on the destination bus.
|
|
61
|
+
:vartype path: str
|
|
62
|
+
:ivar interface: The intended interface on the object path.
|
|
63
|
+
:vartype interface: str
|
|
64
|
+
:ivar member: The intended member on the interface.
|
|
65
|
+
:vartype member: str
|
|
66
|
+
:ivar message_type: The type of this message. A method call, signal, method return, or error.
|
|
67
|
+
:vartype message_type: :class:`MessageType`
|
|
68
|
+
:ivar flags: Flags that affect the behavior of this message.
|
|
69
|
+
:vartype flags: :class:`MessageFlag`
|
|
70
|
+
:ivar error_name: If this message is an error, the name of this error. Must be a valid interface name.
|
|
71
|
+
:vartype error_name: str
|
|
72
|
+
:ivar reply_serial: If this is a return type, the serial this message is in reply to.
|
|
73
|
+
:vartype reply_serial: int
|
|
74
|
+
:ivar sender: The address of the sender of this message. Will be a unique name.
|
|
75
|
+
:vartype sender: str
|
|
76
|
+
:ivar unix_fds: A list of unix fds that were sent in the header of this message.
|
|
77
|
+
:vartype unix_fds: list(int)
|
|
78
|
+
:ivar signature: The signature of the body of this message.
|
|
79
|
+
:vartype signature: str
|
|
80
|
+
:ivar signature_tree: The signature parsed as a signature tree.
|
|
81
|
+
:vartype signature_tree: :class:`SignatureTree`
|
|
82
|
+
:ivar body: The body of this message. Must match the signature.
|
|
83
|
+
:vartype body: list(Any)
|
|
84
|
+
:ivar serial: The serial of the message. Will be automatically set during message sending if not present. Use the ``new_serial()`` method of the bus to generate a serial.
|
|
85
|
+
:vartype serial: int
|
|
86
|
+
|
|
87
|
+
:raises:
|
|
88
|
+
- :class:`InvalidMessageError` - If the message is malformed or missing fields for the message type.
|
|
89
|
+
- :class:`InvalidSignatureError` - If the given signature is not valid.
|
|
90
|
+
- :class:`InvalidObjectPathError` - If ``path`` is not a valid object path.
|
|
91
|
+
- :class:`InvalidBusNameError` - If ``destination`` is not a valid bus name.
|
|
92
|
+
- :class:`InvalidMemberNameError` - If ``member`` is not a valid member name.
|
|
93
|
+
- :class:`InvalidInterfaceNameError` - If ``error_name`` or ``interface`` is not a valid interface name.
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
__slots__ = (
|
|
97
|
+
"body",
|
|
98
|
+
"destination",
|
|
99
|
+
"error_name",
|
|
100
|
+
"flags",
|
|
101
|
+
"interface",
|
|
102
|
+
"member",
|
|
103
|
+
"message_type",
|
|
104
|
+
"path",
|
|
105
|
+
"reply_serial",
|
|
106
|
+
"sender",
|
|
107
|
+
"serial",
|
|
108
|
+
"signature",
|
|
109
|
+
"signature_tree",
|
|
110
|
+
"unix_fds",
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
def __init__(
|
|
114
|
+
self,
|
|
115
|
+
destination: Optional[str] = None,
|
|
116
|
+
path: Optional[str] = None,
|
|
117
|
+
interface: Optional[str] = None,
|
|
118
|
+
member: Optional[str] = None,
|
|
119
|
+
message_type: MessageType = MESSAGE_TYPE_METHOD_CALL,
|
|
120
|
+
flags: Union[MessageFlag, int] = MESSAGE_FLAG_NONE,
|
|
121
|
+
error_name: Optional[Union[str, ErrorType]] = None,
|
|
122
|
+
reply_serial: Optional[int] = None,
|
|
123
|
+
sender: Optional[str] = None,
|
|
124
|
+
unix_fds: list[int] = [],
|
|
125
|
+
signature: Optional[Union[SignatureTree, str]] = None,
|
|
126
|
+
body: list[Any] = [],
|
|
127
|
+
serial: Optional[int] = None,
|
|
128
|
+
validate: bool = True,
|
|
129
|
+
) -> None:
|
|
130
|
+
self._fast_init(
|
|
131
|
+
destination,
|
|
132
|
+
path,
|
|
133
|
+
interface,
|
|
134
|
+
member,
|
|
135
|
+
message_type,
|
|
136
|
+
flags if type(flags) is MESSAGE_FLAG else MESSAGE_FLAG(flags),
|
|
137
|
+
str(error_name.value) if type(error_name) is ErrorType else error_name,
|
|
138
|
+
reply_serial or 0,
|
|
139
|
+
sender,
|
|
140
|
+
unix_fds,
|
|
141
|
+
signature
|
|
142
|
+
if type(signature) is SignatureTree
|
|
143
|
+
else get_signature_tree(signature or ""),
|
|
144
|
+
body,
|
|
145
|
+
serial or 0,
|
|
146
|
+
validate,
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
def _fast_init(
|
|
150
|
+
self,
|
|
151
|
+
destination: Optional[_str],
|
|
152
|
+
path: Optional[_str],
|
|
153
|
+
interface: Optional[_str],
|
|
154
|
+
member: Optional[_str],
|
|
155
|
+
message_type: _MessageType,
|
|
156
|
+
flags: _MessageFlag,
|
|
157
|
+
error_name: Optional[_str],
|
|
158
|
+
reply_serial: _int,
|
|
159
|
+
sender: _str,
|
|
160
|
+
unix_fds: _list[int],
|
|
161
|
+
signature_tree: SignatureTree,
|
|
162
|
+
body: _list[Any],
|
|
163
|
+
serial: _int,
|
|
164
|
+
validate: _bool,
|
|
165
|
+
) -> None:
|
|
166
|
+
self.destination = destination
|
|
167
|
+
self.path = path
|
|
168
|
+
self.interface = interface
|
|
169
|
+
self.member = member
|
|
170
|
+
self.message_type = message_type
|
|
171
|
+
self.flags = flags
|
|
172
|
+
self.error_name = error_name
|
|
173
|
+
self.reply_serial = reply_serial
|
|
174
|
+
self.sender = sender
|
|
175
|
+
self.unix_fds = unix_fds
|
|
176
|
+
self.signature = signature_tree.signature
|
|
177
|
+
self.signature_tree = signature_tree
|
|
178
|
+
self.body = body
|
|
179
|
+
self.serial = serial
|
|
180
|
+
|
|
181
|
+
if not validate:
|
|
182
|
+
return
|
|
183
|
+
if self.destination is not None:
|
|
184
|
+
assert_bus_name_valid(self.destination)
|
|
185
|
+
if self.interface is not None:
|
|
186
|
+
assert_interface_name_valid(self.interface)
|
|
187
|
+
if self.path is not None:
|
|
188
|
+
assert_object_path_valid(self.path)
|
|
189
|
+
if self.member is not None:
|
|
190
|
+
assert_member_name_valid(self.member)
|
|
191
|
+
if self.error_name is not None:
|
|
192
|
+
assert_interface_name_valid(self.error_name) # type: ignore[arg-type]
|
|
193
|
+
|
|
194
|
+
required_fields = REQUIRED_FIELDS.get(self.message_type.value)
|
|
195
|
+
if not required_fields:
|
|
196
|
+
raise InvalidMessageError(f"got unknown message type: {self.message_type}")
|
|
197
|
+
for field in required_fields:
|
|
198
|
+
if not getattr(self, field):
|
|
199
|
+
raise InvalidMessageError(f"missing required field: {field}")
|
|
200
|
+
|
|
201
|
+
def __repr__(self) -> str:
|
|
202
|
+
"""Return a string representation of this message."""
|
|
203
|
+
return (
|
|
204
|
+
f"<Message {self.message_type.name} "
|
|
205
|
+
f"serial={self.serial} "
|
|
206
|
+
f"reply_serial={self.reply_serial} "
|
|
207
|
+
f"sender={self.sender} "
|
|
208
|
+
f"destination={self.destination} "
|
|
209
|
+
f"path={self.path} "
|
|
210
|
+
f"interface={self.interface} "
|
|
211
|
+
f"member={self.member} "
|
|
212
|
+
f"error_name={self.error_name} "
|
|
213
|
+
f"signature={self.signature} "
|
|
214
|
+
f"body={self.body}>"
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
@staticmethod
|
|
218
|
+
def new_error(
|
|
219
|
+
msg: "Message", error_name: Union[str, ErrorType], error_text: str
|
|
220
|
+
) -> "Message":
|
|
221
|
+
"""A convenience constructor to create an error message in reply to the given message.
|
|
222
|
+
|
|
223
|
+
:param msg: The message this error is in reply to.
|
|
224
|
+
:type msg: :class:`Message`
|
|
225
|
+
:param error_name: The name of this error. Must be a valid interface name.
|
|
226
|
+
:type error_name: str
|
|
227
|
+
:param error_text: Human-readable text for the error.
|
|
228
|
+
|
|
229
|
+
:returns: The error message.
|
|
230
|
+
:rtype: :class:`Message`
|
|
231
|
+
|
|
232
|
+
:raises:
|
|
233
|
+
- :class:`InvalidInterfaceNameError` - If the error_name is not a valid interface name.
|
|
234
|
+
"""
|
|
235
|
+
return Message(
|
|
236
|
+
message_type=MessageType.ERROR,
|
|
237
|
+
reply_serial=msg.serial,
|
|
238
|
+
destination=msg.sender,
|
|
239
|
+
error_name=error_name,
|
|
240
|
+
signature="s",
|
|
241
|
+
body=[error_text],
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
@staticmethod
|
|
245
|
+
def new_method_return(
|
|
246
|
+
msg: "Message",
|
|
247
|
+
signature: str = "",
|
|
248
|
+
body: list[Any] = [],
|
|
249
|
+
unix_fds: list[int] = [],
|
|
250
|
+
) -> "Message":
|
|
251
|
+
"""A convenience constructor to create a method return to the given method call message.
|
|
252
|
+
|
|
253
|
+
:param msg: The method call message this is a reply to.
|
|
254
|
+
:type msg: :class:`Message`
|
|
255
|
+
:param signature: The signature for the message body.
|
|
256
|
+
:type signature: str
|
|
257
|
+
:param body: The body of this message. Must match the signature.
|
|
258
|
+
:type body: list(Any)
|
|
259
|
+
:param unix_fds: List integer file descriptors to send with this message.
|
|
260
|
+
:type body: list(int)
|
|
261
|
+
|
|
262
|
+
:returns: The method return message
|
|
263
|
+
:rtype: :class:`Message`
|
|
264
|
+
|
|
265
|
+
:raises:
|
|
266
|
+
- :class:`InvalidSignatureError` - If the signature is not a valid signature.
|
|
267
|
+
"""
|
|
268
|
+
return Message(
|
|
269
|
+
message_type=MessageType.METHOD_RETURN,
|
|
270
|
+
reply_serial=msg.serial,
|
|
271
|
+
destination=msg.sender,
|
|
272
|
+
signature=signature,
|
|
273
|
+
body=body,
|
|
274
|
+
unix_fds=unix_fds,
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
@staticmethod
|
|
278
|
+
def new_signal(
|
|
279
|
+
path: str,
|
|
280
|
+
interface: str,
|
|
281
|
+
member: str,
|
|
282
|
+
signature: str = "",
|
|
283
|
+
body: Optional[list[Any]] = None,
|
|
284
|
+
unix_fds: Optional[list[int]] = None,
|
|
285
|
+
) -> "Message":
|
|
286
|
+
"""A convenience constructor to create a new signal message.
|
|
287
|
+
|
|
288
|
+
:param path: The path of this signal.
|
|
289
|
+
:type path: str
|
|
290
|
+
:param interface: The interface of this signal.
|
|
291
|
+
:type interface: str
|
|
292
|
+
:param member: The member name of this signal.
|
|
293
|
+
:type member: str
|
|
294
|
+
:param signature: The signature of the signal body.
|
|
295
|
+
:type signature: str
|
|
296
|
+
:param body: The body of this signal message.
|
|
297
|
+
:type body: list(Any)
|
|
298
|
+
:param unix_fds: List integer file descriptors to send with this message.
|
|
299
|
+
:type body: list(int)
|
|
300
|
+
|
|
301
|
+
:returns: The signal message.
|
|
302
|
+
:rtype: :class:`Message`
|
|
303
|
+
|
|
304
|
+
:raises:
|
|
305
|
+
- :class:`InvalidSignatureError` - If the signature is not a valid signature.
|
|
306
|
+
- :class:`InvalidObjectPathError` - If ``path`` is not a valid object path.
|
|
307
|
+
- :class:`InvalidInterfaceNameError` - If ``interface`` is not a valid interface name.
|
|
308
|
+
- :class:`InvalidMemberNameError` - If ``member`` is not a valid member name.
|
|
309
|
+
"""
|
|
310
|
+
return Message(
|
|
311
|
+
message_type=MessageType.SIGNAL,
|
|
312
|
+
interface=interface,
|
|
313
|
+
path=path,
|
|
314
|
+
member=member,
|
|
315
|
+
signature=signature,
|
|
316
|
+
body=body or [],
|
|
317
|
+
unix_fds=unix_fds or [],
|
|
318
|
+
)
|
|
319
|
+
|
|
320
|
+
def _marshall(self, negotiate_unix_fd: bool) -> bytearray:
|
|
321
|
+
"""Marshall this message into a byte array."""
|
|
322
|
+
# TODO maximum message size is 134217728 (128 MiB)
|
|
323
|
+
body_block = Marshaller(self.signature, self.body)
|
|
324
|
+
body_buffer = body_block._marshall()
|
|
325
|
+
|
|
326
|
+
fields = []
|
|
327
|
+
|
|
328
|
+
# No verify here since the marshaller will raise an exception if the
|
|
329
|
+
# Variant is invalid.
|
|
330
|
+
|
|
331
|
+
if self.path:
|
|
332
|
+
fields.append((HEADER_PATH, Variant._factory(SIGNATURE_TREE_O, self.path)))
|
|
333
|
+
if self.interface:
|
|
334
|
+
fields.append(
|
|
335
|
+
(HEADER_INTERFACE, Variant._factory(SIGNATURE_TREE_S, self.interface))
|
|
336
|
+
)
|
|
337
|
+
if self.member:
|
|
338
|
+
fields.append(
|
|
339
|
+
(HEADER_MEMBER, Variant._factory(SIGNATURE_TREE_S, self.member))
|
|
340
|
+
)
|
|
341
|
+
if self.error_name:
|
|
342
|
+
fields.append(
|
|
343
|
+
(
|
|
344
|
+
HEADER_ERROR_NAME,
|
|
345
|
+
Variant._factory(SIGNATURE_TREE_S, self.error_name),
|
|
346
|
+
)
|
|
347
|
+
)
|
|
348
|
+
if self.reply_serial:
|
|
349
|
+
fields.append(
|
|
350
|
+
(
|
|
351
|
+
HEADER_REPLY_SERIAL,
|
|
352
|
+
Variant._factory(SIGNATURE_TREE_U, self.reply_serial),
|
|
353
|
+
)
|
|
354
|
+
)
|
|
355
|
+
if self.destination:
|
|
356
|
+
fields.append(
|
|
357
|
+
(
|
|
358
|
+
HEADER_DESTINATION,
|
|
359
|
+
Variant._factory(SIGNATURE_TREE_S, self.destination),
|
|
360
|
+
)
|
|
361
|
+
)
|
|
362
|
+
if self.signature:
|
|
363
|
+
fields.append(
|
|
364
|
+
(HEADER_SIGNATURE, Variant._factory(SIGNATURE_TREE_G, self.signature))
|
|
365
|
+
)
|
|
366
|
+
if self.unix_fds and negotiate_unix_fd:
|
|
367
|
+
fields.append(
|
|
368
|
+
(
|
|
369
|
+
HEADER_UNIX_FDS,
|
|
370
|
+
Variant._factory(SIGNATURE_TREE_U, len(self.unix_fds)),
|
|
371
|
+
)
|
|
372
|
+
)
|
|
373
|
+
|
|
374
|
+
header_body = [
|
|
375
|
+
LITTLE_ENDIAN,
|
|
376
|
+
self.message_type.value,
|
|
377
|
+
self.flags.value,
|
|
378
|
+
PROTOCOL_VERSION,
|
|
379
|
+
len(body_buffer),
|
|
380
|
+
self.serial,
|
|
381
|
+
fields,
|
|
382
|
+
]
|
|
383
|
+
header_block = Marshaller("yyyyuua(yv)", header_body)
|
|
384
|
+
header_block._marshall()
|
|
385
|
+
header_block._align(8)
|
|
386
|
+
header_buffer = header_block._buffer()
|
|
387
|
+
return header_buffer + body_buffer
|
|
Binary file
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import cython
|
|
2
|
+
|
|
3
|
+
from ._private.address cimport get_bus_address, parse_address
|
|
4
|
+
from .message cimport Message
|
|
5
|
+
from .service cimport ServiceInterface, _Method
|
|
6
|
+
|
|
7
|
+
cdef bint TYPE_CHECKING
|
|
8
|
+
|
|
9
|
+
cdef object MessageType
|
|
10
|
+
cdef object DBusError
|
|
11
|
+
cdef object MessageFlag
|
|
12
|
+
|
|
13
|
+
cdef object MESSAGE_TYPE_CALL
|
|
14
|
+
cdef object MESSAGE_TYPE_SIGNAL
|
|
15
|
+
cdef cython.uint NO_REPLY_EXPECTED_VALUE
|
|
16
|
+
cdef object NONE
|
|
17
|
+
cdef object NO_REPLY_EXPECTED
|
|
18
|
+
|
|
19
|
+
cdef object BLOCK_UNEXPECTED_REPLY
|
|
20
|
+
cdef object assert_object_path_valid
|
|
21
|
+
cdef object assert_bus_name_valid
|
|
22
|
+
|
|
23
|
+
@cython.locals(flag_value=cython.uint)
|
|
24
|
+
cdef bint _expects_reply(Message msg)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
cdef class BaseMessageBus:
|
|
28
|
+
|
|
29
|
+
cdef public object unique_name
|
|
30
|
+
cdef public bint _disconnected
|
|
31
|
+
cdef public object _user_disconnect
|
|
32
|
+
cdef public cython.dict _method_return_handlers
|
|
33
|
+
cdef public object _serial
|
|
34
|
+
cdef public cython.dict _path_exports
|
|
35
|
+
cdef public cython.list _user_message_handlers
|
|
36
|
+
cdef public cython.dict _name_owners
|
|
37
|
+
cdef public object _bus_address
|
|
38
|
+
cdef public object _name_owner_match_rule
|
|
39
|
+
cdef public cython.dict _match_rules
|
|
40
|
+
cdef public object _high_level_client_initialized
|
|
41
|
+
cdef public object _ProxyObject
|
|
42
|
+
cdef public object _machine_id
|
|
43
|
+
cdef public bint _negotiate_unix_fd
|
|
44
|
+
cdef public object _sock
|
|
45
|
+
cdef public object _stream
|
|
46
|
+
cdef public object _fd
|
|
47
|
+
|
|
48
|
+
cpdef void _process_message(self, Message msg) except *
|
|
49
|
+
|
|
50
|
+
@cython.locals(exported_service_interface=ServiceInterface)
|
|
51
|
+
cpdef export(self, str path, ServiceInterface interface)
|
|
52
|
+
|
|
53
|
+
@cython.locals(
|
|
54
|
+
methods=cython.list,
|
|
55
|
+
method=_Method,
|
|
56
|
+
interface=ServiceInterface,
|
|
57
|
+
interfaces=dict,
|
|
58
|
+
)
|
|
59
|
+
cdef _find_message_handler(self, Message msg)
|
|
60
|
+
|
|
61
|
+
cdef _find_any_message_handler_matching_signature(self, dict interfaces, Message msg)
|
|
62
|
+
|
|
63
|
+
cdef _setup_socket(self)
|
|
64
|
+
|
|
65
|
+
cpdef _call(self, Message msg, object callback)
|
|
66
|
+
|
|
67
|
+
cpdef next_serial(self)
|
|
68
|
+
|
|
69
|
+
cpdef void _callback_method_handler(
|
|
70
|
+
self,
|
|
71
|
+
ServiceInterface interface,
|
|
72
|
+
_Method method,
|
|
73
|
+
Message msg,
|
|
74
|
+
object send_reply
|
|
75
|
+
) except *
|