bundleFromXML function
Convert the XML representation of an OMEMO bundle into an OmemoBundle object.
jid
refers to the JID the bundle belongs to. id
refers to the bundle's device
identifier. bundle
refers to the
Returns the OmemoBundle.
Implementation
OmemoBundle bundleFromXML(JID jid, int id, XMLNode bundle) {
assert(bundle.attributes['xmlns'] == omemoXmlns, 'Invalid xmlns');
final spk = bundle.firstTag('spk')!;
final prekeys = <int, String>{};
for (final pk in bundle.firstTag('prekeys')!.findTags('pk')) {
prekeys[int.parse(pk.attributes['id']! as String)] = pk.innerText();
}
return OmemoBundle(
jid.toBare().toString(),
id,
spk.innerText(),
int.parse(spk.attributes['id']! as String),
bundle.firstTag('spks')!.innerText(),
bundle.firstTag('ik')!.innerText(),
prekeys,
);
}