Skip to content

Commit

Permalink
fix: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Oct 4, 2022
1 parent 3bf590e commit 5f51da4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
19 changes: 17 additions & 2 deletions src/dbus_fast/message.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ cdef unsigned int LITTLE_ENDIAN
cdef unsigned int BIG_ENDIAN
cdef unsigned int PROTOCOL_VERSION

cdef unsigned int HEADER_PATH
cdef unsigned int HEADER_INTERFACE
cdef unsigned int HEADER_MEMBER
cdef unsigned int HEADER_ERROR_NAME
cdef unsigned int HEADER_REPLY_SERIAL
cdef unsigned int HEADER_DESTINATION
cdef unsigned int HEADER_SIGNATURE
cdef unsigned int HEADER_UNIX_FDS

cdef unsigned int METHOD_CALL
cdef unsigned int SIGNAL
cdef unsigned int ERROR
cdef unsigned int METHOD_RETURN


cdef class Message:

cdef public str destination
Expand All @@ -16,13 +31,13 @@ cdef class Message:
cdef public object message_type
cdef public object flags
cdef public str error_name
cdef public unsigned int reply_serial
cdef public object reply_serial
cdef public str sender
cdef public list unix_fds
cdef public str signature
cdef public object signature_tree
cdef public list body
cdef public unsigned int serial
cdef public object serial

@cython.locals(
fields=cython.list,
Expand Down
13 changes: 9 additions & 4 deletions src/dbus_fast/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
HEADER_SIGNATURE = HeaderField.SIGNATURE.value
HEADER_UNIX_FDS = HeaderField.UNIX_FDS.value

METHOD_CALL = MessageType.METHOD_CALL.value
SIGNAL = MessageType.SIGNAL.value
ERROR = MessageType.ERROR.value
METHOD_RETURN = MessageType.METHOD_RETURN.value


class Message:
"""A class for sending and receiving messages through the
Expand Down Expand Up @@ -139,24 +144,24 @@ def __init__(
if self.error_name is not None:
assert_interface_name_valid(self.error_name)

if message_type == MessageType.METHOD_CALL:
if message_type == METHOD_CALL:
if not path:
raise InvalidMessageError(f"missing required field: path")
if not member:
raise InvalidMessageError(f"missing required field: member")
elif message_type == MessageType.SIGNAL:
elif message_type == SIGNAL:
if not path:
raise InvalidMessageError(f"missing required field: path")
if not member:
raise InvalidMessageError(f"missing required field: member")
if not interface:
raise InvalidMessageError(f"missing required field: interface")
elif message_type == MessageType.ERROR:
elif message_type == ERROR:
if not error_name:
raise InvalidMessageError(f"missing required field: error_name")
if not reply_serial:
raise InvalidMessageError(f"missing required field: reply_serial")
elif message_type == MessageType.METHOD_RETURN:
elif message_type == METHOD_RETURN:
if not reply_serial:
raise InvalidMessageError(f"missing required field: reply_serial")
else:
Expand Down
2 changes: 0 additions & 2 deletions src/dbus_fast/signature.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ cdef class SignatureType:

cdef _collapse(self)

cdef _parse_next(self)


cdef class SignatureTree:

Expand Down

0 comments on commit 5f51da4

Please sign in to comment.