From 9946acac23f5eb4f79b8b4cb2942c2655aa600b4 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 17 Dec 2021 17:25:56 +0200 Subject: [PATCH] Add Python wrapper for olm_session_describe Signed-off-by: Tulir Asokan --- python/olm/session.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/python/olm/session.py b/python/olm/session.py index 636eb3d..d4430d6 100644 --- a/python/olm/session.py +++ b/python/olm/session.py @@ -391,6 +391,24 @@ class Session(object): return bool(ret) + def describe(self, buffer_length=600): + # type: (int) -> str + """ + Generate a string describing the internal state of an olm session + for debugging and logging purposes. + + Args: + buffer_length(int): The size of buffer for the string. + If the buffer is not large enough to hold the entire string, it + will be truncated and will end with "...". A buffer length of + 600 will be enough to hold any output. + """ + describe_buffer = ffi.new("char[]", buffer_length) + lib.olm_session_describe( + self._session, describe_buffer, buffer_length + ) + return bytes_to_native_str(ffi.string(describe_buffer)) + class InboundSession(Session): """Inbound Olm session for p2p encrypted communication.