PcapLiveDevice* PcapLiveDeviceList::getPcapLiveDeviceByName(const std::string& name)
{
	LOG_DEBUG("Searching all live devices...");
	for(std::vector<PcapLiveDevice*>::iterator devIter = m_LiveDeviceList.begin(); devIter != m_LiveDeviceList.end(); devIter++)
	{
		std::string devName((*devIter)->getName());
		if (name == devName)
			return (*devIter);
	}

	return NULL;

}
Пример #2
0
QString NetworkInterface::desc()
{
   return Utils::sysctl("dev." + devName() + "." + QString::number(devNum()) + ".%desc");
}
void DownloadFromDCWidget::on_downloadCancelRetryButton_clicked()
{
	if (currentState == DOWNLOADING) {
		updateState(CANCELLING);
		return;
	}
	if (currentState == DONE) {
		// this means we are retrying - so we better clean out the partial
		// list of downloaded dives from the last attempt
		diveImportedModel->clearTable();
		clear_table(&downloadTable);
	}
	updateState(DOWNLOADING);

	// you cannot cancel the dialog, just the download
	ui.cancel->setEnabled(false);
	ui.downloadCancelRetryButton->setText(tr("Cancel download"));

	auto data = thread.data();
	data->setVendor(ui.vendor->currentText());
	data->setProduct(ui.product->currentText());
#if defined(BT_SUPPORT)
	data->setBluetoothMode(ui.bluetoothMode->isChecked());
	if (data->bluetoothMode()) {
		// Get the selected device address from dialog or from preferences
		if (btDeviceSelectionDialog != NULL) {
			data->setDevName(btDeviceSelectionDialog->getSelectedDeviceAddress());
			data->setDevBluetoothName(btDeviceSelectionDialog->getSelectedDeviceName());
		} else {
			data->setDevName(qPrefDiveComputer::device());
			data->setDevBluetoothName(qPrefDiveComputer::device_name());
		}
	} else
		// this breaks an "else if" across lines... not happy...
#endif
	if (data->vendor() == "Uemis") {
		char *colon;
		char *devname = copy_qstring(ui.device->currentText());

		if ((colon = strstr(devname, ":\\ (UEMISSDA)")) != NULL) {
			*(colon + 2) = '\0';
			fprintf(stderr, "shortened devname to \"%s\"", devname);
		}
		data->setDevName(devname);
	} else {
		data->setDevName(ui.device->currentText());
	}

	data->setForceDownload(ui.forceDownload->isChecked());
	data->setCreateNewTrip(ui.createNewTrip->isChecked());
	data->setSaveLog(ui.logToFile->isChecked());
	data->setSaveDump(ui.dumpToFile->isChecked());

	qPrefDiveComputer::set_vendor(data->vendor());
	qPrefDiveComputer::set_product(data->product());
	qPrefDiveComputer::set_device(data->devName());

#if defined(BT_SUPPORT)
	qPrefDiveComputer::set_download_mode(ui.bluetoothMode->isChecked() ? DC_TRANSPORT_BLUETOOTH : DC_TRANSPORT_SERIAL);
#endif

	// before we start, remember where the dive_table ended
	previousLast = dive_table.nr;
	thread.start();

	// FIXME: We should get the _actual_ device info instead of whatever
	// the user entered in the dropdown.
	// You can enter "OSTC 3" and download just fine from a "OSTC Sport", but
	// this check will compair apples and oranges, firmware wise, then.
	QString product(ui.product->currentText());
	//
	// We shouldn't do this for memory dumps.
	if ((product == "OSTC 3" || product == "OSTC 3+" || product == "OSTC cR" ||
	     product == "OSTC Sport" || product == "OSTC 4" || product == "OSTC Plus") &&
	    !data->saveDump()) {
		ostcFirmwareCheck = new OstcFirmwareCheck(product);
	}
}