diff options
Diffstat (limited to 'ui/qt')
-rw-r--r-- | ui/qt/capture_filter_syntax_worker.cpp | 18 | ||||
-rw-r--r-- | ui/qt/capture_interfaces_dialog.cpp | 26 | ||||
-rw-r--r-- | ui/qt/capture_preferences_frame.cpp | 16 | ||||
-rw-r--r-- | ui/qt/compiled_filter_output.cpp | 6 | ||||
-rw-r--r-- | ui/qt/extcap_options_dialog.cpp | 31 | ||||
-rw-r--r-- | ui/qt/interface_toolbar.cpp | 14 | ||||
-rw-r--r-- | ui/qt/main_welcome.cpp | 20 | ||||
-rw-r--r-- | ui/qt/manage_interfaces_dialog.cpp | 60 | ||||
-rw-r--r-- | ui/qt/models/interface_tree_cache_model.cpp | 44 | ||||
-rw-r--r-- | ui/qt/models/interface_tree_model.cpp | 111 | ||||
-rw-r--r-- | ui/qt/widgets/capture_filter_edit.cpp | 8 | ||||
-rw-r--r-- | ui/qt/wireshark_application.cpp | 8 |
12 files changed, 166 insertions, 196 deletions
diff --git a/ui/qt/capture_filter_syntax_worker.cpp b/ui/qt/capture_filter_syntax_worker.cpp index 2132f50897..a578643b50 100644 --- a/ui/qt/capture_filter_syntax_worker.cpp +++ b/ui/qt/capture_filter_syntax_worker.cpp @@ -89,19 +89,19 @@ void CaptureFilterSyntaxWorker::start() { } for (guint if_idx = 0; if_idx < global_capture_opts.all_ifaces->len; if_idx++) { - interface_t device; + interface_t *device; - device = g_array_index(global_capture_opts.all_ifaces, interface_t, if_idx); - if (!device.locked && device.selected) { + device = &g_array_index(global_capture_opts.all_ifaces, interface_t, if_idx); + if (!device->locked && device->selected) { #ifdef HAVE_EXTCAP - if (device.if_info.extcap == NULL || strlen(device.if_info.extcap) == 0) { + if (device->if_info.extcap == NULL || strlen(device->if_info.extcap) == 0) { #endif - if (device.active_dlt >= DLT_USER0 && device.active_dlt <= DLT_USER15) { + if (device->active_dlt >= DLT_USER0 && device->active_dlt <= DLT_USER15) { // Capture filter for DLT_USER is unknown state = SyntaxLineEdit::Deprecated; err_str = "Unable to check capture filter"; } else { - active_dlts.insert(device.active_dlt); + active_dlts.insert(device->active_dlt); } #ifdef HAVE_EXTCAP } else { @@ -146,11 +146,11 @@ void CaptureFilterSyntaxWorker::start() { // If it's already invalid, don't bother to check extcap if (state != SyntaxLineEdit::Invalid) { foreach (guint extcapif, active_extcap.toList()) { - interface_t device; + interface_t *device; gchar *error = NULL; - device = g_array_index(global_capture_opts.all_ifaces, interface_t, extcapif); - extcap_filter_status status = extcap_verify_capture_filter(device.name, filter.toUtf8().constData(), &error); + device = &g_array_index(global_capture_opts.all_ifaces, interface_t, extcapif); + extcap_filter_status status = extcap_verify_capture_filter(device->name, filter.toUtf8().constData(), &error); if (status == EXTCAP_FILTER_VALID) { DEBUG_SYNTAX_CHECK("unknown", "known good"); } else if (status == EXTCAP_FILTER_INVALID) { diff --git a/ui/qt/capture_interfaces_dialog.cpp b/ui/qt/capture_interfaces_dialog.cpp index 9938fef49f..72cb2eba6f 100644 --- a/ui/qt/capture_interfaces_dialog.cpp +++ b/ui/qt/capture_interfaces_dialog.cpp @@ -247,22 +247,16 @@ void CaptureInterfacesDialog::updateGlobalDeviceSelections() while (*iter) { QString device_name = (*iter)->data(col_interface_, Qt::UserRole).value<QString>(); for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) { - interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, i); - if (device_name.compare(QString().fromUtf8(device.name)) == 0) { - if (!device.locked) { + interface_t *device = &g_array_index(global_capture_opts.all_ifaces, interface_t, i); + if (device_name.compare(QString().fromUtf8(device->name)) == 0) { + if (!device->locked) { if ((*iter)->isSelected()) { - device.selected = TRUE; + device->selected = TRUE; global_capture_opts.num_selected++; } else { - device.selected = FALSE; + device->selected = FALSE; } - device.locked = TRUE; - global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i); - g_array_insert_val(global_capture_opts.all_ifaces, i, device); - - device.locked = FALSE; - global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i); - g_array_insert_val(global_capture_opts.all_ifaces, i, device); + device->locked = FALSE; } break; } @@ -284,10 +278,10 @@ void CaptureInterfacesDialog::updateFromGlobalDeviceSelections() while (*iter) { QString device_name = (*iter)->data(col_interface_, Qt::UserRole).value<QString>(); for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) { - interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, i); - if (device_name.compare(QString().fromUtf8(device.name)) == 0) { - if ((bool)device.selected != (*iter)->isSelected()) { - (*iter)->setSelected(device.selected); + interface_t *device = &g_array_index(global_capture_opts.all_ifaces, interface_t, i); + if (device_name.compare(QString().fromUtf8(device->name)) == 0) { + if ((bool)device->selected != (*iter)->isSelected()) { + (*iter)->setSelected(device->selected); } break; } diff --git a/ui/qt/capture_preferences_frame.cpp b/ui/qt/capture_preferences_frame.cpp index 0028902565..24804ed765 100644 --- a/ui/qt/capture_preferences_frame.cpp +++ b/ui/qt/capture_preferences_frame.cpp @@ -71,7 +71,7 @@ void CapturePreferencesFrame::showEvent(QShowEvent *) void CapturePreferencesFrame::updateWidgets() { #ifdef HAVE_LIBPCAP - interface_t device; + interface_t *device; QString default_device_string; if (prefs_get_string_value(pref_device_, pref_stashed)) { @@ -87,20 +87,20 @@ void CapturePreferencesFrame::updateWidgets() wsApp->refreshLocalInterfaces(); } for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) { - device = g_array_index(global_capture_opts.all_ifaces, interface_t, i); + device = &g_array_index(global_capture_opts.all_ifaces, interface_t, i); /* Continue if capture device is hidden */ - if (device.hidden) { + if (device->hidden) { continue; } - // InterfaceTree matches against device.name when selecting the + // InterfaceTree matches against device->name when selecting the // default interface, so add it here if needed. On Windows this // means that we show the user a big ugly UUID-laden device path. - // We might be able to work around that by passing device.name as + // We might be able to work around that by passing device->name as // the userData argument to addItem instead. - QString item_text = device.display_name; - if (!item_text.contains(device.name)) { - item_text.append(QString(" (%1)").arg(device.name)); + QString item_text = device->display_name; + if (!item_text.contains(device->name)) { + item_text.append(QString(" (%1)").arg(device->name)); } ui->defaultInterfaceComboBox->addItem(item_text); } diff --git a/ui/qt/compiled_filter_output.cpp b/ui/qt/compiled_filter_output.cpp index 1d27d5a48d..e709adf80f 100644 --- a/ui/qt/compiled_filter_output.cpp +++ b/ui/qt/compiled_filter_output.cpp @@ -84,12 +84,12 @@ void CompiledFilterOutput::compileFilter() foreach (QString interfaces, intList_) { for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) { - interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, i); + interface_t *device = &g_array_index(global_capture_opts.all_ifaces, interface_t, i); - if (interfaces.compare(device.display_name)) { + if (interfaces.compare(device->display_name)) { continue; } else { - pcap_t *pd = pcap_open_dead(device.active_dlt, WTAP_MAX_PACKET_SIZE_STANDARD); + pcap_t *pd = pcap_open_dead(device->active_dlt, WTAP_MAX_PACKET_SIZE_STANDARD); if (pd == NULL) break; g_mutex_lock(pcap_compile_mtx); diff --git a/ui/qt/extcap_options_dialog.cpp b/ui/qt/extcap_options_dialog.cpp index 99e9b5743c..c70f5531bb 100644 --- a/ui/qt/extcap_options_dialog.cpp +++ b/ui/qt/extcap_options_dialog.cpp @@ -83,7 +83,7 @@ ExtcapOptionsDialog::ExtcapOptionsDialog(QWidget *parent) : ExtcapOptionsDialog * ExtcapOptionsDialog::createForDevice(QString &dev_name, QWidget *parent) { - interface_t device; + interface_t *device; ExtcapOptionsDialog * resultDialog = NULL; bool dev_found = false; guint if_idx; @@ -93,8 +93,8 @@ ExtcapOptionsDialog * ExtcapOptionsDialog::createForDevice(QString &dev_name, QW for (if_idx = 0; if_idx < global_capture_opts.all_ifaces->len; if_idx++) { - device = g_array_index(global_capture_opts.all_ifaces, interface_t, if_idx); - if (dev_name.compare(QString(device.name)) == 0 && device.if_info.type == IF_EXTCAP) + device = &g_array_index(global_capture_opts.all_ifaces, interface_t, if_idx); + if (dev_name.compare(QString(device->name)) == 0 && device->if_info.type == IF_EXTCAP) { dev_found = true; break; @@ -108,7 +108,7 @@ ExtcapOptionsDialog * ExtcapOptionsDialog::createForDevice(QString &dev_name, QW resultDialog->device_name = QString(dev_name); resultDialog->device_idx = if_idx; - resultDialog->setWindowTitle(wsApp->windowTitleString(tr("Interface Options") + ": " + device.display_name)); + resultDialog->setWindowTitle(wsApp->windowTitleString(tr("Interface Options") + ": " + device->display_name)); resultDialog->updateWidgets(); @@ -316,11 +316,11 @@ void ExtcapOptionsDialog::on_buttonBox_rejected() void ExtcapOptionsDialog::on_buttonBox_helpRequested() { - interface_t device; + interface_t *device; QString interface_help = NULL; - device = g_array_index(global_capture_opts.all_ifaces, interface_t, device_idx); - interface_help = QString(extcap_get_help_for_ifname(device.name)); + device = &g_array_index(global_capture_opts.all_ifaces, interface_t, device_idx); + interface_help = QString(extcap_get_help_for_ifname(device->name)); /* The extcap interface didn't provide an help. Let's go with the default */ if (interface_help.isEmpty()) { wsApp->helpTopicAction(HELP_EXTCAP_OPTIONS_DIALOG); @@ -343,7 +343,7 @@ void ExtcapOptionsDialog::on_buttonBox_helpRequested() { QMessageBox::warning(this, tr("Extcap Help cannot be found"), QString(tr("The help for the extcap interface %1 cannot be found. Given file: %2")) - .arg(device.name).arg(help_url.path()), + .arg(device->name).arg(help_url.path()), QMessageBox::Ok); } @@ -352,11 +352,9 @@ void ExtcapOptionsDialog::on_buttonBox_helpRequested() bool ExtcapOptionsDialog::saveOptionToCaptureInfo() { GHashTable * ret_args; - interface_t device; - - device = g_array_index(global_capture_opts.all_ifaces, interface_t, device_idx); - global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, device_idx); + interface_t *device; + device = &g_array_index(global_capture_opts.all_ifaces, interface_t, device_idx); ret_args = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); ExtcapArgumentList::const_iterator iter; @@ -381,12 +379,9 @@ bool ExtcapOptionsDialog::saveOptionToCaptureInfo() g_hash_table_insert(ret_args, call_string, value_string ); } - if (device.external_cap_args_settings != NULL) - g_hash_table_unref(device.external_cap_args_settings); - device.external_cap_args_settings = ret_args; - - g_array_insert_val(global_capture_opts.all_ifaces, device_idx, device); - + if (device->external_cap_args_settings != NULL) + g_hash_table_unref(device->external_cap_args_settings); + device->external_cap_args_settings = ret_args; return true; } diff --git a/ui/qt/interface_toolbar.cpp b/ui/qt/interface_toolbar.cpp index ffddf28f50..fed9cb919b 100644 --- a/ui/qt/interface_toolbar.cpp +++ b/ui/qt/interface_toolbar.cpp @@ -951,20 +951,20 @@ void InterfaceToolbar::interfaceListChanged() for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) { - interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, i); - if (device.hidden) + interface_t *device = &g_array_index(global_capture_opts.all_ifaces, interface_t, i); + if (device->hidden) continue; - if (interface_.keys().contains(device.name)) + if (interface_.keys().contains(device->name)) { - ui->interfacesComboBox->addItem(device.name); - if (selected_ifname.compare(device.name) == 0) + ui->interfacesComboBox->addItem(device->name); + if (selected_ifname.compare(device->name) == 0) { // Keep selected interface #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) - ui->interfacesComboBox->setCurrentText(device.name); + ui->interfacesComboBox->setCurrentText(device->name); #else - int new_index = ui->interfacesComboBox->findText(device.name); + int new_index = ui->interfacesComboBox->findText(device->name); if (new_index >= 0) { ui->interfacesComboBox->setCurrentIndex(new_index); diff --git a/ui/qt/main_welcome.cpp b/ui/qt/main_welcome.cpp index 30c13f656e..3d8fde8cd9 100644 --- a/ui/qt/main_welcome.cpp +++ b/ui/qt/main_welcome.cpp @@ -289,26 +289,24 @@ void MainWelcome::appInitialized() void MainWelcome::captureFilterTextEdited(const QString capture_filter) { if (global_capture_opts.num_selected > 0) { - interface_t device; + interface_t *device; for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) { - device = g_array_index(global_capture_opts.all_ifaces, interface_t, i); - if (!device.selected) { + device = &g_array_index(global_capture_opts.all_ifaces, interface_t, i); + if (!device->selected) { continue; } - // if (device.active_dlt == -1) { - // simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "The link type of interface %s was not specified.", device.name); + // if (device->active_dlt == -1) { + // simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "The link type of interface %s was not specified.", device->name); // continue; /* Programming error: somehow managed to select an "unsupported" entry */ // } - g_array_remove_index(global_capture_opts.all_ifaces, i); - g_free(device.cfilter); + g_free(device->cfilter); if (capture_filter.isEmpty()) { - device.cfilter = NULL; + device->cfilter = NULL; } else { - device.cfilter = qstring_strdup(capture_filter); + device->cfilter = qstring_strdup(capture_filter); } - g_array_insert_val(global_capture_opts.all_ifaces, i, device); - // update_filter_string(device.name, filter_text); + // update_filter_string(device->name, filter_text); } } } diff --git a/ui/qt/manage_interfaces_dialog.cpp b/ui/qt/manage_interfaces_dialog.cpp index d36d5521a0..5d48bdbe09 100644 --- a/ui/qt/manage_interfaces_dialog.cpp +++ b/ui/qt/manage_interfaces_dialog.cpp @@ -458,12 +458,10 @@ void ManageInterfacesDialog::remoteAccepted() while(*it) { for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) { - interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, i); - if ((*it)->text(col_r_host_dev_).compare(device.name)) + interface_t *device = &g_array_index(global_capture_opts.all_ifaces, interface_t, i); + if ((*it)->text(col_r_host_dev_).compare(device->name)) continue; - device.hidden = ((*it)->checkState(col_r_show_) == Qt::Checked ? false : true); - global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i); - g_array_insert_val(global_capture_opts.all_ifaces, i, device); + device->hidden = ((*it)->checkState(col_r_show_) == Qt::Checked ? false : true); } ++it; } @@ -481,11 +479,11 @@ void ManageInterfacesDialog::on_remoteList_itemClicked(QTreeWidgetItem *item, in } for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) { - interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, i); - if (!device.local) { - if (item->text(col_r_host_dev_).compare(device.name)) + interface_t *device = &g_array_index(global_capture_opts.all_ifaces, interface_t, i); + if (!device->local) { + if (item->text(col_r_host_dev_).compare(device->name)) continue; - device.hidden = (item->checkState(col_r_show_) == Qt::Checked ? false : true); + device->hidden = (item->checkState(col_r_show_) == Qt::Checked ? false : true); } } } @@ -498,8 +496,8 @@ void ManageInterfacesDialog::on_delRemote_clicked() } for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) { - interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, i); - if (item->text(col_r_host_dev_).compare(device.remote_opts.remote_host_opts.remote_host)) + interface_t *device = &g_array_index(global_capture_opts.all_ifaces, interface_t, i); + if (item->text(col_r_host_dev_).compare(device->remote_opts.remote_host_opts.remote_host)) continue; global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i); } @@ -516,22 +514,22 @@ void ManageInterfacesDialog::on_addRemote_clicked() void ManageInterfacesDialog::showRemoteInterfaces() { guint i; - interface_t device; + interface_t *device; QTreeWidgetItem *item = NULL; // We assume that remote interfaces are grouped by host. for (i = 0; i < global_capture_opts.all_ifaces->len; i++) { QTreeWidgetItem *child; - device = g_array_index(global_capture_opts.all_ifaces, interface_t, i); - if (!device.local) { - if (!item || item->text(col_r_host_dev_).compare(device.remote_opts.remote_host_opts.remote_host) != 0) { + device = &g_array_index(global_capture_opts.all_ifaces, interface_t, i); + if (!device->local) { + if (!item || item->text(col_r_host_dev_).compare(device->remote_opts.remote_host_opts.remote_host) != 0) { item = new QTreeWidgetItem(ui->remoteList); - item->setText(col_r_host_dev_, device.remote_opts.remote_host_opts.remote_host); + item->setText(col_r_host_dev_, device->remote_opts.remote_host_opts.remote_host); item->setExpanded(true); } child = new QTreeWidgetItem(item); - child->setCheckState(col_r_show_, device.hidden ? Qt::Unchecked : Qt::Checked); - child->setText(col_r_host_dev_, QString(device.name)); + child->setCheckState(col_r_show_, device->hidden ? Qt::Unchecked : Qt::Checked); + child->setText(col_r_host_dev_, QString(device->name)); } } } @@ -539,19 +537,19 @@ void ManageInterfacesDialog::showRemoteInterfaces() void ManageInterfacesDialog::on_remoteSettings_clicked() { guint i = 0; - interface_t device; + interface_t *device; QTreeWidgetItem* item = ui->remoteList->currentItem(); if (!item) { return; } for (i = 0; i < global_capture_opts.all_ifaces->len; i++) { - device = g_array_index(global_capture_opts.all_ifaces, interface_t, i); - if (!device.local) { - if (item->text(col_r_host_dev_).compare(device.name)) { + device = &g_array_index(global_capture_opts.all_ifaces, interface_t, i); + if (!device->local) { + if (item->text(col_r_host_dev_).compare(device->name)) { continue; } else { - RemoteSettingsDialog *dlg = new RemoteSettingsDialog(this, &device); + RemoteSettingsDialog *dlg = new RemoteSettingsDialog(this, device); dlg->show(); break; } @@ -562,19 +560,17 @@ void ManageInterfacesDialog::on_remoteSettings_clicked() void ManageInterfacesDialog::setRemoteSettings(interface_t *iface) { for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) { - interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, i); - if (!device.local) { - if (strcmp(iface->name, device.name)) { + interface_t *device = &g_array_index(global_capture_opts.all_ifaces, interface_t, i); + if (!device->local) { + if (strcmp(iface->name, device->name)) { continue; } - device.remote_opts.remote_host_opts.nocap_rpcap = iface->remote_opts.remote_host_opts.nocap_rpcap; - device.remote_opts.remote_host_opts.datatx_udp = iface->remote_opts.remote_host_opts.datatx_udp; + device->remote_opts.remote_host_opts.nocap_rpcap = iface->remote_opts.remote_host_opts.nocap_rpcap; + device->remote_opts.remote_host_opts.datatx_udp = iface->remote_opts.remote_host_opts.datatx_udp; #ifdef HAVE_PCAP_SETSAMPLING - device.remote_opts.sampling_method = iface->remote_opts.sampling_method; - device.remote_opts.sampling_param = iface->remote_opts.sampling_param; + device->remote_opts.sampling_method = iface->remote_opts.sampling_method; + device->remote_opts.sampling_param = iface->remote_opts.sampling_param; #endif //HAVE_PCAP_SETSAMPLING - global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i); - g_array_insert_val(global_capture_opts.all_ifaces, i, device); } } } diff --git a/ui/qt/models/interface_tree_cache_model.cpp b/ui/qt/models/interface_tree_cache_model.cpp index 0937dbcde6..3c1a6aa7d8 100644 --- a/ui/qt/models/interface_tree_cache_model.cpp +++ b/ui/qt/models/interface_tree_cache_model.cpp @@ -160,9 +160,9 @@ void InterfaceTreeCacheModel::save() for(unsigned int idx = 0; idx < global_capture_opts.all_ifaces->len; idx++) { - interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, idx); + interface_t *device = &g_array_index(global_capture_opts.all_ifaces, interface_t, idx); - if (! device.name ) + if (! device->name ) continue; /* Try to load a saved value row for this index */ @@ -184,10 +184,10 @@ void InterfaceTreeCacheModel::save() if ( col == IFTREE_COL_HIDDEN ) { - device.hidden = saveValue.toBool(); + device->hidden = saveValue.toBool(); } #ifdef HAVE_EXTCAP - else if ( device.if_info.type == IF_EXTCAP ) + else if ( device->if_info.type == IF_EXTCAP ) { /* extcap interfaces do not have the following columns. * ATTENTION: all generic columns must be added, BEFORE this @@ -196,12 +196,12 @@ void InterfaceTreeCacheModel::save() #endif else if ( col == IFTREE_COL_PROMISCUOUSMODE ) { - device.pmode = saveValue.toBool(); + device->pmode = saveValue.toBool(); } #ifdef HAVE_PCAP_CREATE else if ( col == IFTREE_COL_MONITOR_MODE ) { - device.monitor_mode_enabled = saveValue.toBool(); + device->monitor_mode_enabled = saveValue.toBool(); } #endif else if ( col == IFTREE_COL_SNAPLEN ) @@ -209,40 +209,36 @@ void InterfaceTreeCacheModel::save() int iVal = saveValue.toInt(); if ( iVal != WTAP_MAX_PACKET_SIZE_STANDARD ) { - device.has_snaplen = true; - device.snaplen = iVal; + device->has_snaplen = true; + device->snaplen = iVal; } else { - device.has_snaplen = false; - device.snaplen = WTAP_MAX_PACKET_SIZE_STANDARD; + device->has_snaplen = false; + device->snaplen = WTAP_MAX_PACKET_SIZE_STANDARD; } } #ifdef CAN_SET_CAPTURE_BUFFER_SIZE else if ( col == IFTREE_COL_BUFFERLEN ) { - device.buffer = saveValue.toInt(); + device->buffer = saveValue.toInt(); } #endif - - global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, idx); - g_array_insert_val(global_capture_opts.all_ifaces, idx, device); - ++it; } } QVariant content = getColumnContent(idx, IFTREE_COL_HIDDEN, Qt::CheckStateRole); if ( content.isValid() && static_cast<Qt::CheckState>(content.toInt()) == Qt::Unchecked ) - prefStorage[&prefs.capture_devices_hide] << QString(device.name); + prefStorage[&prefs.capture_devices_hide] << QString(device->name); content = getColumnContent(idx, IFTREE_COL_INTERFACE_COMMENT); if ( content.isValid() && content.toString().size() > 0 ) - prefStorage[&prefs.capture_devices_descr] << QString("%1(%2)").arg(device.name).arg(content.toString()); + prefStorage[&prefs.capture_devices_descr] << QString("%1(%2)").arg(device->name).arg(content.toString()); bool allowExtendedColumns = true; #ifdef HAVE_EXTCAP - if ( device.if_info.type == IF_EXTCAP ) + if ( device->if_info.type == IF_EXTCAP ) allowExtendedColumns = false; #endif if ( allowExtendedColumns ) @@ -251,13 +247,13 @@ void InterfaceTreeCacheModel::save() if ( content.isValid() ) { bool value = static_cast<Qt::CheckState>(content.toInt()) == Qt::Checked; - prefStorage[&prefs.capture_devices_pmode] << QString("%1(%2)").arg(device.name).arg(value ? 1 : 0); + prefStorage[&prefs.capture_devices_pmode] << QString("%1(%2)").arg(device->name).arg(value ? 1 : 0); } #ifdef HAVE_PCAP_CREATE content = getColumnContent(idx, IFTREE_COL_MONITOR_MODE, Qt::CheckStateRole); if ( content.isValid() && static_cast<Qt::CheckState>(content.toInt()) == Qt::Checked ) - prefStorage[&prefs.capture_devices_monitor_mode] << QString(device.name); + prefStorage[&prefs.capture_devices_monitor_mode] << QString(device->name); #endif content = getColumnContent(idx, IFTREE_COL_SNAPLEN); @@ -265,9 +261,9 @@ void InterfaceTreeCacheModel::save() { int value = content.toInt(); prefStorage[&prefs.capture_devices_snaplen] << - QString("%1:%2(%3)").arg(device.name). - arg(device.has_snaplen ? 1 : 0). - arg(device.has_snaplen ? value : WTAP_MAX_PACKET_SIZE_STANDARD); + QString("%1:%2(%3)").arg(device->name). + arg(device->has_snaplen ? 1 : 0). + arg(device->has_snaplen ? value : WTAP_MAX_PACKET_SIZE_STANDARD); } #ifdef CAN_SET_CAPTURE_BUFFER_SIZE @@ -278,7 +274,7 @@ void InterfaceTreeCacheModel::save() if ( value != -1 ) { prefStorage[&prefs.capture_devices_buffersize] << - QString("%1(%2)").arg(device.name). + QString("%1(%2)").arg(device->name). arg(value); } } diff --git a/ui/qt/models/interface_tree_model.cpp b/ui/qt/models/interface_tree_model.cpp index 7acda1340e..0f8cd29a1c 100644 --- a/ui/qt/models/interface_tree_model.cpp +++ b/ui/qt/models/interface_tree_model.cpp @@ -121,7 +121,7 @@ QVariant InterfaceTreeModel::data(const QModelIndex &index, int role) const if ( interfacesLoaded ) { - interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, row); + interface_t *device = &g_array_index(global_capture_opts.all_ifaces, interface_t, row); /* Data for display in cell */ if ( role == Qt::DisplayRole ) @@ -129,55 +129,55 @@ QVariant InterfaceTreeModel::data(const QModelIndex &index, int role) const /* Only the name is being displayed */ if ( col == IFTREE_COL_NAME ) { - return QString(device.display_name); + return QString(device->display_name); } else if ( col == IFTREE_COL_INTERFACE_NAME ) { - return QString(device.name); + return QString(device->name); } else if ( col == IFTREE_COL_PIPE_PATH ) { - return QString(device.if_info.name); + return QString(device->if_info.name); } else if ( col == IFTREE_COL_CAPTURE_FILTER ) { - if ( device.cfilter && strlen(device.cfilter) > 0 ) - return html_escape(QString(device.cfilter)); + if ( device->cfilter && strlen(device->cfilter) > 0 ) + return html_escape(QString(device->cfilter)); } #ifdef HAVE_EXTCAP else if ( col == IFTREE_COL_EXTCAP_PATH ) { - return QString(device.if_info.extcap); + return QString(device->if_info.extcap); } #endif else if ( col == IFTREE_COL_SNAPLEN ) { - return device.has_snaplen ? QString::number(device.snaplen) : DefaultNumericValue; + return device->has_snaplen ? QString::number(device->snaplen) : DefaultNumericValue; } #ifdef CAN_SET_CAPTURE_BUFFER_SIZE else if ( col == IFTREE_COL_BUFFERLEN ) { - return QString::number(device.buffer); + return QString::number(device->buffer); } #endif else if ( col == IFTREE_COL_TYPE ) { - return QVariant::fromValue((int)device.if_info.type); + return QVariant::fromValue((int)device->if_info.type); } else if ( col == IFTREE_COL_INTERFACE_COMMENT ) { - QString comment = gchar_free_to_qstring(capture_dev_user_descr_find(device.name)); + QString comment = gchar_free_to_qstring(capture_dev_user_descr_find(device->name)); if ( comment.length() > 0 ) return comment; else - return QString(device.if_info.vendor_description); + return QString(device->if_info.vendor_description); } else if ( col == IFTREE_COL_DLT ) { - QString linkname = QObject::tr("DLT %1").arg(device.active_dlt); - for (GList *list = device.links; list != NULL; list = g_list_next(list)) { + QString linkname = QObject::tr("DLT %1").arg(device->active_dlt); + for (GList *list = device->links; list != NULL; list = g_list_next(list)) { link_row *linkr = (link_row*)(list->data); - if (linkr->dlt != -1 && linkr->dlt == device.active_dlt) { + if (linkr->dlt != -1 && linkr->dlt == device->active_dlt) { linkname = linkr->name; break; } @@ -196,16 +196,16 @@ QVariant InterfaceTreeModel::data(const QModelIndex &index, int role) const if ( col == IFTREE_COL_HIDDEN ) { /* Hidden is a de-selection, therefore inverted logic here */ - return device.hidden ? Qt::Unchecked : Qt::Checked; + return device->hidden ? Qt::Unchecked : Qt::Checked; } else if ( col == IFTREE_COL_PROMISCUOUSMODE ) { - return device.pmode ? Qt::Checked : Qt::Unchecked; + return device->pmode ? Qt::Checked : Qt::Unchecked; } #ifdef HAVE_PCAP_CREATE else if ( col == IFTREE_COL_MONITOR_MODE ) { - return device.monitor_mode_enabled ? Qt::Checked : Qt::Unchecked; + return device->monitor_mode_enabled ? Qt::Checked : Qt::Unchecked; } #endif } @@ -214,12 +214,12 @@ QVariant InterfaceTreeModel::data(const QModelIndex &index, int role) const { if ( col == IFTREE_COL_STATS ) { - if ( points.contains(device.name) ) - return qVariantFromValue(points[device.name]); + if ( points.contains(device->name) ) + return qVariantFromValue(points[device->name]); } else if ( col == IFTREE_COL_HIDDEN ) { - return QVariant::fromValue((bool)device.hidden); + return QVariant::fromValue((bool)device->hidden); } } #ifdef HAVE_EXTCAP @@ -228,7 +228,7 @@ QVariant InterfaceTreeModel::data(const QModelIndex &index, int role) const { if ( col == IFTREE_COL_EXTCAP ) { - if ( device.if_info.type == IF_EXTCAP ) + if ( device->if_info.type == IF_EXTCAP ) return QIcon(StockIcon("x-capture-options")); } } @@ -322,8 +322,8 @@ QVariant InterfaceTreeModel::getColumnContent(int idx, int col, int role) #ifdef HAVE_PCAP_REMOTE bool InterfaceTreeModel::isRemote(int idx) { - interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, idx); - if ( device.remote_opts.src_type == CAPTURE_IFREMOTE ) + interface_t *device = &g_array_index(global_capture_opts.all_ifaces, interface_t, idx); + if ( device->remote_opts.src_type == CAPTURE_IFREMOTE ) return true; return false; } @@ -352,20 +352,20 @@ QVariant InterfaceTreeModel::toolTipForInterface(int idx) const if ( ! global_capture_opts.all_ifaces || global_capture_opts.all_ifaces->len <= (guint) idx) return QVariant(); - interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, idx); + interface_t *device = &g_array_index(global_capture_opts.all_ifaces, interface_t, idx); QString tt_str = "<p>"; - if ( device.no_addresses > 0 ) + if ( device->no_addresses > 0 ) { tt_str += QString("%1: %2") - .arg(device.no_addresses > 1 ? tr("Addresses") : tr("Address")) - .arg(html_escape(device.addresses)) + .arg(device->no_addresses > 1 ? tr("Addresses") : tr("Address")) + .arg(html_escape(device->addresses)) .replace('\n', ", "); } #ifdef HAVE_EXTCAP - else if ( device.if_info.type == IF_EXTCAP ) + else if ( device->if_info.type == IF_EXTCAP ) { - tt_str = QString(tr("Extcap interface: %1")).arg(get_basename(device.if_info.extcap)); + tt_str = QString(tr("Extcap interface: %1")).arg(get_basename(device->if_info.extcap)); } #endif else @@ -374,7 +374,7 @@ QVariant InterfaceTreeModel::toolTipForInterface(int idx) const } tt_str += "<br/>"; - QString cfilter = device.cfilter; + QString cfilter = device->cfilter; if ( cfilter.isEmpty() ) { tt_str += tr("No capture filter"); @@ -413,9 +413,9 @@ void InterfaceTreeModel::updateStatistic(unsigned int idx) if ( ! global_capture_opts.all_ifaces || global_capture_opts.all_ifaces->len <= (guint) idx ) return; - interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, idx); + interface_t *device = &g_array_index(global_capture_opts.all_ifaces, interface_t, idx); - if ( device.if_info.type == IF_PIPE ) + if ( device->if_info.type == IF_PIPE ) return; if ( !stat_cache_ ) @@ -430,20 +430,17 @@ void InterfaceTreeModel::updateStatistic(unsigned int idx) struct pcap_stat stats; diff = 0; - if ( capture_stats(stat_cache_, device.name, &stats) ) + if ( capture_stats(stat_cache_, device->name, &stats) ) { - if ( (int)(stats.ps_recv - device.last_packets) >= 0 ) + if ( (int)(stats.ps_recv - device->last_packets) >= 0 ) { - diff = stats.ps_recv - device.last_packets; - device.packet_diff = diff; + diff = stats.ps_recv - device->last_packets; + device->packet_diff = diff; } - device.last_packets = stats.ps_recv; - - global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, idx); - g_array_insert_val(global_capture_opts.all_ifaces, idx, device); + device->last_packets = stats.ps_recv; } - points[device.name].append(diff); + points[device->name].append(diff); emit dataChanged(index(idx, IFTREE_COL_STATS), index(idx, IFTREE_COL_STATS)); #else Q_UNUSED(idx) @@ -456,9 +453,9 @@ void InterfaceTreeModel::getPoints(int idx, PointList *pts) if ( ! global_capture_opts.all_ifaces || global_capture_opts.all_ifaces->len <= (guint) idx ) return; - interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, idx); - if ( points.contains(device.name) ) - pts->append(points[device.name]); + interface_t *device = &g_array_index(global_capture_opts.all_ifaces, interface_t, idx); + if ( points.contains(device->name) ) + pts->append(points[device->name]); #else Q_UNUSED(idx) Q_UNUSED(pts) @@ -471,9 +468,9 @@ QItemSelection InterfaceTreeModel::selectedDevices() #ifdef HAVE_LIBPCAP for( int idx = 0; idx < rowCount(); idx++ ) { - interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, idx); + interface_t *device = &g_array_index(global_capture_opts.all_ifaces, interface_t, idx); - if ( device.selected ) + if ( device->selected ) { QModelIndex selectIndex = index(idx, 0); mySelection.merge( @@ -514,27 +511,21 @@ bool InterfaceTreeModel::updateSelectedDevices(QItemSelection sourceSelection) for ( unsigned int idx = 0; idx < global_capture_opts.all_ifaces->len; idx++ ) { - interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, idx); - if ( !device.locked ) + interface_t *device = &g_array_index(global_capture_opts.all_ifaces, interface_t, idx); + if ( !device->locked ) { if ( selectedIndices.contains(idx) ) { - if (! device.selected ) + if (! device->selected ) selectionHasChanged = true; - device.selected = TRUE; + device->selected = TRUE; global_capture_opts.num_selected++; } else { - if ( device.selected ) + if ( device->selected ) selectionHasChanged = true; - device.selected = FALSE; + device->selected = FALSE; } - device.locked = TRUE; - global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, idx); - g_array_insert_val(global_capture_opts.all_ifaces, idx, device); - - device.locked = FALSE; - global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, idx); - g_array_insert_val(global_capture_opts.all_ifaces, idx, device); + device->locked = FALSE; } } #else diff --git a/ui/qt/widgets/capture_filter_edit.cpp b/ui/qt/widgets/capture_filter_edit.cpp index a771e38809..78f60def27 100644 --- a/ui/qt/widgets/capture_filter_edit.cpp +++ b/ui/qt/widgets/capture_filter_edit.cpp @@ -256,13 +256,13 @@ QPair<const QString, bool> CaptureFilterEdit::getSelectedFilter() int selected_devices = 0; for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) { - interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, i); - if (device.selected) { + interface_t *device = &g_array_index(global_capture_opts.all_ifaces, interface_t, i); + if (device->selected) { selected_devices++; if (selected_devices == 1) { - user_filter = device.cfilter; + user_filter = device->cfilter; } else { - if (user_filter.compare(device.cfilter)) { + if (user_filter.compare(device->cfilter)) { filter_conflict = true; } } diff --git a/ui/qt/wireshark_application.cpp b/ui/qt/wireshark_application.cpp index e0fb241143..d6d46f38d5 100644 --- a/ui/qt/wireshark_application.cpp +++ b/ui/qt/wireshark_application.cpp @@ -1026,12 +1026,12 @@ iface_mon_event_cb(const char *iface, int up) { int present = 0; guint ifs, j; - interface_t device; + interface_t *device; interface_options interface_opts; for (ifs = 0; ifs < global_capture_opts.all_ifaces->len; ifs++) { - device = g_array_index(global_capture_opts.all_ifaces, interface_t, ifs); - if (strcmp(device.name, iface) == 0) { + device = &g_array_index(global_capture_opts.all_ifaces, interface_t, ifs); + if (strcmp(device->name, iface) == 0) { present = 1; if (!up) { /* @@ -1041,7 +1041,7 @@ iface_mon_event_cb(const char *iface, int up) */ for (j = 0; j < global_capture_opts.ifaces->len; j++) { interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, j); - if (strcmp(interface_opts.name, device.name) == 0) { + if (strcmp(interface_opts.name, device->name) == 0) { g_array_remove_index(global_capture_opts.ifaces, j); } } |