Module: etree
- oldmemo.etree.serialize_device_list(device_list)[source]
- Parameters:
device_list (
Dict[int,SignedLabel|None]) – The device list to serialize. The first entry of each tuple is the device id, and the second entry is the optional signed label. Note that labels are not supported by this version of the specification and will not be included in the XML.- Return type:
- Returns:
The serialized device list as an XML element.
- oldmemo.etree.parse_device_list(element)[source]
- Parameters:
element (
Element) – The XML element to parse the device list from.- Return type:
Dict[int,SignedLabel|None]- Returns:
The extracted device list. The first entry of each tuple is the device id, and the second entry is the optional signed label. Note that labels are not supported by this version of the specification, so all labels will be set to
None.- Raises:
xmlschema.XMLSchemaValidationError – in case the element does not conform to the XML schema given in the specification.
- oldmemo.etree.serialize_bundle(bundle)[source]
- Parameters:
bundle (
BundleImpl) – The bundle to serialize.- Return type:
- Returns:
The serialized bundle as an XML element.
- oldmemo.etree.parse_bundle(element, bare_jid, device_id)[source]
- Parameters:
- Return type:
- Returns:
The extracted bundle.
- Raises:
ValueError – in case of malformed data that still passed the schema validation.
xmlschema.XMLSchemaValidationError – in case the element does not conform to the XML schema given in the specification.
- async oldmemo.etree.parse_message(element, sender_bare_jid, own_bare_jid, session_manager)[source]
- Parameters:
element (
Element) – The XML element to parse the message from.sender_bare_jid (
str) – The bare JID of the sender.own_bare_jid (
str) – The bare JID of the XMPP account decrypting this message, i.e. us.session_manager (
SessionManager) – The session manager instance is required to find one piece of information that the oldmemo message serialization format lacks with regards to the identity key.
- Return type:
- Returns:
The extracted message.
- Raises:
ValueError – in case there is malformed data not caught be the XML schema validation.
xmlschema.XMLSchemaValidationError – in case the element does not conform to the XML schema given in the specification.
SenderNotFound – in case the public information about the sending device could not be found or is incomplete.
Warning
This version of the OMEMO specification matches key material to recipient purely by device id. The library, however, matches by bare JID and device id. Since the XML doesn’t include the bare JID, the structures expected by the library can’t be filled correctly. Instead, to match the behaviour of the specification, the bare JID of all key material included in the message is assigned to
own_bare_jid, i.e. our own bare JID, which achieves the desired effect of matching only on the device id.