2013-02-01 00:14:15 +00:00
|
|
|
/* capture_preferences_frame.cpp
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-04-30 07:47:58 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2013-02-01 00:14:15 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
2014-06-24 09:36:51 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
|
|
|
#include "ui/capture_globals.h"
|
|
|
|
#endif
|
|
|
|
|
2013-02-01 00:14:15 +00:00
|
|
|
#include "capture_preferences_frame.h"
|
2017-12-29 16:23:07 +00:00
|
|
|
#include <ui/qt/models/pref_models.h>
|
2015-06-25 16:17:03 +00:00
|
|
|
#include <ui_capture_preferences_frame.h>
|
2014-07-25 22:48:59 +00:00
|
|
|
#include "wireshark_application.h"
|
2013-02-01 00:14:15 +00:00
|
|
|
|
|
|
|
#include <QSpacerItem>
|
|
|
|
|
2014-06-30 01:36:22 +00:00
|
|
|
#include "ui/capture_ui_utils.h"
|
2017-10-14 20:14:14 +00:00
|
|
|
#include "ui/ws_ui_util.h"
|
2013-02-01 00:14:15 +00:00
|
|
|
|
|
|
|
#include <epan/prefs-int.h>
|
|
|
|
|
|
|
|
CapturePreferencesFrame::CapturePreferencesFrame(QWidget *parent) :
|
|
|
|
QFrame(parent),
|
|
|
|
ui(new Ui::CapturePreferencesFrame)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
pref_device_ = prefFromPrefPtr(&prefs.capture_device);
|
|
|
|
pref_prom_mode_ = prefFromPrefPtr(&prefs.capture_prom_mode);
|
|
|
|
pref_pcap_ng_ = prefFromPrefPtr(&prefs.capture_pcap_ng);
|
|
|
|
pref_real_time_ = prefFromPrefPtr(&prefs.capture_real_time);
|
|
|
|
pref_auto_scroll_ = prefFromPrefPtr(&prefs.capture_auto_scroll);
|
2018-09-26 13:19:08 +00:00
|
|
|
pref_no_interface_load_ = prefFromPrefPtr(&prefs.capture_no_interface_load);
|
2018-01-07 21:06:13 +00:00
|
|
|
pref_no_extcap_ = prefFromPrefPtr(&prefs.capture_no_extcap);
|
2013-02-01 00:14:15 +00:00
|
|
|
|
|
|
|
// Setting the left margin via a style sheet clobbers its
|
|
|
|
// appearance.
|
|
|
|
int margin = style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
|
|
|
|
QRect geom = ui->defaultInterfaceSpacer->geometry();
|
|
|
|
geom.setWidth(margin);
|
|
|
|
ui->defaultInterfaceSpacer->setGeometry(geom);
|
|
|
|
}
|
|
|
|
|
|
|
|
CapturePreferencesFrame::~CapturePreferencesFrame()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2015-07-07 22:13:24 +00:00
|
|
|
void CapturePreferencesFrame::showEvent(QShowEvent *)
|
2013-02-01 00:14:15 +00:00
|
|
|
{
|
|
|
|
updateWidgets();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CapturePreferencesFrame::updateWidgets()
|
|
|
|
{
|
2013-10-11 21:42:49 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
2017-08-24 14:16:34 +00:00
|
|
|
interface_t *device;
|
2015-07-10 05:50:19 +00:00
|
|
|
QString default_device_string;
|
2013-02-01 00:14:15 +00:00
|
|
|
|
2017-01-07 13:52:23 +00:00
|
|
|
if (prefs_get_string_value(pref_device_, pref_stashed)) {
|
|
|
|
default_device_string = prefs_get_string_value(pref_device_, pref_stashed);
|
2015-07-10 05:50:19 +00:00
|
|
|
}
|
2013-02-01 00:14:15 +00:00
|
|
|
ui->defaultInterfaceComboBox->clear();
|
2019-05-13 20:51:10 +00:00
|
|
|
if ((global_capture_opts.all_ifaces->len == 0) &&
|
|
|
|
(prefs_get_bool_value(pref_no_interface_load_, pref_stashed) == FALSE)) {
|
2014-07-25 22:48:59 +00:00
|
|
|
/*
|
|
|
|
* No interfaces - try refreshing the local interfaces, to
|
|
|
|
* see whether any have showed up (or privileges have changed
|
|
|
|
* to allow us to access them).
|
|
|
|
*/
|
|
|
|
wsApp->refreshLocalInterfaces();
|
|
|
|
}
|
|
|
|
for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
2017-08-24 14:16:34 +00:00
|
|
|
device = &g_array_index(global_capture_opts.all_ifaces, interface_t, i);
|
2014-07-25 22:48:59 +00:00
|
|
|
|
|
|
|
/* Continue if capture device is hidden */
|
2017-08-24 14:16:34 +00:00
|
|
|
if (device->hidden) {
|
2014-07-25 22:48:59 +00:00
|
|
|
continue;
|
2014-06-24 09:36:51 +00:00
|
|
|
}
|
2017-08-24 14:16:34 +00:00
|
|
|
// InterfaceTree matches against device->name when selecting the
|
2016-01-09 00:16:33 +00:00
|
|
|
// default interface, so add it here if needed. On Windows this
|
|
|
|
// means that we show the user a big ugly UUID-laden device path.
|
2017-08-24 14:16:34 +00:00
|
|
|
// We might be able to work around that by passing device->name as
|
2016-01-09 00:16:33 +00:00
|
|
|
// the userData argument to addItem instead.
|
2017-08-24 14:16:34 +00:00
|
|
|
QString item_text = device->display_name;
|
|
|
|
if (!item_text.contains(device->name)) {
|
|
|
|
item_text.append(QString(" (%1)").arg(device->name));
|
2016-01-09 00:16:33 +00:00
|
|
|
}
|
|
|
|
ui->defaultInterfaceComboBox->addItem(item_text);
|
2013-02-01 00:14:15 +00:00
|
|
|
}
|
|
|
|
|
2015-07-10 05:50:19 +00:00
|
|
|
if (!default_device_string.isEmpty()) {
|
|
|
|
ui->defaultInterfaceComboBox->setEditText(default_device_string);
|
2013-02-01 00:14:15 +00:00
|
|
|
} else {
|
|
|
|
ui->defaultInterfaceComboBox->clearEditText();
|
|
|
|
}
|
|
|
|
|
2017-01-07 13:52:23 +00:00
|
|
|
ui->capturePromModeCheckBox->setChecked(prefs_get_bool_value(pref_prom_mode_, pref_stashed));
|
|
|
|
ui->capturePcapNgCheckBox->setChecked(prefs_get_bool_value(pref_pcap_ng_, pref_stashed));
|
|
|
|
ui->captureRealTimeCheckBox->setChecked(prefs_get_bool_value(pref_real_time_, pref_stashed));
|
|
|
|
ui->captureAutoScrollCheckBox->setChecked(prefs_get_bool_value(pref_auto_scroll_, pref_stashed));
|
2013-10-11 21:42:49 +00:00
|
|
|
#endif // HAVE_LIBPCAP
|
2018-09-26 13:19:08 +00:00
|
|
|
ui->captureNoInterfaceLoad->setChecked(prefs_get_bool_value(pref_no_interface_load_, pref_stashed));
|
2018-01-07 21:06:13 +00:00
|
|
|
ui->captureNoExtcapCheckBox->setChecked(prefs_get_bool_value(pref_no_extcap_, pref_stashed));
|
2013-02-01 00:14:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CapturePreferencesFrame::on_defaultInterfaceComboBox_editTextChanged(const QString &new_iface)
|
|
|
|
{
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_string_value(pref_device_, new_iface.toUtf8().constData(), pref_stashed);
|
2013-02-01 00:14:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CapturePreferencesFrame::on_capturePromModeCheckBox_toggled(bool checked)
|
|
|
|
{
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_bool_value(pref_prom_mode_, checked, pref_stashed);
|
2013-02-01 00:14:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CapturePreferencesFrame::on_capturePcapNgCheckBox_toggled(bool checked)
|
|
|
|
{
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_bool_value(pref_pcap_ng_, checked, pref_stashed);
|
2013-02-01 00:14:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CapturePreferencesFrame::on_captureRealTimeCheckBox_toggled(bool checked)
|
|
|
|
{
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_bool_value(pref_real_time_, checked, pref_stashed);
|
2013-02-01 00:14:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CapturePreferencesFrame::on_captureAutoScrollCheckBox_toggled(bool checked)
|
|
|
|
{
|
2017-01-07 13:52:23 +00:00
|
|
|
prefs_set_bool_value(pref_auto_scroll_, checked, pref_stashed);
|
2013-02-01 00:14:15 +00:00
|
|
|
}
|
|
|
|
|
2018-09-26 13:19:08 +00:00
|
|
|
void CapturePreferencesFrame::on_captureNoInterfaceLoad_toggled(bool checked)
|
|
|
|
{
|
|
|
|
prefs_set_bool_value(pref_no_interface_load_, checked, pref_stashed);
|
|
|
|
}
|
|
|
|
|
2018-01-07 21:06:13 +00:00
|
|
|
void CapturePreferencesFrame::on_captureNoExtcapCheckBox_toggled(bool checked)
|
|
|
|
{
|
|
|
|
prefs_set_bool_value(pref_no_extcap_, checked, pref_stashed);
|
|
|
|
}
|