forked from osmocom/wireshark
Qt: Allow capture from hidden interfaces
Hidden interfaces where not able to be captured from, if they where displayed on the front page. This fixes that. Fixes #13354
This commit is contained in:
parent
e61fe552d0
commit
bf21921445
|
@ -1307,7 +1307,7 @@ collect_ifaces(capture_options *capture_opts)
|
|||
/* Now fill the list up again. */
|
||||
for (i = 0; i < capture_opts->all_ifaces->len; i++) {
|
||||
device = &g_array_index(capture_opts->all_ifaces, interface_t, i);
|
||||
if (!device->hidden && device->selected) {
|
||||
if (device->selected) {
|
||||
interface_opts.name = g_strdup(device->name);
|
||||
interface_opts.descr = g_strdup(device->friendly_name);
|
||||
interface_opts.ifname = NULL;
|
||||
|
|
|
@ -151,15 +151,12 @@ QMenu * InterfaceFrame::getSelectionMenu()
|
|||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// Disabled until bug 13354 is fixed
|
||||
contextMenu->addSeparator();
|
||||
QAction * toggleHideAction = new QAction(tr("Show hidden interfaces"), this);
|
||||
toggleHideAction->setCheckable(true);
|
||||
toggleHideAction->setChecked(! proxy_model_->filterHidden());
|
||||
toggleHideAction->setChecked(! proxy_model_.filterHidden());
|
||||
connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHiddenInterfaces()));
|
||||
contextMenu->addAction(toggleHideAction);
|
||||
#endif
|
||||
|
||||
return contextMenu;
|
||||
}
|
||||
|
@ -410,11 +407,15 @@ void InterfaceFrame::on_interfaceTree_doubleClicked(const QModelIndex &index)
|
|||
if (! realIndex.isValid())
|
||||
return;
|
||||
|
||||
QStringList interfaces;
|
||||
|
||||
#ifdef HAVE_LIBPCAP
|
||||
|
||||
QString device_name = source_model_.getColumnContent(realIndex.row(), IFTREE_COL_NAME).toString();
|
||||
QString extcap_string = source_model_.getColumnContent(realIndex.row(), IFTREE_COL_EXTCAP_PATH).toString();
|
||||
|
||||
interfaces << device_name;
|
||||
|
||||
/* We trust the string here. If this interface is really extcap, the string is
|
||||
* being checked immediatly before the dialog is being generated */
|
||||
if (extcap_string.length() > 0)
|
||||
|
@ -427,7 +428,8 @@ void InterfaceFrame::on_interfaceTree_doubleClicked(const QModelIndex &index)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
emit startCapture();
|
||||
|
||||
startCapture(interfaces);
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBPCAP
|
||||
|
@ -492,7 +494,21 @@ void InterfaceFrame::showContextMenu(QPoint pos)
|
|||
{
|
||||
QMenu ctx_menu;
|
||||
|
||||
ctx_menu.addAction(tr("Start capture"), this, SIGNAL(startCapture()));
|
||||
ctx_menu.addAction(tr("Start capture"), this, [=] () {
|
||||
QStringList ifaces;
|
||||
QModelIndexList selIndices = ui->interfaceTree->selectionModel()->selectedIndexes();
|
||||
foreach(QModelIndex idx, selIndices)
|
||||
{
|
||||
QModelIndex realIndex = proxy_model_.mapToSource(info_model_.mapToSource(idx));
|
||||
if (realIndex.column() != IFTREE_COL_NAME)
|
||||
realIndex = realIndex.siblingAtColumn(IFTREE_COL_NAME);
|
||||
QString name = realIndex.data(Qt::DisplayRole).toString();
|
||||
if (! ifaces.contains(name))
|
||||
ifaces << name;
|
||||
}
|
||||
|
||||
startCapture(ifaces);
|
||||
});
|
||||
ctx_menu.exec(ui->interfaceTree->mapToGlobal(pos));
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
|
||||
Q_SIGNALS:
|
||||
void showExtcapOptions(QString device_name, bool startCaptureOnClose);
|
||||
void startCapture();
|
||||
void startCapture(QStringList);
|
||||
void itemSelectionChanged();
|
||||
void typeSelectionChanged();
|
||||
|
||||
|
|
|
@ -589,8 +589,8 @@ main_ui_->goToLineEdit->setValidator(goToLineQiv);
|
|||
connect(main_ui_->mainStack, SIGNAL(currentChanged(int)),
|
||||
this, SLOT(mainStackChanged(int)));
|
||||
|
||||
connect(welcome_page_, SIGNAL(startCapture()),
|
||||
this, SLOT(startCapture()));
|
||||
connect(welcome_page_, SIGNAL(startCapture(QStringList)),
|
||||
this, SLOT(startCapture(QStringList)));
|
||||
connect(welcome_page_, SIGNAL(recentFileActivated(QString)),
|
||||
this, SLOT(openCaptureFile(QString)));
|
||||
|
||||
|
|
|
@ -388,7 +388,7 @@ private slots:
|
|||
* Start capturing from the selected interfaces using the capture filter
|
||||
* shown in the main welcome screen.
|
||||
*/
|
||||
void startCapture();
|
||||
void startCapture(QStringList);
|
||||
void pipeTimeout();
|
||||
void pipeActivated(int source);
|
||||
void pipeNotifierDestroyed();
|
||||
|
|
|
@ -831,13 +831,28 @@ void MainWindow::captureFileClosed() {
|
|||
|
||||
// ui/gtk/capture_dlg.c:start_capture_confirmed
|
||||
|
||||
void MainWindow::startCapture() {
|
||||
void MainWindow::startCapture(QStringList interfaces _U_) {
|
||||
#ifdef HAVE_LIBPCAP
|
||||
interface_options *interface_opts;
|
||||
guint i;
|
||||
interface_t *device;
|
||||
gboolean can_start_capture = TRUE;
|
||||
|
||||
if (interfaces.count() > 0) {
|
||||
global_capture_opts.num_selected = 0;
|
||||
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
||||
device = &g_array_index(global_capture_opts.all_ifaces, interface_t, i);
|
||||
|
||||
if (interfaces.contains(device->name)) {
|
||||
device->selected = TRUE;
|
||||
global_capture_opts.num_selected++;
|
||||
}
|
||||
else {
|
||||
device->selected = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* did the user ever select a capture interface before? */
|
||||
if (global_capture_opts.num_selected == 0) {
|
||||
QString msg = QString(tr("No interface selected."));
|
||||
|
@ -1495,7 +1510,7 @@ void MainWindow::startInterfaceCapture(bool valid, const QString capture_filter)
|
|||
if (testCaptureFileClose(before_what)) {
|
||||
// The interface tree will update the selected interfaces via its timer
|
||||
// so no need to do anything here.
|
||||
startCapture();
|
||||
startCapture(QStringList());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3964,7 +3979,7 @@ void MainWindow::on_actionCaptureStart_triggered()
|
|||
/* XXX - will closing this remove a temporary file? */
|
||||
QString before_what(tr(" before starting a new capture"));
|
||||
if (testCaptureFileClose(before_what)) {
|
||||
startCapture();
|
||||
startCapture(QStringList());
|
||||
} else {
|
||||
// simply clicking the button sets it to 'checked' even though we've
|
||||
// decided to do nothing, so undo that
|
||||
|
@ -3986,7 +4001,7 @@ void MainWindow::on_actionCaptureRestart_triggered()
|
|||
if (!testCaptureFileClose(before_what, Restart))
|
||||
return;
|
||||
|
||||
startCapture();
|
||||
startCapture(QStringList());
|
||||
#endif // HAVE_LIBPCAP
|
||||
}
|
||||
|
||||
|
@ -4116,7 +4131,7 @@ void MainWindow::extcap_options_finished(int result)
|
|||
if (result == QDialog::Accepted) {
|
||||
QString before_what(tr(" before starting a new capture"));
|
||||
if (testCaptureFileClose(before_what)) {
|
||||
startCapture();
|
||||
startCapture(QStringList());
|
||||
}
|
||||
}
|
||||
this->welcome_page_->getInterfaceFrame()->interfaceListChanged();
|
||||
|
|
|
@ -86,7 +86,7 @@ WelcomePage::WelcomePage(QWidget *parent) :
|
|||
connect(welcome_ui_->captureFilterComboBox, SIGNAL(captureFilterSyntaxChanged(bool)),
|
||||
this, SIGNAL(captureFilterSyntaxChanged(bool)));
|
||||
connect(welcome_ui_->captureFilterComboBox, SIGNAL(startCapture()),
|
||||
this, SIGNAL(startCapture()));
|
||||
this, SLOT(captureStarting()));
|
||||
connect(recent_files_, SIGNAL(itemActivated(QListWidgetItem *)), this, SLOT(openRecentItem(QListWidgetItem *)));
|
||||
updateRecentCaptures();
|
||||
|
||||
|
@ -248,9 +248,15 @@ void WelcomePage::on_interfaceFrame_showExtcapOptions(QString device_name, bool
|
|||
emit showExtcapOptions(device_name, startCaptureOnClose);
|
||||
}
|
||||
|
||||
void WelcomePage::on_interfaceFrame_startCapture()
|
||||
void WelcomePage::on_interfaceFrame_startCapture(QStringList ifaces)
|
||||
{
|
||||
emit startCapture();
|
||||
emit startCapture(ifaces);
|
||||
}
|
||||
|
||||
void WelcomePage::captureStarting()
|
||||
{
|
||||
welcome_ui_->interfaceFrame->ensureSelectedInterface();
|
||||
emit startCapture(QStringList());
|
||||
}
|
||||
|
||||
void WelcomePage::updateRecentCaptures() {
|
||||
|
|
|
@ -59,7 +59,7 @@ private:
|
|||
QListWidget *recent_files_;
|
||||
|
||||
signals:
|
||||
void startCapture();
|
||||
void startCapture(QStringList);
|
||||
void recentFileActivated(QString cfile);
|
||||
void captureFilterSyntaxChanged(bool valid);
|
||||
void showExtcapOptions(QString &device_name, bool startCaptureOnClose);
|
||||
|
@ -81,7 +81,8 @@ private slots:
|
|||
void removeRecentPath();
|
||||
|
||||
void on_interfaceFrame_showExtcapOptions(QString device_name, bool startCaptureOnClose);
|
||||
void on_interfaceFrame_startCapture();
|
||||
void on_interfaceFrame_startCapture(QStringList);
|
||||
void captureStarting();
|
||||
};
|
||||
|
||||
#endif // WELCOME_PAGE_H
|
||||
|
|
Loading…
Reference in New Issue