void DownloadThread::run()
{
	const char *error;
	if (!strcmp(data->vendor, "Uemis"))
		error = do_uemis_import(data->devname, data->force_download);
	else
		error = do_libdivecomputer_import(data);
	if (error)
		this->error =  str_error(error, data->devname, data->vendor, data->product);
}
Ejemplo n.º 2
0
void DownloadThread::run()
{
	auto internalData = m_data->internalData();
	internalData->descriptor = descriptorLookup[m_data->vendor() + m_data->product()];
	internalData->download_table = &downloadTable;
	internalData->btname = strdup(m_data->devBluetoothName().toUtf8());
#if defined(Q_OS_ANDROID)
	// on Android we either use BT, a USB device, or we download via FTDI cable
	if (!internalData->bluetooth_mode && (same_string(internalData->devname, "FTDI") || same_string(internalData->devname, "")))
		internalData->devname = "ftdi";
#endif
	qDebug() << "Starting download from " << (internalData->bluetooth_mode ? "BT" : internalData->devname);
	downloadTable.nr = 0;

	Q_ASSERT(internalData->download_table != nullptr);
	const char *errorText;
	import_thread_cancelled = false;
	error.clear();
	if (!strcmp(internalData->vendor, "Uemis"))
		errorText = do_uemis_import(internalData);
	else
		errorText = do_libdivecomputer_import(internalData);
	if (errorText) {
		error = str_error(errorText, internalData->devname, internalData->vendor, internalData->product);
		qDebug() << "Finishing download thread:" << error;
	} else {
		if (!downloadTable.nr)
			error = tr("No new dives downloaded from dive computer");
		qDebug() << "Finishing download thread:" << downloadTable.nr << "dives downloaded";
	}
	qPrefDiveComputer::set_vendor(internalData->vendor);
	qPrefDiveComputer::set_product(internalData->product);
	qPrefDiveComputer::set_device(internalData->devname);
	qPrefDiveComputer::set_device_name(m_data->devBluetoothName());

	updateRememberedDCs();
}