collectContentInfo method
void
collectContentInfo(
- ContentDisposition disposition,
- List<
ContentInfo> result, { - bool? reverse,
- bool? withCleanParts,
- bool? complete,
Adds the matching disposition header with the specified disposition
of this part and this children parts to the result
.
Optionally set reverse
to true
to add all parts that do not match the specified disposition
.
All fetchId parsed from the BODYSTRUCTURE
are returned in a form compatible
with the body parts tree unless withCleanParts
is false.
Set complete
to false
to skip the included rfc822 messages parts.
Implementation
void collectContentInfo(
ContentDisposition disposition, List<ContentInfo> result,
{bool? reverse, bool? withCleanParts, bool? complete}) {
reverse ??= false;
withCleanParts ??= true;
complete ??= true;
final isMessage = contentType?.mediaType.isMessage ?? false;
if (fetchId != null) {
if ((!reverse && contentDisposition?.disposition == disposition) ||
(reverse &&
contentDisposition?.disposition != disposition &&
contentType?.mediaType.top != MediaToptype.multipart)) {
if (!withCleanParts ||
(withCleanParts && !fetchId!.endsWith('.TEXT'))) {
final info = ContentInfo(
withCleanParts ? fetchId!.replaceAll('.TEXT', '') : fetchId!)
..contentDisposition = contentDisposition
..contentType = contentType
..cid = cid;
result.add(info);
}
}
}
if (!complete &&
isMessage &&
((reverse && disposition == ContentDisposition.attachment) ||
(!reverse && disposition == ContentDisposition.inline))) {
// abort to search for inline parts at messages, unless attachments are searched
return;
}
if (parts?.isNotEmpty ?? false) {
for (final part in parts!) {
if ((disposition == ContentDisposition.attachment &&
reverse &&
part.contentDisposition?.disposition ==
ContentDisposition.attachment) ||
(disposition == ContentDisposition.inline &&
!reverse &&
part.contentDisposition?.disposition ==
ContentDisposition.attachment)) {
// abort at attachents when inline parts are searched for
continue;
}
part.collectContentInfo(disposition, result,
reverse: reverse,
withCleanParts: withCleanParts,
complete: complete);
}
}
}