processStatelessFileSharingSources function

List<StatelessFileSharingSource> processStatelessFileSharingSources(
  1. XMLNode node,
  2. {bool checkXmlns = true}
)

Finds the element in node and returns the list of StatelessFileSharingSources contained with it. If checkXmlns is true, then the sources element must also have an xmlns attribute of "urn:xmpp:sfs:0".

Implementation

List<StatelessFileSharingSource> processStatelessFileSharingSources(
  XMLNode node, {
  bool checkXmlns = true,
}) {
  final sources = List<StatelessFileSharingSource>.empty(growable: true);

  final sourcesElement = node.firstTag(
    'sources',
    xmlns: checkXmlns ? sfsXmlns : null,
  )!;
  for (final source in sourcesElement.children) {
    if (source.attributes['xmlns'] == urlDataXmlns) {
      sources.add(StatelessFileSharingUrlSource.fromXml(source));
    } else if (source.attributes['xmlns'] == sfsEncryptionXmlns) {
      sources.add(StatelessFileSharingEncryptedSource.fromXml(source));
    }
  }

  return sources;
}