1 /* main_window_slots.cpp
3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 // Qt 5.5.0 + Visual C++ 2013
27 #pragma warning(disable:4996)
30 #include "main_window.h"
31 #include <ui_main_window.h>
38 #include "ui/capture.h"
41 #include "epan/color_filters.h"
43 #include "wsutil/file_util.h"
44 #include "wsutil/filesystem.h"
45 #include "wsutil/str_util.h"
47 #include "epan/addr_resolv.h"
48 #include "epan/dissector_filters.h"
49 #include "epan/column.h"
50 #include "epan/dfilter/dfilter-macro.h"
51 #include "epan/epan_dissect.h"
52 #include "epan/filter_expressions.h"
53 #include "epan/prefs.h"
55 #include "epan/value_string.h"
58 #include <epan/wslua/init_wslua.h>
61 #include "ui/alert_box.h"
63 #include "ui/capture_ui_utils.h"
66 #include "ui/capture_globals.h"
67 #include "ui/help_url.h"
68 #include "ui/main_statusbar.h"
69 #include "ui/preference_utils.h"
70 #include "ui/recent.h"
71 #include "ui/recent_utils.h"
72 #include "ui/ssl_key_export.h"
73 #include "ui/ui_util.h"
74 #include "ui/qt/simple_dialog.h"
76 #ifdef HAVE_SOFTWARE_UPDATE
77 #include "ui/software_update.h"
80 #include "about_dialog.h"
81 #include "bluetooth_att_server_attributes_dialog.h"
82 #include "bluetooth_devices_dialog.h"
83 #include "bluetooth_hci_summary_dialog.h"
84 #include "capture_file_dialog.h"
85 #include "capture_file_properties_dialog.h"
86 #include "color_utils.h"
87 #include "coloring_rules_dialog.h"
88 #include "conversation_dialog.h"
89 #include "conversation_hash_tables_dialog.h"
90 #include "enabled_protocols_dialog.h"
91 #include "decode_as_dialog.h"
92 #include "display_filter_edit.h"
93 #include "display_filter_expression_dialog.h"
94 #include "dissector_tables_dialog.h"
95 #include "endpoint_dialog.h"
96 #include "expert_info_dialog.h"
97 #include "export_object_dialog.h"
98 #include "export_pdu_dialog.h"
100 #include "extcap_options_dialog.h"
102 #include "filter_action.h"
103 #include "filter_dialog.h"
104 #include "funnel_statistics.h"
105 #include "gsm_map_summary_dialog.h"
106 #include "iax2_analysis_dialog.h"
107 #include "io_graph_dialog.h"
108 #include "lbm_stream_dialog.h"
109 #include "lbm_uimflow_dialog.h"
110 #include "lbm_lbtrm_transport_dialog.h"
111 #include "lbm_lbtru_transport_dialog.h"
112 #include "lte_mac_statistics_dialog.h"
113 #include "lte_rlc_statistics_dialog.h"
114 #include "lte_rlc_graph_dialog.h"
115 #include "mtp3_summary_dialog.h"
116 #include "multicast_statistics_dialog.h"
117 #include "packet_comment_dialog.h"
118 #include "packet_dialog.h"
119 #include "packet_list.h"
120 #include "preferences_dialog.h"
121 #include "print_dialog.h"
122 #include "profile_dialog.h"
123 #include "protocol_hierarchy_dialog.h"
124 #include "qt_ui_utils.h"
125 #include "resolved_addresses_dialog.h"
126 #include "rpc_service_response_time_dialog.h"
127 #include "rtp_stream_dialog.h"
128 #include "rtp_analysis_dialog.h"
129 #include "sctp_all_assocs_dialog.h"
130 #include "sctp_assoc_analyse_dialog.h"
131 #include "sctp_graph_dialog.h"
132 #include "sequence_dialog.h"
133 #include "stats_tree_dialog.h"
134 #include "stock_icon.h"
135 #include "supported_protocols_dialog.h"
136 #include "tap_parameter_dialog.h"
137 #include "tcp_stream_dialog.h"
138 #include "time_shift_dialog.h"
139 #include "uat_dialog.h"
140 #include "voip_calls_dialog.h"
141 #include "wireshark_application.h"
142 #include "wlan_statistics_dialog.h"
144 #include <QClipboard>
146 #include <QMessageBox>
147 #include <QMetaObject>
149 #include <QDesktopServices>
157 static const char *dfe_property_ = "display filter expression"; //TODO : Fix Translate
159 // We're too lazy to sublcass QAction.
160 static const char *color_number_property_ = "color number";
162 bool MainWindow::openCaptureFile(QString cf_path, QString read_filter, unsigned int type)
164 QString file_name = "";
165 dfilter_t *rfcode = NULL;
170 // was a file name given as function parameter?
171 name_param = !cf_path.isEmpty();
175 if (cf_path.isEmpty()) {
176 CaptureFileDialog open_dlg(this, capture_file_.capFile(), read_filter);
178 switch (prefs.gui_fileopen_style) {
180 case FO_STYLE_LAST_OPENED:
181 /* The user has specified that we should start out in the last directory
182 we looked in. If we've already opened a file, use its containing
183 directory, if we could determine it, as the directory, otherwise
184 use the "last opened" directory saved in the preferences file if
186 /* This is now the default behaviour in file_selection_new() */
189 case FO_STYLE_SPECIFIED:
190 /* The user has specified that we should always start out in a
191 specified directory; if they've specified that directory,
192 start out by showing the files in that dir. */
193 if (prefs.gui_fileopen_dir[0] != '\0')
194 open_dlg.setDirectory(prefs.gui_fileopen_dir);
198 if (open_dlg.open(file_name, type)) {
205 if (!testCaptureFileClose()) {
209 if (dfilter_compile(read_filter.toUtf8().constData(), &rfcode, &err_msg)) {
210 cf_set_rfcode(CaptureFile::globalCapFile(), rfcode);
212 /* Not valid. Tell the user, and go back and run the file
213 selection box again once they dismiss the alert. */
214 //bad_dfilter_alert_box(top_level, read_filter->str);
215 QMessageBox::warning(this, tr("Invalid Display Filter"),
216 QString("The filter expression ") +
218 QString(" isn't a valid display filter. (") +
219 err_msg + QString(")."),
223 // go back to the selection dialogue only if the file
224 // was selected from this dialogue
230 /* Try to open the capture file. This closes the current file if it succeeds. */
231 CaptureFile::globalCapFile()->window = this;
232 if (cf_open(CaptureFile::globalCapFile(), cf_path.toUtf8().constData(), type, FALSE, &err) != CF_OK) {
233 /* We couldn't open it; don't dismiss the open dialog box,
234 just leave it around so that the user can, after they
235 dismiss the alert box popped up for the open error,
237 CaptureFile::globalCapFile()->window = NULL;
239 dfilter_free(rfcode);
244 switch (cf_read(CaptureFile::globalCapFile(), FALSE)) {
248 /* Just because we got an error, that doesn't mean we were unable
249 to read any of the file; we handle what we could get from the
253 case CF_READ_ABORTED:
254 /* The user bailed out of re-reading the capture file; the
255 capture file has been closed - just free the capture file name
256 string and return (without changing the last containing
258 capture_file_.setCapFile(NULL);
263 // get_dirname overwrites its path. Hopefully this isn't a problem.
264 wsApp->setLastOpenDir(get_dirname(cf_path.toUtf8().data()));
266 main_ui_->statusBar->showExpert();
271 void MainWindow::filterPackets(QString new_filter, bool force)
273 cf_status_t cf_status;
275 cf_status = cf_filter_packets(CaptureFile::globalCapFile(), new_filter.toUtf8().data(), force);
277 if (cf_status == CF_OK) {
278 emit displayFilterSuccess(true);
279 if (new_filter.length() > 0) {
280 int index = df_combo_box_->findText(new_filter);
282 df_combo_box_->insertItem(0, new_filter);
283 df_combo_box_->setCurrentIndex(0);
285 df_combo_box_->setCurrentIndex(index);
288 df_combo_box_->lineEdit()->clear();
291 emit displayFilterSuccess(false);
294 packet_list_->resetColumns();
298 // A new layout should be applied when it differs from the old layout AND
299 // at the following times:
301 // - When the preferences change
302 // - When the profile changes
303 void MainWindow::layoutPanes()
305 QVector<unsigned> new_layout = QVector<unsigned>() << prefs.gui_layout_type
306 << prefs.gui_layout_content_1
307 << prefs.gui_layout_content_2
308 << prefs.gui_layout_content_3
309 << recent.packet_list_show
310 << recent.tree_view_show
311 << recent.byte_view_show;
313 if (cur_layout_ == new_layout) return;
315 QSplitter *parents[3];
316 int current_row = capture_file_.currentRow();
318 // Reparent all widgets and add them back in the proper order below.
319 // This hides each widget as well.
320 packet_list_->freeze(); // Clears tree and byte view tabs.
321 packet_list_->setParent(main_ui_->mainStack);
322 proto_tree_->setParent(main_ui_->mainStack);
323 byte_view_tab_->setParent(main_ui_->mainStack);
324 empty_pane_.setParent(main_ui_->mainStack);
325 extra_split_.setParent(main_ui_->mainStack);
327 // XXX We should try to preserve geometries if we can, e.g. by
328 // checking to see if the layout type is the same.
329 switch(prefs.gui_layout_type) {
332 extra_split_.setOrientation(Qt::Horizontal);
335 master_split_.setOrientation(Qt::Vertical);
340 extra_split_.setOrientation(Qt::Vertical);
343 master_split_.setOrientation(Qt::Horizontal);
347 g_assert_not_reached();
350 switch(prefs.gui_layout_type) {
353 parents[0] = &master_split_;
354 parents[1] = &master_split_;
355 parents[2] = &master_split_;
359 parents[0] = &master_split_;
360 parents[1] = &extra_split_;
361 parents[2] = &extra_split_;
365 parents[0] = &extra_split_;
366 parents[1] = &extra_split_;
367 parents[2] = &master_split_;
370 g_assert_not_reached();
373 if (parents[0] == &extra_split_) {
374 master_split_.addWidget(&extra_split_);
377 parents[0]->addWidget(getLayoutWidget(prefs.gui_layout_content_1));
379 if (parents[2] == &extra_split_) {
380 master_split_.addWidget(&extra_split_);
383 parents[1]->addWidget(getLayoutWidget(prefs.gui_layout_content_2));
384 parents[2]->addWidget(getLayoutWidget(prefs.gui_layout_content_3));
386 const QList<QWidget *> ms_children = master_split_.findChildren<QWidget *>();
388 extra_split_.setVisible(ms_children.contains(&extra_split_));
389 packet_list_->setVisible(ms_children.contains(packet_list_) && recent.packet_list_show);
390 proto_tree_->setVisible(ms_children.contains(proto_tree_) && recent.tree_view_show);
391 byte_view_tab_->setVisible(ms_children.contains(byte_view_tab_) && recent.byte_view_show);
393 packet_list_->thaw();
394 cf_select_packet(capture_file_.capFile(), current_row); // XXX Doesn't work for row 0?
395 cur_layout_ = new_layout;
398 // The recent layout geometry should be applied after the layout has been
399 // applied AND at the following times:
401 // - When the profile changes
402 void MainWindow::applyRecentPaneGeometry()
404 // XXX This shrinks slightly each time the application is run. For some
405 // reason the master_split_ geometry is two pixels shorter when
406 // saveWindowGeometry is invoked.
408 // This is also an awful lot of trouble to go through to reuse the GTK+
409 // pane settings. We might want to add gui.geometry_main_master_sizes
410 // and gui.geometry_main_extra_sizes and save QSplitter::saveState in
413 // Force a geometry recalculation
414 QWidget *cur_w = main_ui_->mainStack->currentWidget();
415 main_ui_->mainStack->setCurrentWidget(&master_split_);
416 QRect geom = master_split_.geometry();
417 QList<int> master_sizes = master_split_.sizes();
418 QList<int> extra_sizes = extra_split_.sizes();
419 main_ui_->mainStack->setCurrentWidget(cur_w);
421 int master_last_size = master_split_.orientation() == Qt::Vertical ? geom.height() : geom.width();
422 int extra_last_size = extra_split_.orientation() == Qt::Vertical ? geom.height() : geom.width();
424 if (recent.gui_geometry_main_upper_pane > 0) {
425 master_sizes[0] = recent.gui_geometry_main_upper_pane + 1; // Add back mystery pixel
426 master_last_size -= recent.gui_geometry_main_upper_pane + master_split_.handleWidth();
429 if (recent.gui_geometry_main_lower_pane > 0) {
430 if (master_sizes.length() > 2) {
431 master_sizes[1] = recent.gui_geometry_main_lower_pane + 1; // Add back mystery pixel
432 master_last_size -= recent.gui_geometry_main_lower_pane + master_split_.handleWidth();
433 } else if (extra_sizes.length() > 0) {
434 extra_sizes[0] = recent.gui_geometry_main_lower_pane; // No mystery pixel
435 extra_last_size -= recent.gui_geometry_main_lower_pane + extra_split_.handleWidth();
436 extra_sizes.last() = extra_last_size;
440 master_sizes.last() = master_last_size;
442 master_split_.setSizes(master_sizes);
443 extra_split_.setSizes(extra_sizes);
446 void MainWindow::layoutToolbars()
448 Qt::ToolButtonStyle tbstyle = Qt::ToolButtonIconOnly;
449 switch (prefs.gui_toolbar_main_style) {
451 tbstyle = Qt::ToolButtonTextOnly;
454 tbstyle = Qt::ToolButtonTextUnderIcon;
458 main_ui_->mainToolBar->setToolButtonStyle(tbstyle);
460 main_ui_->mainToolBar->setVisible(recent.main_toolbar_show);
461 main_ui_->displayFilterToolBar->setVisible(recent.filter_toolbar_show);
462 main_ui_->wirelessToolBar->setVisible(recent.wireless_toolbar_show);
463 main_ui_->statusBar->setVisible(recent.statusbar_show);
466 void MainWindow::updatePreferenceActions()
468 main_ui_->actionViewNameResolutionPhysical->setChecked(gbl_resolv_flags.mac_name);
469 main_ui_->actionViewNameResolutionNetwork->setChecked(gbl_resolv_flags.network_name);
470 main_ui_->actionViewNameResolutionTransport->setChecked(gbl_resolv_flags.transport_name);
472 // Should this be a "recent" setting?
473 main_ui_->actionGoAutoScroll->setChecked(prefs.capture_auto_scroll);
476 void MainWindow::updateRecentActions()
478 main_ui_->actionViewMainToolbar->setChecked(recent.main_toolbar_show);
479 main_ui_->actionViewFilterToolbar->setChecked(recent.filter_toolbar_show);
480 main_ui_->actionViewWirelessToolbar->setChecked(recent.wireless_toolbar_show);
481 main_ui_->actionViewStatusBar->setChecked(recent.statusbar_show);
482 main_ui_->actionViewPacketList->setChecked(recent.packet_list_show);
483 main_ui_->actionViewPacketDetails->setChecked(recent.tree_view_show);
484 main_ui_->actionViewPacketBytes->setChecked(recent.byte_view_show);
486 foreach (QAction* tda, td_actions.keys()) {
487 if (recent.gui_time_format == td_actions[tda]) {
488 tda->setChecked(true);
491 foreach (QAction* tpa, tp_actions.keys()) {
492 if (recent.gui_time_precision == tp_actions[tpa]) {
493 tpa->setChecked(true);
496 main_ui_->actionViewTimeDisplaySecondsWithHoursAndMinutes->setChecked(recent.gui_seconds_format == TS_SECONDS_HOUR_MIN_SEC);
498 main_ui_->actionViewColorizePacketList->setChecked(recent.packet_list_colorize);
501 void MainWindow::filterAction(QString &action_filter, FilterAction::Action action, FilterAction::ActionType type)
503 QString cur_filter, new_filter;
505 if (!df_combo_box_) return;
506 cur_filter = df_combo_box_->lineEdit()->text();
509 case FilterAction::ActionTypePlain:
510 new_filter = action_filter;
512 case FilterAction::ActionTypeAnd:
513 if (cur_filter.length()) {
514 new_filter = "(" + cur_filter + ") && (" + action_filter + ")";
516 new_filter = action_filter;
519 case FilterAction::ActionTypeOr:
520 if (cur_filter.length()) {
521 new_filter = "(" + cur_filter + ") || (" + action_filter + ")";
523 new_filter = action_filter;
526 case FilterAction::ActionTypeNot:
527 new_filter = "!(" + action_filter + ")";
529 case FilterAction::ActionTypeAndNot:
530 if (cur_filter.length()) {
531 new_filter = "(" + cur_filter + ") && !(" + action_filter + ")";
533 new_filter = "!(" + action_filter + ")";
536 case FilterAction::ActionTypeOrNot:
537 if (cur_filter.length()) {
538 new_filter = "(" + cur_filter + ") || !(" + action_filter + ")";
540 new_filter = "!(" + action_filter + ")";
544 g_assert_not_reached();
549 case FilterAction::ActionApply:
550 df_combo_box_->lineEdit()->setText(new_filter);
551 df_combo_box_->applyDisplayFilter();
553 case FilterAction::ActionPrepare:
554 df_combo_box_->lineEdit()->setText(new_filter);
555 df_combo_box_->lineEdit()->setFocus();
557 case FilterAction::ActionWebLookup:
559 QString url = QString("https://www.google.com/search?q=") + new_filter;
560 QDesktopServices::openUrl(QUrl(url));
563 case FilterAction::ActionCopy:
564 wsApp->clipboard()->setText(new_filter);
567 qDebug() << "FIX FilterAction::Action" << action << "not implemented";
574 void MainWindow::captureCapturePrepared(capture_session *) {
576 setTitlebarForCaptureInProgress();
578 setWindowIcon(wsApp->captureIcon());
580 /* Disable menu items that make no sense if you're currently running
582 setForCaptureInProgress(true);
583 // set_capture_if_dialog_for_capture_in_progress(TRUE);
585 // /* Don't set up main window for a capture file. */
586 // main_set_for_capture_file(FALSE);
587 main_ui_->mainStack->setCurrentWidget(&master_split_);
588 #endif // HAVE_LIBPCAP
591 void MainWindow::captureCaptureUpdateStarted(capture_session *) {
594 /* We've done this in "prepared" above, but it will be cleared while
595 switching to the next multiple file. */
596 setTitlebarForCaptureInProgress();
598 setForCaptureInProgress(true);
600 setForCapturedPackets(true);
601 #endif // HAVE_LIBPCAP
603 void MainWindow::captureCaptureUpdateFinished(capture_session *) {
606 /* The capture isn't stopping any more - it's stopped. */
607 capture_stopping_ = false;
609 /* Update the main window as appropriate */
610 updateForUnsavedChanges();
612 /* Enable menu items that make sense if you're not currently running
614 setForCaptureInProgress(false);
616 setWindowIcon(wsApp->normalIcon());
618 if (global_capture_opts.quit_after_cap) {
619 // Command line asked us to quit after capturing.
620 // Don't pop up a dialog to ask for unsaved files etc.
623 #endif // HAVE_LIBPCAP
625 void MainWindow::captureCaptureFixedStarted(capture_session *) {
627 #endif // HAVE_LIBPCAP
629 void MainWindow::captureCaptureFixedFinished(capture_session *) {
632 /* The capture isn't stopping any more - it's stopped. */
633 capture_stopping_ = false;
635 /* Enable menu items that make sense if you're not currently running
637 setForCaptureInProgress(false);
639 setWindowIcon(wsApp->normalIcon());
641 if (global_capture_opts.quit_after_cap) {
642 // Command line asked us to quit after capturing.
643 // Don't pop up a dialog to ask for unsaved files etc.
646 #endif // HAVE_LIBPCAP
648 void MainWindow::captureCaptureStopping(capture_session *) {
651 capture_stopping_ = true;
652 setMenusForCaptureStopping();
653 #endif // HAVE_LIBPCAP
655 void MainWindow::captureCaptureFailed(capture_session *) {
657 /* Capture isn't stopping any more. */
658 capture_stopping_ = false;
660 setForCaptureInProgress(false);
661 main_ui_->mainStack->setCurrentWidget(main_welcome_);
663 setWindowIcon(wsApp->normalIcon());
665 if (global_capture_opts.quit_after_cap) {
666 // Command line asked us to quit after capturing.
667 // Don't pop up a dialog to ask for unsaved files etc.
670 #endif // HAVE_LIBPCAP
674 // Callbacks from cfile.c and file.c via CaptureFile::captureFileCallback
676 void MainWindow::captureFileOpened() {
677 if (capture_file_.window() != this) return;
679 file_set_dialog_.fileOpened(capture_file_.capFile());
680 setMenusForFileSet(true);
681 emit setCaptureFile(capture_file_.capFile());
684 void MainWindow::captureFileReadStarted(const QString &action) {
685 // tap_param_dlg_update();
687 /* Set up main window for a capture file. */
688 // main_set_for_capture_file(TRUE);
690 main_ui_->statusBar->popFileStatus();
691 QString msg = QString(tr("%1: %2")).arg(action).arg(capture_file_.fileName());
692 QString msgtip = QString();
693 main_ui_->statusBar->pushFileStatus(msg, msgtip);
694 main_ui_->mainStack->setCurrentWidget(&master_split_);
695 main_ui_->actionAnalyzeReloadLuaPlugins->setEnabled(false);
697 WiresharkApplication::processEvents();
700 void MainWindow::captureFileReadFinished() {
703 if (!capture_file_.capFile()->is_tempfile && capture_file_.capFile()->filename) {
704 /* Add this filename to the list of recent files in the "Recent Files" submenu */
705 add_menu_recent_capture_file(capture_file_.capFile()->filename);
707 /* Remember folder for next Open dialog and save it in recent */
708 dir_path = get_dirname(g_strdup(capture_file_.capFile()->filename));
709 wsApp->setLastOpenDir(dir_path);
713 /* Update the appropriate parts of the main window. */
714 updateForUnsavedChanges();
716 /* Enable menu items that make sense if you have some captured packets. */
717 setForCapturedPackets(true);
719 main_ui_->statusBar->setFileName(capture_file_);
720 main_ui_->actionAnalyzeReloadLuaPlugins->setEnabled(true);
722 packet_list_->captureFileReadFinished();
724 emit setDissectedCaptureFile(capture_file_.capFile());
727 void MainWindow::captureFileRetapStarted()
729 // XXX Push a status message?
733 void MainWindow::captureFileRetapFinished()
738 void MainWindow::captureFileFlushTapsData()
740 draw_tap_listeners(FALSE);
743 void MainWindow::captureFileClosing() {
744 setMenusForCaptureFile(true);
745 setForCapturedPackets(false);
746 setForCaptureInProgress(false);
748 // Reset expert information indicator
749 main_ui_->statusBar->captureFileClosing();
750 main_ui_->searchFrame->animatedHide();
751 // gtk_widget_show(expert_info_none);
752 emit setCaptureFile(NULL);
753 emit setDissectedCaptureFile(NULL);
756 void MainWindow::captureFileClosed() {
757 packets_bar_update();
759 file_set_dialog_.fileClosed();
760 setMenusForFileSet(false);
761 setWindowModified(false);
763 // Reset expert information indicator
764 main_ui_->statusBar->captureFileClosing();
766 main_ui_->statusBar->popFileStatus();
769 setWindowIcon(wsApp->normalIcon());
770 setMenusForSelectedPacket();
771 setMenusForSelectedTreeRow();
773 if (!global_capture_opts.multi_files_on)
774 main_ui_->mainStack->setCurrentWidget(main_welcome_);
777 void MainWindow::captureFileSaveStarted(const QString &file_path)
779 QFileInfo file_info(file_path);
780 main_ui_->statusBar->popFileStatus();
781 main_ui_->statusBar->pushFileStatus(tr("Saving %1" UTF8_HORIZONTAL_ELLIPSIS).arg(file_info.baseName()));
784 void MainWindow::filterExpressionsChanged()
786 // Recreate filter buttons
787 foreach (QAction *act, main_ui_->displayFilterToolBar->actions()) {
788 // Permanent actions shouldn't have data
789 if (act->property(dfe_property_).isValid()) {
790 main_ui_->displayFilterToolBar->removeAction(act);
795 // XXX Add a context menu for removing and changing buttons.
796 for (struct filter_expression *fe = *pfilter_expression_head; fe != NULL; fe = fe->next) {
797 if (!fe->enabled) continue;
798 QAction *dfb_action = new QAction(fe->label, main_ui_->displayFilterToolBar);
799 dfb_action->setToolTip(fe->expression);
800 dfb_action->setData(fe->expression);
801 dfb_action->setProperty(dfe_property_, true);
802 main_ui_->displayFilterToolBar->addAction(dfb_action);
803 connect(dfb_action, SIGNAL(triggered()), this, SLOT(displayFilterButtonClicked()));
811 // ui/gtk/capture_dlg.c:start_capture_confirmed
813 void MainWindow::startCapture() {
815 interface_options interface_opts;
818 /* did the user ever select a capture interface before? */
819 if(global_capture_opts.num_selected == 0) {
820 QString msg = QString(tr("No interface selected"));
821 main_ui_->statusBar->pushTemporaryStatus(msg);
822 main_ui_->actionCaptureStart->setChecked(false);
826 // Ideally we should have disabled the start capture
827 // toolbar buttons and menu items. This may not be the
828 // case, e.g. with QtMacExtras.
829 if(!capture_filter_valid_) {
830 QString msg = QString(tr("Invalid capture filter"));
831 main_ui_->statusBar->pushTemporaryStatus(msg);
832 main_ui_->actionCaptureStart->setChecked(false);
836 main_ui_->mainStack->setCurrentWidget(&master_split_);
838 /* XXX - we might need to init other pref data as well... */
841 QString capture_filter = main_welcome_->captureFilter();
842 g_free(global_capture_opts.default_options.cfilter);
843 if (capture_filter.isEmpty()) {
844 global_capture_opts.default_options.cfilter = NULL;
846 global_capture_opts.default_options.cfilter = qstring_strdup(capture_filter);
849 if (global_capture_opts.num_selected > 0) {
852 for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) {
853 device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
854 if (!device.selected) {
857 // if (device.active_dlt == -1) {
858 // simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "The link type of interface %s was not specified.", device.name);
859 // continue; /* Programming error: somehow managed to select an "unsupported" entry */
861 g_array_remove_index(global_capture_opts.all_ifaces, i);
862 g_free(device.cfilter);
863 device.cfilter = qstring_strdup(capture_filter);
864 g_array_insert_val(global_capture_opts.all_ifaces, i, device);
865 // update_filter_string(device.name, filter_text);
870 /* XXX - can this ever happen? */
871 if (cap_session_.state != CAPTURE_STOPPED)
874 /* close the currently loaded capture file */
875 cf_close((capture_file *) cap_session_.cf);
877 /* Copy the selected interfaces to the set of interfaces to use for
879 collect_ifaces(&global_capture_opts);
881 CaptureFile::globalCapFile()->window = this;
882 if (capture_start(&global_capture_opts, &cap_session_, &info_data_, main_window_update)) {
883 capture_options *capture_opts = cap_session_.capture_opts;
884 GString *interface_names;
886 /* enable autoscroll timer as needed. */
887 packet_list_->setVerticalAutoScroll(main_ui_->actionGoAutoScroll->isChecked());
889 /* Add "interface name<live capture in progress>" on main status bar */
890 interface_names = get_iface_list_string(capture_opts, 0);
891 if (strlen (interface_names->str) > 0) {
892 g_string_append(interface_names, ":");
894 g_string_append(interface_names, " ");
896 main_ui_->statusBar->popFileStatus();
897 QString msg = QString().sprintf("%s<live capture in progress>", interface_names->str);
898 QString msgtip = QString().sprintf("to file: %s", (capture_opts->save_file) ? capture_opts->save_file : "");
899 main_ui_->statusBar->pushFileStatus(msg, msgtip);
900 g_string_free(interface_names, TRUE);
902 /* The capture succeeded, which means the capture filter syntax is
903 valid; add this capture filter to the recent capture filter list. */
904 QByteArray filter_ba;
905 for (i = 0; i < global_capture_opts.ifaces->len; i++) {
906 interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, i);
907 if (interface_opts.cfilter) {
908 recent_add_cfilter(interface_opts.name, interface_opts.cfilter);
909 if (filter_ba.isEmpty()) {
910 filter_ba = interface_opts.cfilter;
912 /* Not the first selected interface; is its capture filter
913 the same as the one the other interfaces we've looked
915 if (strcmp(interface_opts.cfilter, filter_ba.constData()) != 0) {
916 /* No, so not all selected interfaces have the same capture
923 if (!filter_ba.isEmpty()) {
924 recent_add_cfilter(NULL, filter_ba.constData());
927 CaptureFile::globalCapFile()->window = NULL;
929 #endif // HAVE_LIBPCAP
932 // Copied from ui/gtk/gui_utils.c
933 void MainWindow::pipeTimeout() {
937 gboolean result, result1;
942 /* try to read data from the pipe only 5 times, to avoid blocking */
943 while(iterations < 5) {
944 /*g_log(NULL, G_LOG_LEVEL_DEBUG, "pipe_timer_cb: new iteration");*/
946 /* Oddly enough although Named pipes don't work on win9x,
947 PeekNamedPipe does !!! */
948 handle = (HANDLE) _get_osfhandle (pipe_source_);
949 result = PeekNamedPipe(handle, NULL, 0, NULL, &avail, NULL);
951 /* Get the child process exit status */
952 result1 = GetExitCodeProcess((HANDLE)*(pipe_child_process_),
955 /* If the Peek returned an error, or there are bytes to be read
956 or the childwatcher thread has terminated then call the normal
958 if (!result || avail > 0 || childstatus != STILL_ACTIVE) {
960 /*g_log(NULL, G_LOG_LEVEL_DEBUG, "pipe_timer_cb: data avail");*/
962 /* And call the real handler */
963 if (!pipe_input_cb_(pipe_source_, pipe_user_data_)) {
964 g_log(NULL, G_LOG_LEVEL_DEBUG, "pipe_timer_cb: input pipe closed, iterations: %u", iterations);
965 /* pipe closed, return false so that the old timer is not run again */
971 /*g_log(NULL, G_LOG_LEVEL_DEBUG, "pipe_timer_cb: no data avail");*/
972 /* No data, stop now */
981 void MainWindow::pipeActivated(int source) {
985 g_assert(source == pipe_source_);
987 pipe_notifier_->setEnabled(false);
988 if (pipe_input_cb_(pipe_source_, pipe_user_data_)) {
989 pipe_notifier_->setEnabled(true);
991 delete pipe_notifier_;
996 void MainWindow::pipeNotifierDestroyed() {
1000 pipe_notifier_ = NULL;
1004 void MainWindow::stopCapture() {
1005 //#ifdef HAVE_AIRPCAP
1006 // if (airpcap_if_active)
1007 // airpcap_set_toolbar_stop_capture(airpcap_if_active);
1011 capture_stop(&cap_session_);
1012 #endif // HAVE_LIBPCAP
1014 /* Pop the "<live capture in progress>" message off the status bar. */
1015 main_ui_->statusBar->setFileName(capture_file_);
1017 /* disable autoscroll timer if any. */
1018 packet_list_->setVerticalAutoScroll(false);
1021 // Keep focus rects from showing through the welcome screen. Primarily for
1023 void MainWindow::mainStackChanged(int)
1025 for (int i = 0; i < main_ui_->mainStack->count(); i++) {
1026 main_ui_->mainStack->widget(i)->setEnabled(i == main_ui_->mainStack->currentIndex());
1030 // XXX - Copied from ui/gtk/menus.c
1033 * Add the capture filename (with an absolute path) to the "Recent Files" menu.
1035 // XXX - We should probably create a RecentFile class.
1036 void MainWindow::updateRecentFiles() {
1038 QMenu *recentMenu = main_ui_->menuOpenRecentCaptureFile;
1039 QString action_cf_name;
1045 recentMenu->clear();
1047 /* Iterate through the actions in menuOpenRecentCaptureFile,
1048 * removing special items, a maybe duplicate entry and every item above count_max */
1049 int shortcut = Qt::Key_0;
1050 foreach (recent_item_status *ri, wsApp->recentItems()) {
1052 ra = new QAction(recentMenu);
1053 ra->setData(ri->filename);
1054 // XXX - Needs get_recent_item_status or equivalent
1055 ra->setEnabled(ri->accessible);
1056 recentMenu->insertAction(NULL, ra);
1057 action_cf_name = ra->data().toString();
1058 if (shortcut <= Qt::Key_9) {
1059 ra->setShortcut(Qt::META | shortcut);
1062 ra->setText(action_cf_name);
1063 connect(ra, SIGNAL(triggered()), this, SLOT(recentActionTriggered()));
1066 if (recentMenu->actions().count() > 0) {
1067 // Separator + "Clear"
1068 // XXX - Do we really need this?
1069 ra = new QAction(recentMenu);
1070 ra->setSeparator(true);
1071 recentMenu->insertAction(NULL, ra);
1073 ra = new QAction(recentMenu);
1074 ra->setText(tr("Clear Menu"));
1075 recentMenu->insertAction(NULL, ra);
1076 connect(ra, SIGNAL(triggered()), wsApp, SLOT(clearRecentItems()));
1078 if (main_ui_->actionDummyNoFilesFound) {
1079 recentMenu->addAction(main_ui_->actionDummyNoFilesFound);
1084 void MainWindow::recentActionTriggered() {
1085 QAction *ra = qobject_cast<QAction*>(sender());
1088 QString cfPath = ra->data().toString();
1089 openCaptureFile(cfPath);
1093 void MainWindow::setMenusForSelectedPacket()
1095 gboolean is_ip = FALSE, is_tcp = FALSE, is_udp = FALSE, is_sctp = FALSE, is_ssl = FALSE, is_rtp = FALSE, is_lte_rlc = FALSE, is_http = FALSE;
1097 /* Making the menu context-sensitive allows for easier selection of the
1098 desired item and has the added benefit, with large captures, of
1099 avoiding needless looping through huge lists for marked, ignored,
1100 or time-referenced packets. */
1102 /* We have one or more items in the packet list */
1103 bool have_frames = false;
1104 /* A frame is selected */
1105 bool frame_selected = false;
1106 /* We have marked frames. (XXX - why check frame_selected?) */
1107 bool have_marked = false;
1108 /* We have a marked frame other than the current frame (i.e.,
1109 we have at least one marked frame, and either there's more
1110 than one marked frame or the current frame isn't marked). */
1111 bool another_is_marked = false;
1112 /* One or more frames are hidden by a display filter */
1113 bool have_filtered = false;
1114 /* One or more frames have been ignored */
1115 bool have_ignored = false;
1116 bool have_time_ref = false;
1117 /* We have a time reference frame other than the current frame (i.e.,
1118 we have at least one time reference frame, and either there's more
1119 than one time reference frame or the current frame isn't a
1120 time reference frame). (XXX - why check frame_selected?) */
1121 bool another_is_time_ref = false;
1122 /* We have a valid filter expression */
1123 bool have_filter_expr = false;
1125 QList<QAction *> cc_actions = QList<QAction *>()
1126 << main_ui_->actionViewColorizeConversation1 << main_ui_->actionViewColorizeConversation2
1127 << main_ui_->actionViewColorizeConversation3 << main_ui_->actionViewColorizeConversation4
1128 << main_ui_->actionViewColorizeConversation5 << main_ui_->actionViewColorizeConversation6
1129 << main_ui_->actionViewColorizeConversation7 << main_ui_->actionViewColorizeConversation8
1130 << main_ui_->actionViewColorizeConversation9 << main_ui_->actionViewColorizeConversation10;
1132 if (capture_file_.capFile()) {
1133 frame_selected = capture_file_.capFile()->current_frame != NULL;
1134 have_frames = capture_file_.capFile()->count > 0;
1135 have_marked = frame_selected && capture_file_.capFile()->marked_count > 0;
1136 another_is_marked = have_marked &&
1137 !(capture_file_.capFile()->marked_count == 1 && capture_file_.capFile()->current_frame->flags.marked);
1138 have_filtered = capture_file_.capFile()->displayed_count > 0 && capture_file_.capFile()->displayed_count != capture_file_.capFile()->count;
1139 have_ignored = capture_file_.capFile()->ignored_count > 0;
1140 have_time_ref = capture_file_.capFile()->ref_time_count > 0;
1141 another_is_time_ref = frame_selected && have_time_ref &&
1142 !(capture_file_.capFile()->ref_time_count == 1 && capture_file_.capFile()->current_frame->flags.ref_time);
1144 if (capture_file_.capFile()->edt)
1146 proto_get_frame_protocols(capture_file_.capFile()->edt->pi.layers,
1147 &is_ip, &is_tcp, &is_udp, &is_sctp,
1148 &is_ssl, &is_rtp, &is_lte_rlc);
1149 is_http = proto_is_frame_protocol(capture_file_.capFile()->edt->pi.layers, "http");
1153 have_filter_expr = !packet_list_->getFilterFromRowAndColumn().isEmpty();
1155 main_ui_->actionEditMarkPacket->setEnabled(frame_selected);
1156 main_ui_->actionEditMarkAllDisplayed->setEnabled(have_frames);
1157 /* Unlike un-ignore, do not allow unmark of all frames when no frames are displayed */
1158 main_ui_->actionEditUnmarkAllDisplayed->setEnabled(have_marked);
1159 main_ui_->actionEditNextMark->setEnabled(another_is_marked);
1160 main_ui_->actionEditPreviousMark->setEnabled(another_is_marked);
1162 #ifdef WANT_PACKET_EDITOR
1163 // set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/EditPacket",
1165 #endif // WANT_PACKET_EDITOR
1166 main_ui_->actionEditPacketComment->setEnabled(frame_selected && wtap_dump_can_write(capture_file_.capFile()->linktypes, WTAP_COMMENT_PER_PACKET));
1168 main_ui_->actionEditIgnorePacket->setEnabled(frame_selected);
1169 main_ui_->actionEditIgnoreAllDisplayed->setEnabled(have_filtered);
1170 /* Allow un-ignore of all frames even with no frames currently displayed */
1171 main_ui_->actionEditUnignoreAllDisplayed->setEnabled(have_ignored);
1173 main_ui_->actionEditSetTimeReference->setEnabled(frame_selected);
1174 main_ui_->actionEditUnsetAllTimeReferences->setEnabled(have_time_ref);
1175 main_ui_->actionEditNextTimeReference->setEnabled(another_is_time_ref);
1176 main_ui_->actionEditPreviousTimeReference->setEnabled(another_is_time_ref);
1177 main_ui_->actionEditTimeShift->setEnabled(have_frames);
1179 main_ui_->actionGoGoToLinkedPacket->setEnabled(false);
1181 main_ui_->actionAnalyzeAAFSelected->setEnabled(have_filter_expr);
1182 main_ui_->actionAnalyzeAAFNotSelected->setEnabled(have_filter_expr);
1183 main_ui_->actionAnalyzeAAFAndSelected->setEnabled(have_filter_expr);
1184 main_ui_->actionAnalyzeAAFOrSelected->setEnabled(have_filter_expr);
1185 main_ui_->actionAnalyzeAAFAndNotSelected->setEnabled(have_filter_expr);
1186 main_ui_->actionAnalyzeAAFOrNotSelected->setEnabled(have_filter_expr);
1188 main_ui_->actionAnalyzePAFSelected->setEnabled(have_filter_expr);
1189 main_ui_->actionAnalyzePAFNotSelected->setEnabled(have_filter_expr);
1190 main_ui_->actionAnalyzePAFAndSelected->setEnabled(have_filter_expr);
1191 main_ui_->actionAnalyzePAFOrSelected->setEnabled(have_filter_expr);
1192 main_ui_->actionAnalyzePAFAndNotSelected->setEnabled(have_filter_expr);
1193 main_ui_->actionAnalyzePAFOrNotSelected->setEnabled(have_filter_expr);
1195 main_ui_->actionAnalyzeFollowTCPStream->setEnabled(is_tcp);
1196 main_ui_->actionAnalyzeFollowUDPStream->setEnabled(is_udp);
1197 main_ui_->actionAnalyzeFollowSSLStream->setEnabled(is_ssl);
1198 main_ui_->actionAnalyzeFollowHTTPStream->setEnabled(is_http);
1200 foreach (QAction *cc_action, cc_actions) {
1201 cc_action->setEnabled(frame_selected);
1203 main_ui_->actionViewColorizeNewConversationRule->setEnabled(frame_selected);
1205 main_ui_->actionViewColorizeResetColorization->setEnabled(tmp_color_filters_used());
1207 main_ui_->actionViewColorizeNewConversationRule->setEnabled(frame_selected);
1209 main_ui_->actionViewShowPacketInNewWindow->setEnabled(frame_selected);
1210 main_ui_->actionViewEditResolvedName->setEnabled(frame_selected && is_ip);
1212 main_ui_->menuConversationFilter->clear();
1214 packet_list_->conversationMenu()->clear();
1215 packet_list_->colorizeMenu()->clear();
1217 for (GList *conv_filter_list_entry = conv_filter_list; conv_filter_list_entry; conv_filter_list_entry = g_list_next(conv_filter_list_entry)) {
1219 conversation_filter_t* conv_filter = (conversation_filter_t *)conv_filter_list_entry->data;
1220 QAction *conv_action = main_ui_->menuConversationFilter->addAction(conv_filter->display_name);
1222 bool enable = false;
1224 if (capture_file_.capFile() && capture_file_.capFile()->edt) {
1225 enable = conv_filter->is_filter_valid(&capture_file_.capFile()->edt->pi);
1226 filter = gchar_free_to_qstring(conv_filter->build_filter_string(&capture_file_.capFile()->edt->pi));
1228 conv_action->setEnabled(enable);
1229 conv_action->setData(filter);
1230 connect(conv_action, SIGNAL(triggered()), this, SLOT(applyConversationFilter()));
1232 // Packet list context menu items
1233 packet_list_->conversationMenu()->addAction(conv_action);
1235 QMenu *submenu = packet_list_->colorizeMenu()->addMenu(conv_action->text());
1237 foreach (QAction *cc_action, cc_actions) {
1238 QAction *colorize_action = submenu->addAction(cc_action->icon(), cc_action->text());
1239 colorize_action->setProperty(color_number_property_, i++);
1240 colorize_action->setData(filter);
1241 colorize_action->setEnabled(enable);
1242 connect(colorize_action, SIGNAL(triggered()), this, SLOT(colorizeWithFilter()));
1245 QAction *conv_rule_action = submenu->addAction(main_ui_->actionViewColorizeNewConversationRule->text());
1246 conv_rule_action->setData(conv_action->data());
1247 conv_rule_action->setEnabled(enable);
1248 connect(conv_rule_action, SIGNAL(triggered()), this, SLOT(colorizeWithFilter()));
1251 // set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/ResolveName",
1252 // frame_selected && (gbl_resolv_flags.mac_name || gbl_resolv_flags.network_name ||
1253 // gbl_resolv_flags.transport_name || gbl_resolv_flags.concurrent_dns));
1254 // set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ToolsMenu/FirewallACLRules",
1256 main_ui_->menuTcpStreamGraphs->setEnabled(is_tcp);
1257 main_ui_->actionSCTPAnalyseThisAssociation->setEnabled(is_sctp);
1258 main_ui_->actionSCTPShowAllAssociations->setEnabled(is_sctp);
1259 main_ui_->actionSCTPFilterThisAssociation->setEnabled(is_sctp);
1260 main_ui_->actionTelephonyRTPStreamAnalysis->setEnabled(is_rtp);
1261 main_ui_->actionTelephonyLteRlcGraph->setEnabled(is_lte_rlc);
1264 void MainWindow::setMenusForSelectedTreeRow(field_info *fi) {
1266 bool can_match_selected = false;
1267 bool is_framenum = false;
1268 bool have_field_info = false;
1269 bool have_subtree = false;
1270 bool can_open_url = false;
1271 QString field_filter;
1274 QList<QAction *> cc_actions = QList<QAction *>()
1275 << main_ui_->actionViewColorizeConversation1 << main_ui_->actionViewColorizeConversation2
1276 << main_ui_->actionViewColorizeConversation3 << main_ui_->actionViewColorizeConversation4
1277 << main_ui_->actionViewColorizeConversation5 << main_ui_->actionViewColorizeConversation6
1278 << main_ui_->actionViewColorizeConversation7 << main_ui_->actionViewColorizeConversation8
1279 << main_ui_->actionViewColorizeConversation9 << main_ui_->actionViewColorizeConversation10;
1281 if (capture_file_.capFile()) {
1282 capture_file_.capFile()->finfo_selected = fi;
1284 if (fi && fi->tree_type != -1) {
1285 have_subtree = true;
1289 if (capture_file_.capFile() != NULL && fi != NULL) {
1290 header_field_info *hfinfo = fi->hfinfo;
1291 int linked_frame = -1;
1293 have_field_info = true;
1294 can_match_selected = proto_can_match_selected(capture_file_.capFile()->finfo_selected, capture_file_.capFile()->edt);
1295 if (hfinfo && hfinfo->type == FT_FRAMENUM) {
1297 linked_frame = fvalue_get_uinteger(&fi->value);
1300 char *tmp_field = proto_construct_match_selected_string(fi, capture_file_.capFile()->edt);
1301 field_filter = QString(tmp_field);
1302 wmem_free(NULL, tmp_field);
1304 field_id = fi->hfinfo->id;
1305 /* if the selected field isn't a protocol, get its parent */
1306 if (!proto_registrar_is_protocol(field_id)) {
1307 field_id = proto_registrar_get_parent(fi->hfinfo->id);
1310 if (field_id >= 0) {
1311 can_open_url = true;
1312 main_ui_->actionContextWikiProtocolPage->setData(field_id);
1313 main_ui_->actionContextFilterFieldReference->setData(field_id);
1315 main_ui_->actionContextWikiProtocolPage->setData(QVariant());
1316 main_ui_->actionContextFilterFieldReference->setData(QVariant());
1319 if (linked_frame > 0) {
1320 main_ui_->actionGoGoToLinkedPacket->setData(linked_frame);
1322 main_ui_->actionGoGoToLinkedPacket->setData(QVariant());
1326 // Always enable / disable the following items.
1327 main_ui_->actionFileExportPacketBytes->setEnabled(have_field_info);
1329 main_ui_->actionCopyAllVisibleItems->setEnabled(capture_file_.capFile() != NULL);
1330 main_ui_->actionCopyAllVisibleSelectedTreeItems->setEnabled(can_match_selected);
1331 main_ui_->actionEditCopyDescription->setEnabled(can_match_selected);
1332 main_ui_->actionEditCopyFieldName->setEnabled(can_match_selected);
1333 main_ui_->actionEditCopyValue->setEnabled(can_match_selected);
1334 main_ui_->actionEditCopyAsFilter->setEnabled(can_match_selected);
1336 main_ui_->actionViewExpandSubtrees->setEnabled(have_subtree);
1338 main_ui_->actionGoGoToLinkedPacket->setEnabled(is_framenum);
1340 main_ui_->actionAnalyzeCreateAColumn->setEnabled(can_match_selected);
1342 main_ui_->actionContextShowLinkedPacketInNewWindow->setEnabled(is_framenum);
1344 main_ui_->actionContextWikiProtocolPage->setEnabled(can_open_url);
1345 main_ui_->actionContextFilterFieldReference->setEnabled(can_open_url);
1348 // Only enable / disable the following items if we have focus so that we
1349 // don't clobber anything we may have set in setMenusForSelectedPacket.
1350 if (!proto_tree_ || !proto_tree_->hasFocus()) return;
1352 main_ui_->menuConversationFilter->clear();
1353 for (GList *conv_filter_list_entry = conv_filter_list; conv_filter_list_entry; conv_filter_list_entry = g_list_next(conv_filter_list_entry)) {
1354 conversation_filter_t* conv_filter = (conversation_filter_t *)conv_filter_list_entry->data;
1355 QAction *conv_action = main_ui_->menuConversationFilter->addAction(conv_filter->display_name);
1357 bool enable = false;
1359 if (fi && capture_file_.capFile() && capture_file_.capFile()->edt) {
1360 enable = conv_filter->is_filter_valid(&capture_file_.capFile()->edt->pi);
1361 filter = conv_filter->build_filter_string(&capture_file_.capFile()->edt->pi);
1363 conv_action->setEnabled(enable);
1364 conv_action->setData(filter);
1365 connect(conv_action, SIGNAL(triggered()), this, SLOT(applyConversationFilter()));
1368 proto_tree_->colorizeMenu()->clear();
1370 foreach (QAction *cc_action, cc_actions) {
1371 QAction *colorize_action = proto_tree_->colorizeMenu()->addAction(cc_action->icon(), cc_action->text());
1372 colorize_action->setProperty(color_number_property_, i++);
1373 colorize_action->setData(field_filter);
1374 colorize_action->setEnabled(!field_filter.isEmpty());
1375 connect(colorize_action, SIGNAL(triggered()), this, SLOT(colorizeWithFilter()));
1378 QAction *conv_rule_action = proto_tree_->colorizeMenu()->addAction(main_ui_->actionViewColorizeNewConversationRule->text());
1379 conv_rule_action->setData(field_filter);
1380 conv_rule_action->setEnabled(!field_filter.isEmpty());
1381 connect(conv_rule_action, SIGNAL(triggered()), this, SLOT(colorizeWithFilter()));
1383 // set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ResolveName",
1384 // frame_selected && (gbl_resolv_flags.mac_name || gbl_resolv_flags.network_name ||
1385 // gbl_resolv_flags.transport_name || gbl_resolv_flags.concurrent_dns));
1388 main_ui_->actionAnalyzeAAFSelected->setEnabled(can_match_selected);
1389 main_ui_->actionAnalyzeAAFNotSelected->setEnabled(can_match_selected);
1390 main_ui_->actionAnalyzeAAFAndSelected->setEnabled(can_match_selected);
1391 main_ui_->actionAnalyzeAAFOrSelected->setEnabled(can_match_selected);
1392 main_ui_->actionAnalyzeAAFAndNotSelected->setEnabled(can_match_selected);
1393 main_ui_->actionAnalyzeAAFOrNotSelected->setEnabled(can_match_selected);
1395 main_ui_->actionAnalyzePAFSelected->setEnabled(can_match_selected);
1396 main_ui_->actionAnalyzePAFNotSelected->setEnabled(can_match_selected);
1397 main_ui_->actionAnalyzePAFAndSelected->setEnabled(can_match_selected);
1398 main_ui_->actionAnalyzePAFOrSelected->setEnabled(can_match_selected);
1399 main_ui_->actionAnalyzePAFAndNotSelected->setEnabled(can_match_selected);
1400 main_ui_->actionAnalyzePAFOrNotSelected->setEnabled(can_match_selected);
1403 void MainWindow::interfaceSelectionChanged()
1406 // XXX This doesn't disable the toolbar button when using
1408 if (global_capture_opts.num_selected > 0 && capture_filter_valid_) {
1409 main_ui_->actionCaptureStart->setEnabled(true);
1411 main_ui_->actionCaptureStart->setEnabled(false);
1413 #endif // HAVE_LIBPCAP
1416 void MainWindow::captureFilterSyntaxChanged(bool valid)
1418 capture_filter_valid_ = valid;
1419 interfaceSelectionChanged();
1422 void MainWindow::startInterfaceCapture(bool valid)
1424 capture_filter_valid_ = valid;
1428 void MainWindow::redissectPackets()
1430 if (capture_file_.capFile()) {
1431 cf_redissect_packets(capture_file_.capFile());
1432 main_ui_->statusBar->expertUpdate();
1435 proto_free_deregistered_fields();
1438 void MainWindow::checkDisplayFilter()
1440 if (!df_combo_box_->checkDisplayFilter()) {
1441 g_free(CaptureFile::globalCapFile()->dfilter);
1442 CaptureFile::globalCapFile()->dfilter = NULL;
1446 void MainWindow::fieldsChanged()
1448 gchar *err_msg = NULL;
1449 if (!color_filters_reload(&err_msg, color_filter_add_cb)) {
1450 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
1453 tap_listeners_dfilter_recompile();
1455 emit checkDisplayFilter();
1457 if (have_custom_cols(&CaptureFile::globalCapFile()->cinfo)) {
1458 // Recreate packet list columns according to new/changed/deleted fields
1459 packet_list_->fieldsChanged(CaptureFile::globalCapFile());
1462 emit reloadFields();
1465 void MainWindow::reloadLuaPlugins()
1468 if (wsApp->isReloadingLua())
1471 wsApp->setReloadingLua(true);
1473 wslua_reload_plugins(NULL, NULL);
1474 funnel_statistics_reload_menus();
1475 reloadDynamicMenus();
1476 closePacketDialogs();
1478 // Preferences may have been deleted so close all widgets using prefs
1479 proto_tree_->closeContextMenu();
1480 main_ui_->preferenceEditorFrame->animatedHide();
1482 char *gdp_path, *dp_path;
1483 wsApp->readConfigurationFiles(&gdp_path, &dp_path, true);
1488 wsApp->setReloadingLua(false);
1489 SimpleDialog::displayQueuedMessages();
1493 void MainWindow::showAccordionFrame(AccordionFrame *show_frame, bool toggle)
1495 QList<AccordionFrame *>frame_list = QList<AccordionFrame *>()
1496 << main_ui_->goToFrame << main_ui_->searchFrame
1497 << main_ui_->addressEditorFrame << main_ui_->columnEditorFrame
1498 << main_ui_->preferenceEditorFrame;
1500 frame_list.removeAll(show_frame);
1501 foreach (AccordionFrame *af, frame_list) af->animatedHide();
1504 if (show_frame->isVisible()) {
1505 show_frame->animatedHide();
1509 show_frame->animatedShow();
1512 void MainWindow::showColumnEditor(int column)
1514 previous_focus_ = wsApp->focusWidget();
1515 connect(previous_focus_, SIGNAL(destroyed()), this, SLOT(resetPreviousFocus()));
1516 showAccordionFrame(main_ui_->columnEditorFrame);
1517 main_ui_->columnEditorFrame->editColumn(column);
1520 void MainWindow::showPreferenceEditor()
1522 showAccordionFrame(main_ui_->preferenceEditorFrame);
1525 void MainWindow::initViewColorizeMenu()
1527 QList<QAction *> cc_actions = QList<QAction *>()
1528 << main_ui_->actionViewColorizeConversation1 << main_ui_->actionViewColorizeConversation2
1529 << main_ui_->actionViewColorizeConversation3 << main_ui_->actionViewColorizeConversation4
1530 << main_ui_->actionViewColorizeConversation5 << main_ui_->actionViewColorizeConversation6
1531 << main_ui_->actionViewColorizeConversation7 << main_ui_->actionViewColorizeConversation8
1532 << main_ui_->actionViewColorizeConversation9 << main_ui_->actionViewColorizeConversation10;
1534 guint8 color_num = 1;
1536 foreach (QAction *cc_action, cc_actions) {
1537 cc_action->setData(color_num);
1538 connect(cc_action, SIGNAL(triggered()), this, SLOT(colorizeConversation()));
1540 const color_filter_t *colorf = color_filters_tmp_color(color_num);
1542 QColor bg = ColorUtils::fromColorT(colorf->bg_color);
1543 QColor fg = ColorUtils::fromColorT(colorf->fg_color);
1544 cc_action->setIcon(StockIcon::colorIcon(bg.rgb(), fg.rgb(), QString::number(color_num)));
1550 // Spotlight uses Cmd+Space
1551 main_ui_->actionViewColorizeResetColorization->setShortcut(QKeySequence("Meta+Space"));
1555 void MainWindow::addStatsPluginsToMenu() {
1556 GList *cfg_list = stats_tree_get_cfg_list();
1557 GList *iter = g_list_first(cfg_list);
1558 QAction *stats_tree_action;
1560 bool first_item = true;
1563 stats_tree_cfg *cfg = (stats_tree_cfg*)iter->data;
1566 main_ui_->menuStatistics->addSeparator();
1570 parent_menu = main_ui_->menuStatistics;
1571 // gtk/main_menubar.c compresses double slashes, hence SkipEmptyParts
1572 QStringList cfg_name_parts = QString(cfg->name).split("/", QString::SkipEmptyParts);
1573 if (cfg_name_parts.isEmpty()) continue;
1575 QString stat_name = cfg_name_parts.takeLast();
1576 if (!cfg_name_parts.isEmpty()) {
1577 QString menu_name = cfg_name_parts.join("/");
1578 parent_menu = findOrAddMenu(parent_menu, menu_name);
1581 stats_tree_action = new QAction(stat_name, this);
1582 stats_tree_action->setData(cfg->abbr);
1583 parent_menu->addAction(stats_tree_action);
1584 connect(stats_tree_action, SIGNAL(triggered()), this, SLOT(actionStatisticsPlugin_triggered()));
1586 iter = g_list_next(iter);
1588 g_list_free(cfg_list);
1591 void MainWindow::setFeaturesEnabled(bool enabled)
1593 main_ui_->menuBar->setEnabled(enabled);
1594 main_ui_->mainToolBar->setEnabled(enabled);
1595 main_ui_->displayFilterToolBar->setEnabled(enabled);
1598 main_ui_->statusBar->clearMessage();
1602 main_ui_->statusBar->showMessage(tr("Please wait while Wireshark is initializing" UTF8_HORIZONTAL_ELLIPSIS));
1606 // Display Filter Toolbar
1608 void MainWindow::on_actionDisplayFilterExpression_triggered()
1610 DisplayFilterExpressionDialog *dfe_dialog = new DisplayFilterExpressionDialog(this);
1612 connect(dfe_dialog, SIGNAL(insertDisplayFilter(QString)),
1613 df_combo_box_->lineEdit(), SLOT(insertFilter(const QString &)));
1618 void MainWindow::on_actionNewDisplayFilterExpression_triggered()
1620 main_ui_->filterExpressionFrame->addExpression(df_combo_box_->lineEdit()->text());
1621 showAccordionFrame(main_ui_->filterExpressionFrame);
1624 // On Qt4 + OS X with unifiedTitleAndToolBarOnMac set it's possible to make
1625 // the main window obnoxiously wide.
1627 void MainWindow::displayFilterButtonClicked()
1629 QAction *dfb_action = qobject_cast<QAction*>(sender());
1632 df_combo_box_->lineEdit()->setText(dfb_action->data().toString());
1633 df_combo_box_->applyDisplayFilter();
1634 df_combo_box_->lineEdit()->setFocus();
1638 void MainWindow::openStatCommandDialog(const QString &menu_path, const char *arg, void *userdata)
1640 QString slot = QString("statCommand%1").arg(menu_path);
1641 QMetaObject::invokeMethod(this, slot.toLatin1().constData(), Q_ARG(const char *, arg), Q_ARG(void *, userdata));
1644 void MainWindow::openTapParameterDialog(const QString cfg_str, const QString arg, void *userdata)
1646 TapParameterDialog *tp_dialog = TapParameterDialog::showTapParameterStatistics(*this, capture_file_, cfg_str, arg, userdata);
1647 if (!tp_dialog) return;
1649 connect(tp_dialog, SIGNAL(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)),
1650 this, SLOT(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)));
1651 connect(tp_dialog, SIGNAL(updateFilter(QString)),
1652 df_combo_box_->lineEdit(), SLOT(setText(QString)));
1656 void MainWindow::openTapParameterDialog()
1658 QAction *tpa = qobject_cast<QAction *>(QObject::sender());
1661 const QString cfg_str = tpa->data().toString();
1662 openTapParameterDialog(cfg_str, NULL, NULL);
1667 void MainWindow::on_actionFileOpen_triggered()
1672 void MainWindow::on_actionFileMerge_triggered()
1677 void MainWindow::on_actionFileImportFromHexDump_triggered()
1679 importCaptureFile();
1682 void MainWindow::on_actionFileClose_triggered() {
1683 if (testCaptureFileClose())
1684 main_ui_->mainStack->setCurrentWidget(main_welcome_);
1687 void MainWindow::on_actionFileSave_triggered()
1689 saveCaptureFile(capture_file_.capFile(), FALSE);
1692 void MainWindow::on_actionFileSaveAs_triggered()
1694 saveAsCaptureFile(capture_file_.capFile());
1697 void MainWindow::on_actionFileSetListFiles_triggered()
1699 file_set_dialog_.show();
1702 void MainWindow::on_actionFileSetNextFile_triggered()
1704 fileset_entry *entry = fileset_get_next();
1707 QString new_cf_path = entry->fullname;
1708 openCaptureFile(new_cf_path);
1712 void MainWindow::on_actionFileSetPreviousFile_triggered()
1714 fileset_entry *entry = fileset_get_previous();
1717 QString new_cf_path = entry->fullname;
1718 openCaptureFile(new_cf_path);
1722 void MainWindow::on_actionFileExportPackets_triggered()
1724 exportSelectedPackets();
1727 void MainWindow::on_actionFileExportAsPlainText_triggered()
1729 exportDissections(export_type_text);
1732 void MainWindow::on_actionFileExportAsCSV_triggered()
1734 exportDissections(export_type_csv);
1737 void MainWindow::on_actionFileExportAsCArrays_triggered()
1739 exportDissections(export_type_carrays);
1742 void MainWindow::on_actionFileExportAsPSML_triggered()
1744 exportDissections(export_type_psml);
1747 void MainWindow::on_actionFileExportAsPDML_triggered()
1749 exportDissections(export_type_pdml);
1752 void MainWindow::on_actionFileExportPacketBytes_triggered()
1756 if (!capture_file_.capFile() || !capture_file_.capFile()->finfo_selected) return;
1758 file_name = QFileDialog::getSaveFileName(this,
1759 wsApp->windowTitleString(tr("Export Selected Packet Bytes")),
1760 wsApp->lastOpenDir().canonicalPath(),
1761 tr("Raw data (*.bin *.dat *.raw);;Any File (*.*)")
1764 if (file_name.length() > 0) {
1765 const guint8 *data_p;
1768 data_p = tvb_get_ptr(capture_file_.capFile()->finfo_selected->ds_tvb, 0, -1) +
1769 capture_file_.capFile()->finfo_selected->start;
1770 fd = ws_open(file_name.toUtf8().constData(), O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0666);
1772 open_failure_alert_box(file_name.toUtf8().constData(), errno, TRUE);
1775 if (ws_write(fd, data_p, capture_file_.capFile()->finfo_selected->length) < 0) {
1776 write_failure_alert_box(file_name.toUtf8().constData(), errno);
1780 if (ws_close(fd) < 0) {
1781 write_failure_alert_box(file_name.toUtf8().constData(), errno);
1785 /* Save the directory name for future file dialogs. */
1786 wsApp->setLastOpenDir(&file_name);
1789 void MainWindow::on_actionFileExportPDU_triggered()
1791 ExportPDUDialog *exportpdu_dialog = new ExportPDUDialog(this);
1793 if (exportpdu_dialog->isMinimized() == true)
1795 exportpdu_dialog->showNormal();
1799 exportpdu_dialog->show();
1802 exportpdu_dialog->raise();
1803 exportpdu_dialog->activateWindow();
1806 void MainWindow::on_actionFileExportSSLSessionKeys_triggered()
1812 keylist_len = ssl_session_key_count();
1813 /* don't show up the dialog, if no data has to be saved */
1814 if (keylist_len < 1) {
1815 /* shouldn't happen as the menu item should have been greyed out */
1816 QMessageBox::warning(
1819 tr("There are no SSL Session Keys to save."),
1825 save_title.append(wsApp->windowTitleString(tr("Export SSL Session Keys (%1 key%2").
1826 arg(keylist_len).arg(plurality(keylist_len, "", "s"))));
1827 file_name = QFileDialog::getSaveFileName(this,
1829 wsApp->lastOpenDir().canonicalPath(),
1830 tr("SSL Session Keys (*.keys *.txt);;Any File (*.*)")
1832 if (file_name.length() > 0) {
1836 keylist = ssl_export_sessions();
1837 fd = ws_open(file_name.toUtf8().constData(), O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0666);
1839 open_failure_alert_box(file_name.toUtf8().constData(), errno, TRUE);
1844 * Thanks, Microsoft, for not using size_t for the third argument to
1845 * _write(). Presumably this string will be <= 4GiB long....
1847 if (ws_write(fd, keylist, (unsigned int)strlen(keylist)) < 0) {
1848 write_failure_alert_box(file_name.toUtf8().constData(), errno);
1853 if (ws_close(fd) < 0) {
1854 write_failure_alert_box(file_name.toUtf8().constData(), errno);
1859 /* Save the directory name for future file dialogs. */
1860 wsApp->setLastOpenDir(&file_name);
1865 void MainWindow::on_actionFileExportObjectsDICOM_triggered()
1867 new ExportObjectDialog(*this, capture_file_, ExportObjectDialog::Dicom);
1870 void MainWindow::on_actionStatisticsHpfeeds_triggered()
1872 openStatisticsTreeDialog("hpfeeds");
1875 void MainWindow::on_actionFileExportObjectsHTTP_triggered()
1877 new ExportObjectDialog(*this, capture_file_, ExportObjectDialog::Http);
1880 void MainWindow::on_actionFileExportObjectsSMB_triggered()
1882 new ExportObjectDialog(*this, capture_file_, ExportObjectDialog::Smb);
1885 void MainWindow::on_actionFileExportObjectsTFTP_triggered()
1887 new ExportObjectDialog(*this, capture_file_, ExportObjectDialog::Tftp);
1890 void MainWindow::on_actionFilePrint_triggered()
1892 PrintDialog pdlg(this, capture_file_.capFile());
1899 void MainWindow::recursiveCopyProtoTreeItems(QTreeWidgetItem *item, QString &clip, int ident_level) {
1900 if (!item->isExpanded()) return;
1902 for (int i_item = 0; i_item < item->childCount(); i_item += 1) {
1903 clip.append(QString(" ").repeated(ident_level));
1904 clip.append(item->child(i_item)->text(0));
1907 recursiveCopyProtoTreeItems(item->child(i_item), clip, ident_level + 1);
1911 // XXX This should probably be somewhere else.
1912 void MainWindow::actionEditCopyTriggered(MainWindow::CopySelected selection_type)
1914 char label_str[ITEM_LABEL_LENGTH];
1917 if (!capture_file_.capFile()) return;
1919 field_info *finfo_selected = capture_file_.capFile()->finfo_selected;
1921 switch(selection_type) {
1922 case CopySelectedDescription:
1923 if (finfo_selected && finfo_selected->rep
1924 && strlen (finfo_selected->rep->representation) > 0) {
1925 clip.append(finfo_selected->rep->representation);
1928 case CopySelectedFieldName:
1929 if (finfo_selected && finfo_selected->hfinfo->abbrev != 0) {
1930 clip.append(finfo_selected->hfinfo->abbrev);
1933 case CopySelectedValue:
1934 if (finfo_selected && capture_file_.capFile()->edt != 0) {
1935 gchar* field_str = get_node_field_value(finfo_selected, capture_file_.capFile()->edt);
1936 clip.append(field_str);
1940 case CopyAllVisibleItems:
1941 for (int i_item = 0; i_item < proto_tree_->topLevelItemCount(); i_item += 1) {
1942 clip.append(proto_tree_->topLevelItem(i_item)->text(0));
1945 recursiveCopyProtoTreeItems(proto_tree_->topLevelItem(i_item), clip, 1);
1949 case CopyAllVisibleSelectedTreeItems:
1950 if (proto_tree_->selectedItems().count() > 0) {
1951 clip.append(proto_tree_->currentItem()->text(0));
1954 recursiveCopyProtoTreeItems(proto_tree_->currentItem(), clip, 1);
1959 if (clip.length() == 0) {
1960 /* If no representation then... Try to read the value */
1961 proto_item_fill_label(capture_file_.capFile()->finfo_selected, label_str);
1962 clip.append(label_str);
1965 if (clip.length()) {
1966 wsApp->clipboard()->setText(clip);
1968 QString err = tr("Couldn't copy text. Try another item.");
1969 main_ui_->statusBar->pushTemporaryStatus(err);
1973 void MainWindow::on_actionCopyAllVisibleItems_triggered()
1975 actionEditCopyTriggered(CopyAllVisibleItems);
1978 void MainWindow::on_actionCopyAllVisibleSelectedTreeItems_triggered()
1980 actionEditCopyTriggered(CopyAllVisibleSelectedTreeItems);
1983 void MainWindow::on_actionEditCopyDescription_triggered()
1985 actionEditCopyTriggered(CopySelectedDescription);
1988 void MainWindow::on_actionEditCopyFieldName_triggered()
1990 actionEditCopyTriggered(CopySelectedFieldName);
1993 void MainWindow::on_actionEditCopyValue_triggered()
1995 actionEditCopyTriggered(CopySelectedValue);
1998 void MainWindow::on_actionEditCopyAsFilter_triggered()
2000 matchFieldFilter(FilterAction::ActionCopy, FilterAction::ActionTypePlain);
2003 void MainWindow::on_actionEditFindPacket_triggered()
2005 if (packet_list_->model()->rowCount() < 1) {
2008 previous_focus_ = wsApp->focusWidget();
2009 connect(previous_focus_, SIGNAL(destroyed()), this, SLOT(resetPreviousFocus()));
2010 showAccordionFrame(main_ui_->searchFrame, true);
2011 if (main_ui_->searchFrame->isVisible()) {
2012 main_ui_->searchFrame->setFocus();
2016 void MainWindow::on_actionEditFindNext_triggered()
2018 main_ui_->searchFrame->findNext();
2021 void MainWindow::on_actionEditFindPrevious_triggered()
2023 main_ui_->searchFrame->findPrevious();
2026 void MainWindow::on_actionEditMarkPacket_triggered()
2029 packet_list_->markFrame();
2033 void MainWindow::on_actionEditMarkAllDisplayed_triggered()
2036 packet_list_->markAllDisplayedFrames(true);
2040 void MainWindow::on_actionEditUnmarkAllDisplayed_triggered()
2043 packet_list_->markAllDisplayedFrames(false);
2047 void MainWindow::on_actionEditNextMark_triggered()
2049 if (capture_file_.capFile())
2050 cf_find_packet_marked(capture_file_.capFile(), SD_FORWARD);
2053 void MainWindow::on_actionEditPreviousMark_triggered()
2055 if (capture_file_.capFile())
2056 cf_find_packet_marked(capture_file_.capFile(), SD_BACKWARD);
2059 void MainWindow::on_actionEditIgnorePacket_triggered()
2062 packet_list_->ignoreFrame();
2066 void MainWindow::on_actionEditIgnoreAllDisplayed_triggered()
2069 packet_list_->ignoreAllDisplayedFrames(true);
2073 void MainWindow::on_actionEditUnignoreAllDisplayed_triggered()
2076 packet_list_->ignoreAllDisplayedFrames(false);
2080 void MainWindow::on_actionEditSetTimeReference_triggered()
2082 packet_list_->setTimeReference();
2085 void MainWindow::on_actionEditUnsetAllTimeReferences_triggered()
2087 packet_list_->unsetAllTimeReferences();
2090 void MainWindow::on_actionEditNextTimeReference_triggered()
2092 if (!capture_file_.capFile()) return;
2093 cf_find_packet_time_reference(capture_file_.capFile(), SD_FORWARD);
2096 void MainWindow::on_actionEditPreviousTimeReference_triggered()
2098 if (!capture_file_.capFile()) return;
2099 cf_find_packet_time_reference(capture_file_.capFile(), SD_BACKWARD);
2102 void MainWindow::on_actionEditTimeShift_triggered()
2104 TimeShiftDialog ts_dialog(this, capture_file_.capFile());
2105 connect(this, SIGNAL(setCaptureFile(capture_file*)),
2106 &ts_dialog, SLOT(setCaptureFile(capture_file*)));
2107 connect(&ts_dialog, SIGNAL(timeShifted()), packet_list_, SLOT(applyTimeShift()));
2111 void MainWindow::on_actionEditPacketComment_triggered()
2113 PacketCommentDialog pc_dialog(this, packet_list_->packetComment());
2114 if (pc_dialog.exec() == QDialog::Accepted) {
2115 packet_list_->setPacketComment(pc_dialog.text());
2116 updateForUnsavedChanges();
2120 void MainWindow::on_actionEditConfigurationProfiles_triggered()
2122 ProfileDialog cp_dialog;
2127 void MainWindow::showPreferencesDialog(PreferencesDialog::PreferencesPane start_pane)
2129 PreferencesDialog pref_dialog(this);
2131 pref_dialog.setPane(start_pane);
2134 // Emitting PacketDissectionChanged directly from a QDialog can cause
2135 // problems on OS X.
2136 wsApp->flushAppSignals();
2139 void MainWindow::showPreferencesDialog(QString module_name)
2141 PreferencesDialog pref_dialog(this);
2143 pref_dialog.setPane(module_name);
2146 // Emitting PacketDissectionChanged directly from a QDialog can cause
2147 // problems on OS X.
2148 wsApp->flushAppSignals();
2151 void MainWindow::on_actionEditPreferences_triggered()
2153 showPreferencesDialog();
2158 void MainWindow::showHideMainWidgets(QAction *action)
2163 bool show = action->isChecked();
2164 QWidget *widget = action->data().value<QWidget*>();
2166 // We may have come from the toolbar context menu, so check/uncheck each
2168 if (widget == main_ui_->mainToolBar) {
2169 recent.main_toolbar_show = show;
2170 main_ui_->actionViewMainToolbar->setChecked(show);
2171 } else if (widget == main_ui_->displayFilterToolBar) {
2172 recent.filter_toolbar_show = show;
2173 main_ui_->actionViewFilterToolbar->setChecked(show);
2174 } else if (widget == main_ui_->wirelessToolBar) {
2175 recent.wireless_toolbar_show = show;
2176 main_ui_->actionViewWirelessToolbar->setChecked(show);
2177 } else if (widget == main_ui_->statusBar) {
2178 recent.statusbar_show = show;
2179 main_ui_->actionViewStatusBar->setChecked(show);
2180 } else if (widget == packet_list_) {
2181 recent.packet_list_show = show;
2182 main_ui_->actionViewPacketList->setChecked(show);
2183 } else if (widget == proto_tree_) {
2184 recent.tree_view_show = show;
2185 main_ui_->actionViewPacketDetails->setChecked(show);
2186 } else if (widget == byte_view_tab_) {
2187 recent.byte_view_show = show;
2188 main_ui_->actionViewPacketBytes->setChecked(show);
2192 widget->setVisible(show);
2196 Q_DECLARE_METATYPE(ts_type)
2198 void MainWindow::setTimestampFormat(QAction *action)
2203 ts_type tsf = action->data().value<ts_type>();
2204 if (recent.gui_time_format != tsf) {
2205 timestamp_set_type(tsf);
2206 recent.gui_time_format = tsf;
2207 if (capture_file_.capFile()) {
2208 /* This call adjusts column width */
2209 cf_timestamp_auto_precision(capture_file_.capFile());
2212 packet_list_->resetColumns();
2217 Q_DECLARE_METATYPE(ts_precision)
2219 void MainWindow::setTimestampPrecision(QAction *action)
2224 ts_precision tsp = action->data().value<ts_precision>();
2225 if (recent.gui_time_precision != tsp) {
2226 /* the actual precision will be set in packet_list_queue_draw() below */
2227 timestamp_set_precision(tsp);
2228 recent.gui_time_precision = tsp;
2229 if (capture_file_.capFile()) {
2230 /* This call adjusts column width */
2231 cf_timestamp_auto_precision(capture_file_.capFile());
2234 packet_list_->resetColumns();
2239 void MainWindow::on_actionViewTimeDisplaySecondsWithHoursAndMinutes_triggered(bool checked)
2242 recent.gui_seconds_format = TS_SECONDS_HOUR_MIN_SEC;
2244 recent.gui_seconds_format = TS_SECONDS_DEFAULT;
2246 timestamp_set_seconds_type(recent.gui_seconds_format);
2248 if (capture_file_.capFile()) {
2249 /* This call adjusts column width */
2250 cf_timestamp_auto_precision(capture_file_.capFile());
2253 packet_list_->resetColumns();
2257 void MainWindow::on_actionViewEditResolvedName_triggered()
2259 // int column = packet_list_->selectedColumn();
2262 if (packet_list_->currentIndex().isValid()) {
2263 column = packet_list_->currentIndex().column();
2266 main_ui_->addressEditorFrame->editAddresses(capture_file_, column);
2267 showAccordionFrame(main_ui_->addressEditorFrame);
2270 void MainWindow::setNameResolution()
2272 gbl_resolv_flags.mac_name = main_ui_->actionViewNameResolutionPhysical->isChecked() ? TRUE : FALSE;
2273 gbl_resolv_flags.network_name = main_ui_->actionViewNameResolutionNetwork->isChecked() ? TRUE : FALSE;
2274 gbl_resolv_flags.transport_name = main_ui_->actionViewNameResolutionTransport->isChecked() ? TRUE : FALSE;
2277 packet_list_->resetColumns();
2281 void MainWindow::on_actionViewNameResolutionPhysical_triggered()
2283 setNameResolution();
2286 void MainWindow::on_actionViewNameResolutionNetwork_triggered()
2288 setNameResolution();
2291 void MainWindow::on_actionViewNameResolutionTransport_triggered()
2293 setNameResolution();
2296 void MainWindow::zoomText()
2298 // Scale by 10%, rounding to nearest half point, minimum 1 point.
2299 // XXX Small sizes repeat. It might just be easier to create a map of multipliers.
2300 mono_font_ = QFont(wsApp->monospaceFont());
2301 qreal zoom_size = wsApp->monospaceFont().pointSize() * 2 * qPow(1.1, recent.gui_zoom_level);
2302 zoom_size = qRound(zoom_size) / 2.0;
2303 zoom_size = qMax(zoom_size, 1.0);
2304 mono_font_.setPointSizeF(zoom_size);
2305 emit monospaceFontChanged(mono_font_);
2308 void MainWindow::on_actionViewZoomIn_triggered()
2310 recent.gui_zoom_level++;
2314 void MainWindow::on_actionViewZoomOut_triggered()
2316 recent.gui_zoom_level--;
2320 void MainWindow::on_actionViewNormalSize_triggered()
2322 recent.gui_zoom_level = 0;
2326 void MainWindow::on_actionViewColorizePacketList_triggered(bool checked) {
2327 recent.packet_list_colorize = checked;
2328 packet_list_enable_color(checked);
2329 packet_list_->packetListModel()->resetColorized();
2332 void MainWindow::on_actionViewColoringRules_triggered()
2334 ColoringRulesDialog coloring_rules_dialog(this);
2335 connect(&coloring_rules_dialog, SIGNAL(accepted()),
2336 packet_list_, SLOT(recolorPackets()));
2337 coloring_rules_dialog.exec();
2340 // actionViewColorizeConversation1 - 10
2341 void MainWindow::colorizeConversation(bool create_rule)
2343 QAction *cc_action = qobject_cast<QAction *>(sender());
2344 if (!cc_action) return;
2346 if (capture_file_.capFile() && capture_file_.capFile()->current_frame) {
2347 packet_info *pi = &capture_file_.capFile()->edt->pi;
2348 guint8 cc_num = cc_action->data().toUInt();
2349 gchar *filter = NULL;
2351 const conversation_filter_t *color_filter = find_conversation_filter("tcp");
2352 if ((color_filter != NULL) && (color_filter->is_filter_valid(pi)))
2353 filter = color_filter->build_filter_string(pi);
2354 if (filter == NULL) {
2355 color_filter = find_conversation_filter("udp");
2356 if ((color_filter != NULL) && (color_filter->is_filter_valid(pi)))
2357 filter = color_filter->build_filter_string(pi);
2359 if (filter == NULL) {
2360 color_filter = find_conversation_filter("ip");
2361 if ((color_filter != NULL) && (color_filter->is_filter_valid(pi)))
2362 filter = color_filter->build_filter_string(pi);
2364 if (filter == NULL) {
2365 color_filter = find_conversation_filter("ipv6");
2366 if ((color_filter != NULL) && (color_filter->is_filter_valid(pi)))
2367 filter = color_filter->build_filter_string(pi);
2369 if (filter == NULL) {
2370 color_filter = find_conversation_filter("eth");
2371 if ((color_filter != NULL) && (color_filter->is_filter_valid(pi)))
2372 filter = color_filter->build_filter_string(pi);
2374 if( filter == NULL ) {
2375 main_ui_->statusBar->pushTemporaryStatus(tr("Unable to build conversation filter."));
2380 ColoringRulesDialog coloring_rules_dialog(this, filter);
2381 connect(&coloring_rules_dialog, SIGNAL(accepted()),
2382 packet_list_, SLOT(recolorPackets()));
2383 coloring_rules_dialog.exec();
2385 gchar *err_msg = NULL;
2386 if (!color_filters_set_tmp(cc_num, filter, FALSE, &err_msg)) {
2387 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
2390 packet_list_->recolorPackets();
2393 setMenusForSelectedPacket();
2396 void MainWindow::colorizeWithFilter()
2398 QAction *colorize_action = qobject_cast<QAction *>(sender());
2399 if (!colorize_action) return;
2401 QString filter = colorize_action->data().toString();
2402 if (filter.isEmpty()) return;
2405 int color_number = colorize_action->property(color_number_property_).toInt(&ok);
2409 gchar *err_msg = NULL;
2410 if (color_filters_set_tmp(color_number, filter.toUtf8().constData(), FALSE, &err_msg)) {
2411 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
2414 packet_list_->recolorPackets();
2416 // New coloring rule
2417 ColoringRulesDialog coloring_rules_dialog(window(), filter);
2418 connect(&coloring_rules_dialog, SIGNAL(accepted()),
2419 packet_list_, SLOT(recolorPackets()));
2420 coloring_rules_dialog.exec();
2422 main_ui_->actionViewColorizeResetColorization->setEnabled(tmp_color_filters_used());
2425 void MainWindow::on_actionViewColorizeResetColorization_triggered()
2427 gchar *err_msg = NULL;
2428 if (!color_filters_reset_tmp(&err_msg)) {
2429 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
2432 packet_list_->recolorPackets();
2433 setMenusForSelectedPacket();
2436 void MainWindow::on_actionViewColorizeNewConversationRule_triggered()
2438 colorizeConversation(true);
2441 void MainWindow::on_actionViewResizeColumns_triggered()
2443 for (int col = 0; col < packet_list_->packetListModel()->columnCount(); col++) {
2444 packet_list_->resizeColumnToContents(col);
2445 recent_set_column_width(col, packet_list_->columnWidth(col));
2449 void MainWindow::openPacketDialog(bool from_reference)
2453 /* Find the frame for which we're popping up a dialog */
2454 if(from_reference) {
2455 guint32 framenum = fvalue_get_uinteger(&(capture_file_.capFile()->finfo_selected->value));
2459 fdata = frame_data_sequence_find(capture_file_.capFile()->frames, framenum);
2461 fdata = capture_file_.capFile()->current_frame;
2464 /* If we have a frame, pop up the dialog */
2466 PacketDialog *packet_dialog = new PacketDialog(*this, capture_file_, fdata);
2468 connect(this, SIGNAL(monospaceFontChanged(QFont)),
2469 packet_dialog, SIGNAL(monospaceFontChanged(QFont)));
2470 connect(this, SIGNAL(closePacketDialogs()),
2471 packet_dialog, SLOT(close()));
2472 zoomText(); // Emits monospaceFontChanged
2474 packet_dialog->show();
2478 void MainWindow::on_actionViewInternalsConversationHashTables_triggered()
2480 ConversationHashTablesDialog *conversation_hash_tables_dlg = new ConversationHashTablesDialog(this);
2481 conversation_hash_tables_dlg->show();
2484 void MainWindow::on_actionViewInternalsDissectorTables_triggered()
2486 DissectorTablesDialog *dissector_tables_dlg = new DissectorTablesDialog(this);
2487 dissector_tables_dlg->show();
2490 void MainWindow::on_actionViewInternalsSupportedProtocols_triggered()
2492 SupportedProtocolsDialog *supported_protocols_dlg = new SupportedProtocolsDialog(this);
2493 supported_protocols_dlg->show();
2496 void MainWindow::on_actionViewShowPacketInNewWindow_triggered()
2501 // This is only used in ProtoTree. Defining it here makes more sense.
2502 void MainWindow::on_actionContextShowLinkedPacketInNewWindow_triggered()
2504 openPacketDialog(true);
2507 void MainWindow::on_actionViewReload_triggered()
2509 cf_reload(CaptureFile::globalCapFile());
2512 void MainWindow::on_actionViewReload_as_File_Format_or_Capture_triggered()
2514 capture_file *cf = CaptureFile::globalCapFile();
2516 if (cf->open_type == WTAP_TYPE_AUTO)
2517 cf->open_type = open_info_name_to_type("MIME Files Format");
2518 else /* TODO: This should be latest format chosen by user */
2519 cf->open_type = WTAP_TYPE_AUTO;
2525 // Expand / collapse slots in proto_tree
2531 void MainWindow::matchFieldFilter(FilterAction::Action action, FilterAction::ActionType filter_type)
2533 QString field_filter;
2535 if (packet_list_->contextMenuActive() || packet_list_->hasFocus()) {
2536 field_filter = packet_list_->getFilterFromRowAndColumn();
2537 } else if (capture_file_.capFile() && capture_file_.capFile()->finfo_selected) {
2538 char *tmp_field = proto_construct_match_selected_string(capture_file_.capFile()->finfo_selected,
2539 capture_file_.capFile()->edt);
2540 field_filter = QString(tmp_field);
2541 wmem_free(NULL, tmp_field);
2544 if (field_filter.isEmpty()) {
2545 QString err = tr("No filter available. Try another ");
2546 err.append(packet_list_->contextMenuActive() ? "column" : "item");
2548 main_ui_->statusBar->pushTemporaryStatus(err);
2552 filterAction(field_filter, action, filter_type);
2555 static FilterDialog *display_filter_dlg_ = NULL;
2556 void MainWindow::on_actionAnalyzeDisplayFilters_triggered()
2558 if (!display_filter_dlg_) {
2559 display_filter_dlg_ = new FilterDialog(this, FilterDialog::DisplayFilter);
2561 display_filter_dlg_->show();
2562 display_filter_dlg_->raise();
2563 display_filter_dlg_->activateWindow();
2567 void MainWindow::on_actionAnalyzeDisplayFilterMacros_triggered()
2569 struct epan_uat* dfm_uat;
2570 dfilter_macro_get_uat(&dfm_uat);
2571 UatDialog uat_dlg(parentWidget(), dfm_uat);
2574 // Emitting PacketDissectionChanged directly from a QDialog can cause
2575 // problems on OS X.
2576 wsApp->flushAppSignals();
2579 void MainWindow::on_actionAnalyzeCreateAColumn_triggered()
2583 if ( capture_file_.capFile() != 0 && capture_file_.capFile()->finfo_selected != 0 )
2585 colnr = column_prefs_add_custom(COL_CUSTOM, capture_file_.capFile()->finfo_selected->hfinfo->name,
2586 capture_file_.capFile()->finfo_selected->hfinfo->abbrev,0);
2588 packet_list_->columnsChanged();
2589 packet_list_->resizeColumnToContents(colnr);
2595 void MainWindow::applyConversationFilter()
2597 QAction *cfa = qobject_cast<QAction*>(sender());
2600 QString new_filter = cfa->data().toString();
2601 if (new_filter.isEmpty()) return;
2603 df_combo_box_->lineEdit()->setText(new_filter);
2604 df_combo_box_->applyDisplayFilter();
2607 // XXX We could probably create the analyze and prepare actions
2608 // dynamically using FilterActions and consolidate the methods
2609 // below into one callback.
2610 void MainWindow::on_actionAnalyzeAAFSelected_triggered()
2612 matchFieldFilter(FilterAction::ActionApply, FilterAction::ActionTypePlain);
2615 void MainWindow::on_actionAnalyzeAAFNotSelected_triggered()
2617 matchFieldFilter(FilterAction::ActionApply, FilterAction::ActionTypeNot);
2620 void MainWindow::on_actionAnalyzeAAFAndSelected_triggered()
2622 matchFieldFilter(FilterAction::ActionApply, FilterAction::ActionTypeAnd);
2625 void MainWindow::on_actionAnalyzeAAFOrSelected_triggered()
2627 matchFieldFilter(FilterAction::ActionApply, FilterAction::ActionTypeOr);
2630 void MainWindow::on_actionAnalyzeAAFAndNotSelected_triggered()
2632 matchFieldFilter(FilterAction::ActionApply, FilterAction::ActionTypeAndNot);
2635 void MainWindow::on_actionAnalyzeAAFOrNotSelected_triggered()
2637 matchFieldFilter(FilterAction::ActionApply, FilterAction::ActionTypeOrNot);
2640 void MainWindow::on_actionAnalyzePAFSelected_triggered()
2642 matchFieldFilter(FilterAction::ActionPrepare, FilterAction::ActionTypePlain);
2645 void MainWindow::on_actionAnalyzePAFNotSelected_triggered()
2647 matchFieldFilter(FilterAction::ActionPrepare, FilterAction::ActionTypeNot);
2650 void MainWindow::on_actionAnalyzePAFAndSelected_triggered()
2652 matchFieldFilter(FilterAction::ActionPrepare, FilterAction::ActionTypeAnd);
2655 void MainWindow::on_actionAnalyzePAFOrSelected_triggered()
2657 matchFieldFilter(FilterAction::ActionPrepare, FilterAction::ActionTypeOr);
2660 void MainWindow::on_actionAnalyzePAFAndNotSelected_triggered()
2662 matchFieldFilter(FilterAction::ActionPrepare, FilterAction::ActionTypeAndNot);
2665 void MainWindow::on_actionAnalyzePAFOrNotSelected_triggered()
2667 matchFieldFilter(FilterAction::ActionPrepare, FilterAction::ActionTypeOrNot);
2670 void MainWindow::on_actionAnalyzeEnabledProtocols_triggered()
2672 EnabledProtocolsDialog enable_proto_dialog(this);
2673 enable_proto_dialog.exec();
2675 // Emitting PacketDissectionChanged directly from a QDialog can cause
2676 // problems on OS X.
2677 wsApp->flushAppSignals();
2680 void MainWindow::on_actionAnalyzeDecodeAs_triggered()
2682 QAction *da_action = qobject_cast<QAction*>(sender());
2683 bool create_new = false;
2684 if (da_action && da_action->data().toBool() == true) {
2688 DecodeAsDialog da_dialog(this, capture_file_.capFile(), create_new);
2689 connect(this, SIGNAL(setCaptureFile(capture_file*)),
2690 &da_dialog, SLOT(setCaptureFile(capture_file*)));
2693 // Emitting PacketDissectionChanged directly from a QDialog can cause
2694 // problems on OS X.
2695 wsApp->flushAppSignals();
2698 void MainWindow::on_actionAnalyzeReloadLuaPlugins_triggered()
2703 void MainWindow::openFollowStreamDialog(follow_type_t type) {
2704 FollowStreamDialog *fsd = new FollowStreamDialog(*this, capture_file_, type);
2705 connect(fsd, SIGNAL(updateFilter(QString, bool)), this, SLOT(filterPackets(QString, bool)));
2706 connect(fsd, SIGNAL(goToPacket(int)), packet_list_, SLOT(goToPacket(int)));
2709 fsd->follow(getFilter());
2712 void MainWindow::on_actionAnalyzeFollowTCPStream_triggered()
2714 openFollowStreamDialog(FOLLOW_TCP);
2717 void MainWindow::on_actionAnalyzeFollowUDPStream_triggered()
2719 openFollowStreamDialog(FOLLOW_UDP);
2722 void MainWindow::on_actionAnalyzeFollowSSLStream_triggered()
2724 openFollowStreamDialog(FOLLOW_SSL);
2727 void MainWindow::on_actionAnalyzeFollowHTTPStream_triggered()
2729 openFollowStreamDialog(FOLLOW_HTTP);
2732 void MainWindow::openSCTPAllAssocsDialog()
2734 SCTPAllAssocsDialog *sctp_dialog = new SCTPAllAssocsDialog(this, capture_file_.capFile());
2735 connect(sctp_dialog, SIGNAL(filterPackets(QString,bool)),
2736 this, SLOT(filterPackets(QString,bool)));
2737 connect(this, SIGNAL(setCaptureFile(capture_file*)),
2738 sctp_dialog, SLOT(setCaptureFile(capture_file*)));
2739 sctp_dialog->fillTable();
2741 if (sctp_dialog->isMinimized() == true)
2743 sctp_dialog->showNormal();
2747 sctp_dialog->show();
2750 sctp_dialog->raise();
2751 sctp_dialog->activateWindow();
2754 void MainWindow::on_actionSCTPShowAllAssociations_triggered()
2756 openSCTPAllAssocsDialog();
2759 void MainWindow::on_actionSCTPAnalyseThisAssociation_triggered()
2761 SCTPAssocAnalyseDialog *sctp_analyse = new SCTPAssocAnalyseDialog(this, NULL, capture_file_.capFile());
2762 connect(sctp_analyse, SIGNAL(filterPackets(QString,bool)),
2763 this, SLOT(filterPackets(QString,bool)));
2765 if (sctp_analyse->isMinimized() == true)
2767 sctp_analyse->showNormal();
2771 sctp_analyse->show();
2774 sctp_analyse->raise();
2775 sctp_analyse->activateWindow();
2778 void MainWindow::on_actionSCTPFilterThisAssociation_triggered()
2780 sctp_assoc_info_t* assoc = SCTPAssocAnalyseDialog::findAssocForPacket(capture_file_.capFile());
2782 QString newFilter = QString("sctp.assoc_index==%1").arg(assoc->assoc_id);
2784 emit filterPackets(newFilter, false);
2789 void MainWindow::statCommandWlanStatistics(const char *arg, void *)
2791 WlanStatisticsDialog *wlan_stats_dlg = new WlanStatisticsDialog(*this, capture_file_, arg);
2792 connect(wlan_stats_dlg, SIGNAL(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)),
2793 this, SLOT(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)));
2794 wlan_stats_dlg->show();
2797 void MainWindow::on_actionWirelessWlanStatistics_triggered()
2799 statCommandWlanStatistics(NULL, NULL);
2803 void MainWindow::statCommandExpertInfo(const char *, void *)
2805 ExpertInfoDialog *expert_dialog = new ExpertInfoDialog(*this, capture_file_);
2806 const DisplayFilterEdit *df_edit = dynamic_cast<DisplayFilterEdit *>(df_combo_box_->lineEdit());
2808 expert_dialog->setDisplayFilter(df_edit->text());
2810 connect(expert_dialog, SIGNAL(goToPacket(int, int)),
2811 packet_list_, SLOT(goToPacket(int, int)));
2812 connect(expert_dialog, SIGNAL(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)),
2813 this, SLOT(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)));
2815 expert_dialog->show();
2818 void MainWindow::on_actionAnalyzeExpertInfo_triggered()
2820 statCommandExpertInfo(NULL, NULL);
2824 // Next / previous / first / last slots in packet_list
2828 void MainWindow::on_actionStatisticsFlowGraph_triggered()
2830 SequenceDialog *sequence_dialog = new SequenceDialog(*this, capture_file_);
2831 connect(sequence_dialog, SIGNAL(goToPacket(int)),
2832 packet_list_, SLOT(goToPacket(int)));
2833 sequence_dialog->show();
2836 void MainWindow::openTcpStreamDialog(int graph_type)
2838 TCPStreamDialog *stream_dialog = new TCPStreamDialog(this, capture_file_.capFile(), (tcp_graph_type)graph_type);
2839 connect(stream_dialog, SIGNAL(goToPacket(int)),
2840 packet_list_, SLOT(goToPacket(int)));
2841 connect(this, SIGNAL(setCaptureFile(capture_file*)),
2842 stream_dialog, SLOT(setCaptureFile(capture_file*)));
2843 stream_dialog->show();
2846 void MainWindow::on_actionStatisticsTcpStreamStevens_triggered()
2848 openTcpStreamDialog(GRAPH_TSEQ_STEVENS);
2851 void MainWindow::on_actionStatisticsTcpStreamTcptrace_triggered()
2853 openTcpStreamDialog(GRAPH_TSEQ_TCPTRACE);
2856 void MainWindow::on_actionStatisticsTcpStreamThroughput_triggered()
2858 openTcpStreamDialog(GRAPH_THROUGHPUT);
2861 void MainWindow::on_actionStatisticsTcpStreamRoundTripTime_triggered()
2863 openTcpStreamDialog(GRAPH_RTT);
2866 void MainWindow::on_actionStatisticsTcpStreamWindowScaling_triggered()
2868 openTcpStreamDialog(GRAPH_WSCALE);
2872 void MainWindow::statCommandMulticastStatistics(const char *arg, void *)
2874 MulticastStatisticsDialog *mcast_stats_dlg = new MulticastStatisticsDialog(*this, capture_file_, arg);
2875 connect(mcast_stats_dlg, SIGNAL(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)),
2876 this, SLOT(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)));
2877 mcast_stats_dlg->show();
2880 void MainWindow::on_actionStatisticsUdpMulticastStreams_triggered()
2882 statCommandMulticastStatistics(NULL, NULL);
2885 void MainWindow::openStatisticsTreeDialog(const gchar *abbr)
2887 StatsTreeDialog *st_dialog = new StatsTreeDialog(*this, capture_file_, abbr);
2888 // connect(st_dialog, SIGNAL(goToPacket(int)),
2889 // packet_list_, SLOT(goToPacket(int)));
2893 void MainWindow::on_actionStatistics29WestTopics_Advertisements_by_Topic_triggered()
2895 openStatisticsTreeDialog("lbmr_topic_ads_topic");
2898 void MainWindow::on_actionStatistics29WestTopics_Advertisements_by_Source_triggered()
2900 openStatisticsTreeDialog("lbmr_topic_ads_source");
2903 void MainWindow::on_actionStatistics29WestTopics_Advertisements_by_Transport_triggered()
2905 openStatisticsTreeDialog("lbmr_topic_ads_transport");
2908 void MainWindow::on_actionStatistics29WestTopics_Queries_by_Topic_triggered()
2910 openStatisticsTreeDialog("lbmr_topic_queries_topic");
2913 void MainWindow::on_actionStatistics29WestTopics_Queries_by_Receiver_triggered()
2915 openStatisticsTreeDialog("lbmr_topic_queries_receiver");
2918 void MainWindow::on_actionStatistics29WestTopics_Wildcard_Queries_by_Pattern_triggered()
2920 openStatisticsTreeDialog("lbmr_topic_queries_pattern");
2923 void MainWindow::on_actionStatistics29WestTopics_Wildcard_Queries_by_Receiver_triggered()
2925 openStatisticsTreeDialog("lbmr_topic_queries_pattern_receiver");
2928 void MainWindow::on_actionStatistics29WestQueues_Advertisements_by_Queue_triggered()
2930 openStatisticsTreeDialog("lbmr_queue_ads_queue");
2933 void MainWindow::on_actionStatistics29WestQueues_Advertisements_by_Source_triggered()
2935 openStatisticsTreeDialog("lbmr_queue_ads_source");
2938 void MainWindow::on_actionStatistics29WestQueues_Queries_by_Queue_triggered()
2940 openStatisticsTreeDialog("lbmr_queue_queries_queue");
2943 void MainWindow::on_actionStatistics29WestQueues_Queries_by_Receiver_triggered()
2945 openStatisticsTreeDialog("lbmr_queue_queries_receiver");
2948 void MainWindow::on_actionStatistics29WestUIM_Streams_triggered()
2950 LBMStreamDialog *stream_dialog = new LBMStreamDialog(this, capture_file_.capFile());
2951 // connect(stream_dialog, SIGNAL(goToPacket(int)),
2952 // packet_list_, SLOT(goToPacket(int)));
2953 connect(this, SIGNAL(setCaptureFile(capture_file*)),
2954 stream_dialog, SLOT(setCaptureFile(capture_file*)));
2955 stream_dialog->show();
2958 void MainWindow::on_actionStatistics29WestUIM_Stream_Flow_Graph_triggered()
2960 LBMUIMFlowDialog * uimflow_dialog = new LBMUIMFlowDialog(this, capture_file_.capFile());
2961 connect(uimflow_dialog, SIGNAL(goToPacket(int)),
2962 packet_list_, SLOT(goToPacket(int)));
2963 connect(this, SIGNAL(setCaptureFile(capture_file*)),
2964 uimflow_dialog, SLOT(setCaptureFile(capture_file*)));
2965 uimflow_dialog->show();
2968 void MainWindow::on_actionStatistics29WestLBTRM_triggered()
2970 LBMLBTRMTransportDialog * lbtrm_dialog = new LBMLBTRMTransportDialog(this, capture_file_.capFile());
2971 connect(lbtrm_dialog, SIGNAL(goToPacket(int)),
2972 packet_list_, SLOT(goToPacket(int)));
2973 connect(this, SIGNAL(setCaptureFile(capture_file*)),
2974 lbtrm_dialog, SLOT(setCaptureFile(capture_file*)));
2975 lbtrm_dialog->show();
2977 void MainWindow::on_actionStatistics29WestLBTRU_triggered()
2979 LBMLBTRUTransportDialog * lbtru_dialog = new LBMLBTRUTransportDialog(this, capture_file_.capFile());
2980 connect(lbtru_dialog, SIGNAL(goToPacket(int)),
2981 packet_list_, SLOT(goToPacket(int)));
2982 connect(this, SIGNAL(setCaptureFile(capture_file*)),
2983 lbtru_dialog, SLOT(setCaptureFile(capture_file*)));
2984 lbtru_dialog->show();
2987 void MainWindow::on_actionStatisticsANCP_triggered()
2989 openStatisticsTreeDialog("ancp");
2992 void MainWindow::on_actionStatisticsBACappInstanceId_triggered()
2994 openStatisticsTreeDialog("bacapp_instanceid");
2997 void MainWindow::on_actionStatisticsBACappIP_triggered()
2999 openStatisticsTreeDialog("bacapp_ip");
3002 void MainWindow::on_actionStatisticsBACappObjectId_triggered()
3004 openStatisticsTreeDialog("bacapp_objectid");
3007 void MainWindow::on_actionStatisticsBACappService_triggered()
3009 openStatisticsTreeDialog("bacapp_service");
3012 void MainWindow::on_actionStatisticsCollectd_triggered()
3014 openStatisticsTreeDialog("collectd");
3018 void MainWindow::statCommandConversations(const char *arg, void *userdata)
3020 ConversationDialog *conv_dialog = new ConversationDialog(*this, capture_file_, GPOINTER_TO_INT(userdata), arg);
3021 connect(conv_dialog, SIGNAL(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)),
3022 this, SLOT(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)));
3023 connect(conv_dialog, SIGNAL(openFollowStreamDialog(follow_type_t)),
3024 this, SLOT(openFollowStreamDialog(follow_type_t)));
3025 connect(conv_dialog, SIGNAL(openTcpStreamGraph(int)),
3026 this, SLOT(openTcpStreamDialog(int)));
3027 conv_dialog->show();
3030 void MainWindow::on_actionStatisticsConversations_triggered()
3032 statCommandConversations(NULL, NULL);
3036 void MainWindow::statCommandEndpoints(const char *arg, void *userdata)
3038 EndpointDialog *endp_dialog = new EndpointDialog(*this, capture_file_, GPOINTER_TO_INT(userdata), arg);
3039 connect(endp_dialog, SIGNAL(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)),
3040 this, SLOT(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)));
3041 connect(endp_dialog, SIGNAL(openFollowStreamDialog(follow_type_t)),
3042 this, SLOT(openFollowStreamDialog(follow_type_t)));
3043 connect(endp_dialog, SIGNAL(openTcpStreamGraph(int)),
3044 this, SLOT(openTcpStreamDialog(int)));
3045 endp_dialog->show();
3048 void MainWindow::on_actionStatisticsEndpoints_triggered()
3050 statCommandEndpoints(NULL, NULL);
3053 void MainWindow::on_actionStatisticsHART_IP_triggered()
3055 openStatisticsTreeDialog("hart_ip");
3058 void MainWindow::on_actionStatisticsHTTPPacketCounter_triggered()
3060 openStatisticsTreeDialog("http");
3063 void MainWindow::on_actionStatisticsHTTPRequests_triggered()
3065 openStatisticsTreeDialog("http_req");
3068 void MainWindow::on_actionStatisticsHTTPLoadDistribution_triggered()
3070 openStatisticsTreeDialog("http_srv");
3073 void MainWindow::on_actionStatisticsPacketLengths_triggered()
3075 openStatisticsTreeDialog("plen");
3079 void MainWindow::statCommandIOGraph(const char *, void *)
3081 IOGraphDialog *iog_dialog = new IOGraphDialog(*this, capture_file_);
3082 connect(iog_dialog, SIGNAL(goToPacket(int)), packet_list_, SLOT(goToPacket(int)));
3083 connect(this, SIGNAL(reloadFields()), iog_dialog, SLOT(reloadFields()));
3087 void MainWindow::on_actionStatisticsIOGraph_triggered()
3089 statCommandIOGraph(NULL, NULL);
3092 void MainWindow::on_actionStatisticsSametime_triggered()
3094 openStatisticsTreeDialog("sametime");
3097 void MainWindow::on_actionStatisticsDNS_triggered()
3099 openStatisticsTreeDialog("dns");
3102 void MainWindow::actionStatisticsPlugin_triggered()
3104 QAction* action = qobject_cast<QAction*>(sender());
3106 openStatisticsTreeDialog(action->data().toString().toUtf8());
3110 void MainWindow::on_actionStatisticsHTTP2_triggered()
3112 openStatisticsTreeDialog("http2");
3118 void MainWindow::openVoipCallsDialog(bool all_flows)
3120 VoipCallsDialog *voip_calls_dialog = new VoipCallsDialog(*this, capture_file_, all_flows);
3121 connect(voip_calls_dialog, SIGNAL(goToPacket(int)),
3122 packet_list_, SLOT(goToPacket(int)));
3123 connect(voip_calls_dialog, SIGNAL(updateFilter(QString, bool)),
3124 this, SLOT(filterPackets(QString, bool)));
3125 voip_calls_dialog->show();
3128 void MainWindow::on_actionTelephonyVoipCalls_triggered()
3130 openVoipCallsDialog();
3133 void MainWindow::on_actionTelephonyGsmMapSummary_triggered()
3135 GsmMapSummaryDialog *gms_dialog = new GsmMapSummaryDialog(*this, capture_file_);
3139 void MainWindow::on_actionTelephonyIax2StreamAnalysis_triggered()
3141 Iax2AnalysisDialog *iax2_analysis_dialog = new Iax2AnalysisDialog(*this, capture_file_);
3142 connect(iax2_analysis_dialog, SIGNAL(goToPacket(int)),
3143 packet_list_, SLOT(goToPacket(int)));
3144 iax2_analysis_dialog->show();
3147 void MainWindow::on_actionTelephonyISUPMessages_triggered()
3149 openStatisticsTreeDialog("isup_msg");
3153 void MainWindow::statCommandLteMacStatistics(const char *arg, void *)
3155 LteMacStatisticsDialog *lte_mac_stats_dlg = new LteMacStatisticsDialog(*this, capture_file_, arg);
3156 connect(lte_mac_stats_dlg, SIGNAL(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)),
3157 this, SLOT(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)));
3158 lte_mac_stats_dlg->show();
3161 void MainWindow::on_actionTelephonyLteMacStatistics_triggered()
3163 statCommandLteMacStatistics(NULL, NULL);
3166 void MainWindow::statCommandLteRlcStatistics(const char *arg, void *)
3168 LteRlcStatisticsDialog *lte_rlc_stats_dlg = new LteRlcStatisticsDialog(*this, capture_file_, arg);
3169 connect(lte_rlc_stats_dlg, SIGNAL(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)),
3170 this, SLOT(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)));
3171 // N.B. It is necessary for the RLC Statistics window to launch the RLC graph in this way, to ensure
3172 // that the goToPacket() signal/slot connection gets set up...
3173 connect(lte_rlc_stats_dlg, SIGNAL(launchRLCGraph(bool, guint16, guint8, guint16, guint16, guint8)),
3174 this, SLOT(launchRLCGraph(bool, guint16, guint8, guint16, guint16, guint8)));
3176 lte_rlc_stats_dlg->show();
3179 void MainWindow::on_actionTelephonyLteRlcStatistics_triggered()
3181 statCommandLteRlcStatistics(NULL, NULL);
3184 void MainWindow::launchRLCGraph(bool channelKnown,
3185 guint16 ueid, guint8 rlcMode,
3186 guint16 channelType, guint16 channelId, guint8 direction)
3188 LteRlcGraphDialog *lrg_dialog = new LteRlcGraphDialog(*this, capture_file_, channelKnown);
3189 connect(lrg_dialog, SIGNAL(goToPacket(int)), packet_list_, SLOT(goToPacket(int)));
3190 // This is a bit messy, but wanted to hide these parameters from users of
3191 // on_actionTelephonyLteRlcGraph_triggered().
3193 lrg_dialog->setChannelInfo(ueid, rlcMode, channelType, channelId, direction);
3198 void MainWindow::on_actionTelephonyLteRlcGraph_triggered()
3200 // We don't yet know the channel.
3201 launchRLCGraph(false, 0, 0, 0, 0, 0);
3204 void MainWindow::on_actionTelephonyMtp3Summary_triggered()
3206 Mtp3SummaryDialog *mtp3s_dialog = new Mtp3SummaryDialog(*this, capture_file_);
3207 mtp3s_dialog->show();
3210 void MainWindow::on_actionTelephonyRTPStreams_triggered()
3212 RtpStreamDialog *rtp_stream_dialog = new RtpStreamDialog(*this, capture_file_);
3213 connect(rtp_stream_dialog, SIGNAL(packetsMarked()),
3214 packet_list_, SLOT(redrawVisiblePackets()));
3215 connect(rtp_stream_dialog, SIGNAL(goToPacket(int)),
3216 packet_list_, SLOT(goToPacket(int)));
3217 connect(rtp_stream_dialog, SIGNAL(updateFilter(QString, bool)),
3218 this, SLOT(filterPackets(QString, bool)));
3219 rtp_stream_dialog->show();
3222 void MainWindow::on_actionTelephonyRTPStreamAnalysis_triggered()
3224 RtpAnalysisDialog *rtp_analysis_dialog = new RtpAnalysisDialog(*this, capture_file_);
3225 connect(rtp_analysis_dialog, SIGNAL(goToPacket(int)),
3226 packet_list_, SLOT(goToPacket(int)));
3227 rtp_analysis_dialog->show();
3230 void MainWindow::on_actionTelephonyRTSPPacketCounter_triggered()
3232 openStatisticsTreeDialog("rtsp");
3235 void MainWindow::on_actionTelephonySMPPOperations_triggered()
3237 openStatisticsTreeDialog("smpp_commands");
3240 void MainWindow::on_actionTelephonyUCPMessages_triggered()
3242 openStatisticsTreeDialog("ucp_messages");
3245 void MainWindow::on_actionTelephonySipFlows_triggered()
3247 openVoipCallsDialog(true);
3252 void MainWindow::on_actionBluetoothATT_Server_Attributes_triggered()
3254 BluetoothAttServerAttributesDialog *bluetooth_att_sever_attributes_dialog = new BluetoothAttServerAttributesDialog(*this, capture_file_);
3255 connect(bluetooth_att_sever_attributes_dialog, SIGNAL(goToPacket(int)),
3256 packet_list_, SLOT(goToPacket(int)));
3257 connect(bluetooth_att_sever_attributes_dialog, SIGNAL(updateFilter(QString, bool)),
3258 this, SLOT(filterPackets(QString, bool)));
3259 bluetooth_att_sever_attributes_dialog->show();
3262 void MainWindow::on_actionBluetoothDevices_triggered()
3264 BluetoothDevicesDialog *bluetooth_devices_dialog = new BluetoothDevicesDialog(*this, capture_file_);
3265 connect(bluetooth_devices_dialog, SIGNAL(goToPacket(int)),
3266 packet_list_, SLOT(goToPacket(int)));
3267 connect(bluetooth_devices_dialog, SIGNAL(updateFilter(QString, bool)),
3268 this, SLOT(filterPackets(QString, bool)));
3269 bluetooth_devices_dialog->show();
3272 void MainWindow::on_actionBluetoothHCI_Summary_triggered()
3274 BluetoothHciSummaryDialog *bluetooth_hci_summary_dialog = new BluetoothHciSummaryDialog(*this, capture_file_);
3275 connect(bluetooth_hci_summary_dialog, SIGNAL(goToPacket(int)),
3276 packet_list_, SLOT(goToPacket(int)));
3277 connect(bluetooth_hci_summary_dialog, SIGNAL(updateFilter(QString, bool)),
3278 this, SLOT(filterPackets(QString, bool)));
3279 bluetooth_hci_summary_dialog->show();
3283 void MainWindow::on_actionHelpContents_triggered() {
3285 wsApp->helpTopicAction(HELP_CONTENT);
3288 void MainWindow::on_actionHelpMPWireshark_triggered() {
3290 wsApp->helpTopicAction(LOCALPAGE_MAN_WIRESHARK);
3293 void MainWindow::on_actionHelpMPWireshark_Filter_triggered() {
3294 wsApp->helpTopicAction(LOCALPAGE_MAN_WIRESHARK_FILTER);
3297 void MainWindow::on_actionHelpMPCapinfos_triggered() {
3298 wsApp->helpTopicAction(LOCALPAGE_MAN_CAPINFOS);
3301 void MainWindow::on_actionHelpMPDumpcap_triggered() {
3302 wsApp->helpTopicAction(LOCALPAGE_MAN_DUMPCAP);
3305 void MainWindow::on_actionHelpMPEditcap_triggered() {
3306 wsApp->helpTopicAction(LOCALPAGE_MAN_EDITCAP);
3309 void MainWindow::on_actionHelpMPMergecap_triggered() {
3310 wsApp->helpTopicAction(LOCALPAGE_MAN_MERGECAP);
3313 void MainWindow::on_actionHelpMPRawShark_triggered() {
3314 wsApp->helpTopicAction(LOCALPAGE_MAN_RAWSHARK);
3317 void MainWindow::on_actionHelpMPReordercap_triggered() {
3318 wsApp->helpTopicAction(LOCALPAGE_MAN_REORDERCAP);
3321 void MainWindow::on_actionHelpMPText2cap_triggered() {
3322 wsApp->helpTopicAction(LOCALPAGE_MAN_TEXT2PCAP);
3325 void MainWindow::on_actionHelpMPTShark_triggered() {
3326 wsApp->helpTopicAction(LOCALPAGE_MAN_TSHARK);
3329 void MainWindow::on_actionHelpWebsite_triggered() {
3331 wsApp->helpTopicAction(ONLINEPAGE_HOME);
3334 void MainWindow::on_actionHelpFAQ_triggered() {
3336 wsApp->helpTopicAction(ONLINEPAGE_FAQ);
3339 void MainWindow::on_actionHelpAsk_triggered() {
3341 wsApp->helpTopicAction(ONLINEPAGE_ASK);
3344 void MainWindow::on_actionHelpDownloads_triggered() {
3346 wsApp->helpTopicAction(ONLINEPAGE_DOWNLOAD);
3349 void MainWindow::on_actionHelpWiki_triggered() {
3351 wsApp->helpTopicAction(ONLINEPAGE_WIKI);
3354 void MainWindow::on_actionHelpSampleCaptures_triggered() {
3356 wsApp->helpTopicAction(ONLINEPAGE_SAMPLE_FILES);
3359 #ifdef HAVE_SOFTWARE_UPDATE
3360 void MainWindow::checkForUpdates()
3362 software_update_check();
3366 void MainWindow::on_actionHelpAbout_triggered()
3368 AboutDialog *about_dialog = new AboutDialog(this);
3370 if (about_dialog->isMinimized() == true)
3372 about_dialog->showNormal();
3376 about_dialog->show();
3379 about_dialog->raise();
3380 about_dialog->activateWindow();
3383 void MainWindow::on_actionGoGoToPacket_triggered() {
3384 if (packet_list_->model()->rowCount() < 1) {
3387 previous_focus_ = wsApp->focusWidget();
3388 connect(previous_focus_, SIGNAL(destroyed()), this, SLOT(resetPreviousFocus()));
3390 showAccordionFrame(main_ui_->goToFrame, true);
3391 if (main_ui_->goToFrame->isVisible()) {
3392 main_ui_->goToLineEdit->clear();
3393 main_ui_->goToLineEdit->setFocus();
3397 void MainWindow::on_actionGoGoToLinkedPacket_triggered()
3399 QAction *gta = qobject_cast<QAction*>(sender());
3403 int packet_num = gta->data().toInt(&ok);
3406 packet_list_->goToPacket(packet_num);
3409 // gtk/main_menubar.c:goto_conversation_frame
3410 void MainWindow::goToConversationFrame(bool go_next) {
3411 gchar *filter = NULL;
3412 dfilter_t *dfcode = NULL;
3413 gboolean found_packet = FALSE;
3414 packet_info *pi = &(capture_file_.capFile()->edt->pi);
3415 conversation_filter_t* conv_filter;
3417 /* Try to build a conversation
3418 * filter in the order TCP, UDP, IP, Ethernet and apply the
3420 conv_filter = find_conversation_filter("tcp");
3421 if ((conv_filter != NULL) && (conv_filter->is_filter_valid(pi)))
3422 filter = conv_filter->build_filter_string(pi);
3423 conv_filter = find_conversation_filter("udp");
3424 if ((conv_filter != NULL) && (conv_filter->is_filter_valid(pi)))
3425 filter = conv_filter->build_filter_string(pi);
3426 conv_filter = find_conversation_filter("ip");
3427 if ((conv_filter != NULL) && (conv_filter->is_filter_valid(pi)))
3428 filter = conv_filter->build_filter_string(pi);
3429 conv_filter = find_conversation_filter("ipv6");
3430 if ((conv_filter != NULL) && (conv_filter->is_filter_valid(pi)))
3431 filter = conv_filter->build_filter_string(pi);
3433 if( filter == NULL ) {
3434 main_ui_->statusBar->pushTemporaryStatus(tr("Unable to build conversation filter."));
3439 if (!dfilter_compile(filter, &dfcode, NULL)) {
3440 /* The attempt failed; report an error. */
3441 main_ui_->statusBar->pushTemporaryStatus(tr("Error compiling filter for this conversation."));
3446 found_packet = cf_find_packet_dfilter(capture_file_.capFile(), dfcode, go_next ? SD_FORWARD : SD_BACKWARD);
3448 if (!found_packet) {
3449 /* We didn't find a packet */
3450 main_ui_->statusBar->pushTemporaryStatus(tr("No previous/next packet in conversation."));
3453 dfilter_free(dfcode);
3457 void MainWindow::on_actionGoNextConversationPacket_triggered()
3459 goToConversationFrame(true);
3462 void MainWindow::on_actionGoPreviousConversationPacket_triggered()
3464 goToConversationFrame(false);
3467 void MainWindow::on_actionGoAutoScroll_toggled(bool checked)
3469 packet_list_->setVerticalAutoScroll(checked);
3472 void MainWindow::resetPreviousFocus() {
3473 previous_focus_ = NULL;
3476 void MainWindow::on_goToCancel_clicked()
3478 main_ui_->goToFrame->animatedHide();
3479 if (previous_focus_) {
3480 disconnect(previous_focus_, SIGNAL(destroyed()), this, SLOT(resetPreviousFocus()));
3481 previous_focus_->setFocus();
3482 resetPreviousFocus();
3486 void MainWindow::on_goToGo_clicked()
3488 gotoFrame(main_ui_->goToLineEdit->text().toInt());
3490 on_goToCancel_clicked();
3493 void MainWindow::on_goToLineEdit_returnPressed()
3495 on_goToGo_clicked();
3498 void MainWindow::on_actionCaptureStart_triggered()
3500 //#ifdef HAVE_AIRPCAP
3501 // airpcap_if_active = airpcap_if_selected;
3502 // if (airpcap_if_active)
3503 // airpcap_set_toolbar_start_capture(airpcap_if_active);
3506 // if (cap_open_w) {
3508 // * There's an options dialog; get the values from it and close it.
3510 // gboolean success;
3512 // /* Determine if "capture start" while building of the "capture options" window */
3513 // /* is in progress. If so, ignore the "capture start. */
3514 // /* XXX: Would it be better/cleaner for the "capture options" window code to */
3515 // /* disable the capture start button temporarily ? */
3516 // if (cap_open_complete == FALSE) {
3517 // return; /* Building options window: ignore "capture start" */
3519 // success = capture_dlg_prep(cap_open_w);
3520 // window_destroy(GTK_WIDGET(cap_open_w));
3522 // return; /* error in options dialog */
3526 if (global_capture_opts.num_selected == 0) {
3527 QString err_msg = tr("No Interface Selected");
3528 main_ui_->statusBar->pushTemporaryStatus(err_msg);
3529 main_ui_->actionCaptureStart->setChecked(false);
3533 /* XXX - will closing this remove a temporary file? */
3534 QString before_what(tr(" before starting a new capture"));
3535 if (testCaptureFileClose(before_what)) {
3538 // simply clicking the button sets it to 'checked' even though we've
3539 // decided to do nothing, so undo that
3540 main_ui_->actionCaptureStart->setChecked(false);
3542 #endif // HAVE_LIBPCAP
3545 void MainWindow::on_actionCaptureStop_triggered()
3550 void MainWindow::on_actionCaptureRestart_triggered()
3552 QString before_what(tr(" before restarting a new capture"));
3553 if (!testCaptureFileClose(before_what, RestartButtons))
3556 /* TODO: GTK use only this: capture_restart(&cap_session_); */
3560 static FilterDialog *capture_filter_dlg_ = NULL;
3561 void MainWindow::on_actionCaptureCaptureFilters_triggered()
3563 if (!capture_filter_dlg_) {
3564 capture_filter_dlg_ = new FilterDialog(this, FilterDialog::CaptureFilter);
3566 capture_filter_dlg_->show();
3567 capture_filter_dlg_->raise();
3568 capture_filter_dlg_->activateWindow();
3571 void MainWindow::on_actionStatisticsCaptureFileProperties_triggered()
3573 CaptureFilePropertiesDialog *capture_file_properties_dialog = new CaptureFilePropertiesDialog(*this, capture_file_);
3574 connect(capture_file_properties_dialog, SIGNAL(captureCommentChanged()),
3575 this, SLOT(updateForUnsavedChanges()));
3576 capture_file_properties_dialog->show();
3579 void MainWindow::on_actionStatisticsResolvedAddresses_triggered()
3581 ResolvedAddressesDialog *resolved_addresses_dialog = new ResolvedAddressesDialog(this, &capture_file_);
3582 resolved_addresses_dialog->show();
3585 void MainWindow::on_actionStatisticsProtocolHierarchy_triggered()
3587 ProtocolHierarchyDialog *phd = new ProtocolHierarchyDialog(*this, capture_file_);
3588 connect(phd, SIGNAL(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)),
3589 this, SLOT(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)));
3594 void MainWindow::on_actionCaptureOptions_triggered()
3596 connect(&capture_interfaces_dialog_, SIGNAL(setFilterValid(bool)), this, SLOT(startInterfaceCapture(bool)));
3597 capture_interfaces_dialog_.SetTab(0);
3598 capture_interfaces_dialog_.updateInterfaces();
3600 if (capture_interfaces_dialog_.isMinimized() == true)
3602 capture_interfaces_dialog_.showNormal();
3606 capture_interfaces_dialog_.show();
3609 capture_interfaces_dialog_.raise();
3610 capture_interfaces_dialog_.activateWindow();
3613 void MainWindow::on_actionCaptureRefreshInterfaces_triggered()
3615 main_ui_->actionCaptureRefreshInterfaces->setEnabled(false);
3616 wsApp->refreshLocalInterfaces();
3617 main_ui_->actionCaptureRefreshInterfaces->setEnabled(true);
3621 void MainWindow::externalMenuItem_triggered()
3623 QAction * triggerAction = NULL;
3625 ext_menubar_t * entry = NULL;
3627 if ( QObject::sender() != NULL)
3629 triggerAction = (QAction *)QObject::sender();
3630 v = triggerAction->data();
3632 if ( v.canConvert<void *>())
3634 entry = (ext_menubar_t *)v.value<void *>();
3636 if ( entry->type == EXT_MENUBAR_ITEM )
3638 entry->callback(EXT_MENUBAR_QT_GUI, (gpointer) ((void *)main_ui_), entry->user_data);
3642 QDesktopServices::openUrl(QUrl(QString((gchar *)entry->user_data)));
3648 void MainWindow::gotoFrame(int packet_num)
3650 if ( packet_num > 0 )
3652 packet_list_->goToPacket(packet_num);
3657 void MainWindow::extcap_options_finished(int result)
3659 if ( result == QDialog::Accepted )
3663 this->main_welcome_->getInterfaceTree()->interfaceListChanged();
3666 void MainWindow::showExtcapOptionsDialog(QString &device_name)
3668 ExtcapOptionsDialog * extcap_options_dialog = ExtcapOptionsDialog::createForDevice(device_name, this);
3669 /* The dialog returns null, if the given device name is not a valid extcap device */
3670 if ( extcap_options_dialog != NULL )
3672 connect(extcap_options_dialog, SIGNAL(finished(int)),
3673 this, SLOT(extcap_options_finished(int)));
3674 extcap_options_dialog->show();
3679 // Q_DECLARE_METATYPE(field_info *) called in proto_tree.h
3681 void MainWindow::on_actionContextCopyBytesHexTextDump_triggered()
3683 QAction *ca = qobject_cast<QAction*>(sender());
3686 field_info *fi = ca->data().value<field_info *>();
3688 byte_view_tab_->copyData(ByteViewTab::copyDataHexTextDump, fi);
3691 void MainWindow::on_actionContextCopyBytesHexDump_triggered()
3693 QAction *ca = qobject_cast<QAction*>(sender());
3696 field_info *fi = ca->data().value<field_info *>();
3698 byte_view_tab_->copyData(ByteViewTab::copyDataHexDump, fi);
3701 void MainWindow::on_actionContextCopyBytesPrintableText_triggered()
3703 QAction *ca = qobject_cast<QAction*>(sender());
3706 field_info *fi = ca->data().value<field_info *>();
3708 byte_view_tab_->copyData(ByteViewTab::copyDataPrintableText, fi);
3711 void MainWindow::on_actionContextCopyBytesHexStream_triggered()
3713 QAction *ca = qobject_cast<QAction*>(sender());
3716 field_info *fi = ca->data().value<field_info *>();
3718 byte_view_tab_->copyData(ByteViewTab::copyDataHexStream, fi);
3721 void MainWindow::on_actionContextCopyBytesBinary_triggered()
3723 QAction *ca = qobject_cast<QAction*>(sender());
3726 field_info *fi = ca->data().value<field_info *>();
3728 byte_view_tab_->copyData(ByteViewTab::copyDataBinary, fi);
3731 void MainWindow::on_actionContextWikiProtocolPage_triggered()
3733 QAction *wa = qobject_cast<QAction*>(sender());
3737 int field_id = wa->data().toInt(&ok);
3740 const QString proto_abbrev = proto_registrar_get_abbrev(field_id);
3742 int ret = QMessageBox::question(this, wsApp->windowTitleString(tr("Wiki Page for %1").arg(proto_abbrev)),
3743 tr("<p>The Wireshark Wiki is maintained by the community.</p>"
3744 "<p>The page you are about to load might be wonderful, "
3745 "incomplete, wrong, or nonexistent.</p>"
3746 "<p>Proceed to the wiki?</p>"),
3747 QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
3749 if (ret != QMessageBox::Yes) return;
3751 QUrl wiki_url = QString("https://wiki.wireshark.org/Protocols/%1").arg(proto_abbrev);
3752 QDesktopServices::openUrl(wiki_url);
3755 void MainWindow::on_actionContextFilterFieldReference_triggered()
3757 QAction *wa = qobject_cast<QAction*>(sender());
3761 int field_id = wa->data().toInt(&ok);
3764 const QString proto_abbrev = proto_registrar_get_abbrev(field_id);
3766 QUrl dfref_url = QString("https://www.wireshark.org/docs/dfref/%1/%2")
3767 .arg(proto_abbrev[0])
3769 QDesktopServices::openUrl(dfref_url);
3773 #pragma warning(pop)
3782 * indent-tabs-mode: nil
3785 * ex: set shiftwidth=4 tabstop=8 expandtab:
3786 * :indentSize=4:tabSize=8:noTabs=true: