download static method
Implementation
static void download(
Computer computer,
ComputerTransport transport, [
String? lastFingerprint,
]) {
final computerDescriptor = _computerDescriptorCache[computer]!;
final ffi.Pointer<dc_iostream_t> iostream =
_interfaces.connect(transport, computerDescriptor);
final device = calloc<ffi.Pointer<dc_device_t>>();
try {
handleResult(
_bindings.dc_device_open(
device,
context.value,
computerDescriptor,
iostream,
),
'device open',
);
final customdata = calloc<_DiveCallbackUserdata>();
customdata.ref.device = device.value;
customdata.ref.lastFingerprint =
lastFingerprint?.toNativeUtf8() ?? ffi.nullptr;
_divesCache.clear();
handleResult(
_bindings.dc_device_foreach(
device.value,
ffi.Pointer.fromFunction(_dive_callback, 0),
customdata.cast(),
),
'device foreach',
);
if (lastFingerprint != null) {
_divesCache.removeWhere((e) => e.hash == lastFingerprint);
}
divesCallback?.call(_divesCache);
handleResult(
_bindings.dc_device_close(device.value),
'device close',
);
} finally {
handleResult(
_bindings.dc_iostream_close(iostream),
'iostream close',
);
}
}