WirelessFrame::WirelessFrame(QWidget *parent) : QFrame(parent), ui(new Ui::WirelessFrame), interfaces_(NULL), capture_in_progress_(false) { ui->setupUi(this); ui->helperToolButton->hide(); if (ws80211_init() == 0) { ui->stackedWidget->setEnabled(true); ui->stackedWidget->setCurrentWidget(ui->interfacePage); #ifdef HAVE_AIRPCAP // We should arguably add ws80211_get_helper_name and ws80211_get_helper_tooltip. // This works for now and is translatable. ui->helperToolButton->setText(tr("AirPcap Control Panel")); ui->helperToolButton->setToolTip(tr("Open the AirPcap Control Panel")); ui->helperToolButton->show(); ui->helperToolButton->setEnabled(ws80211_get_helper_path() != NULL); #endif } else { ui->stackedWidget->setEnabled(false); ui->stackedWidget->setCurrentWidget(ui->noWirelessPage); } ui->fcsFilterFrame->setVisible(ws80211_has_fcs_filter()); getInterfaceInfo(); startTimer(update_interval_); }
void WirelessFrame::on_interfaceComboBox_currentIndexChanged(const QString &cur_iface) { ui->channelComboBox->clear(); ui->channelTypeComboBox->clear(); if (cur_iface.isEmpty()) { updateWidgets(); return; } for (guint i = 0; i < interfaces_->len; i++) { struct ws80211_interface *iface = g_array_index(interfaces_, struct ws80211_interface *, i); if (cur_iface.compare(iface->ifname) == 0) { struct ws80211_iface_info iface_info; QString units = " GHz"; ws80211_get_iface_info(iface->ifname, &iface_info); for (guint i = 0; i < iface->frequencies->len; i++) { guint32 frequency = g_array_index(iface->frequencies, guint32, i); double ghz = frequency / 1000.0; QString chan_str = QString("%1 " UTF8_MIDDLE_DOT " %2%3") .arg(ws80211_frequency_to_channel(frequency)) .arg(ghz, 0, 'f', 3) .arg(units); ui->channelComboBox->addItem(chan_str, frequency); if ((int)frequency == iface_info.current_freq) { ui->channelComboBox->setCurrentIndex(ui->channelComboBox->count() - 1); } units = QString(); } // XXX - Do we need to make a distinction between WS80211_CHAN_NO_HT // and WS80211_CHAN_HT20? E.g. is there a driver that won't capture // HT frames if you use WS80211_CHAN_NO_HT? ui->channelTypeComboBox->addItem("20 MHz", WS80211_CHAN_NO_HT); if (iface_info.current_chan_type == WS80211_CHAN_NO_HT || iface_info.current_chan_type == WS80211_CHAN_HT20) { ui->channelTypeComboBox->setCurrentIndex(0); } if (iface->channel_types & (1 << WS80211_CHAN_HT40MINUS)) { ui->channelTypeComboBox->addItem("HT 40-", WS80211_CHAN_HT40MINUS); if (iface_info.current_chan_type == WS80211_CHAN_HT40MINUS) { ui->channelTypeComboBox->setCurrentIndex(ui->channelTypeComboBox->count() - 1); } } if (iface->channel_types & (1 << WS80211_CHAN_HT40PLUS)) { ui->channelTypeComboBox->addItem("HT 40+", WS80211_CHAN_HT40PLUS); if (iface_info.current_chan_type == WS80211_CHAN_HT40PLUS) { ui->channelTypeComboBox->setCurrentIndex(ui->channelTypeComboBox->count() - 1); } } if (ws80211_has_fcs_filter()) { ui->fcsComboBox->setCurrentIndex(iface_info.current_fcs_validation); } } } updateWidgets(); }