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.
32 #include "main_window.h"
33 #include "ui_main_window.h"
41 #include "ui/capture.h"
44 #include "color_filters.h"
46 #include "wsutil/file_util.h"
47 #include "wsutil/filesystem.h"
49 #include "epan/addr_resolv.h"
50 #include "epan/column.h"
51 #include "epan/epan_dissect.h"
52 #include "epan/filter_expressions.h"
53 #include "epan/prefs.h"
54 #include "epan/value_string.h"
56 #include "ui/alert_box.h"
58 #include "ui/capture_ui_utils.h"
61 #include "ui/capture_globals.h"
62 #include "ui/help_url.h"
63 #include "ui/main_statusbar.h"
64 #include "ui/preference_utils.h"
65 #include "ui/recent.h"
66 #include "ui/recent_utils.h"
67 #include "ui/ssl_key_export.h"
68 #include "ui/ui_util.h"
70 #ifdef HAVE_SOFTWARE_UPDATE
71 #include "ui/software_update.h"
74 #include "capture_file_dialog.h"
75 #include "capture_file_properties_dialog.h"
76 #include "conversation_dialog.h"
77 #include "decode_as_dialog.h"
78 #include "endpoint_dialog.h"
79 #include "export_object_dialog.h"
80 #include "export_pdu_dialog.h"
81 #include "io_graph_dialog.h"
82 #include "lbm_stream_dialog.h"
83 #include "lbm_uimflow_dialog.h"
84 #include "lbm_lbtrm_transport_dialog.h"
85 #include "lbm_lbtru_transport_dialog.h"
86 #include "packet_comment_dialog.h"
87 #include "preferences_dialog.h"
88 #include "print_dialog.h"
89 #include "profile_dialog.h"
90 #include "qt_ui_utils.h"
91 #include "sctp_all_assocs_dialog.h"
92 #include "sctp_assoc_analyse_dialog.h"
93 #include "sctp_graph_dialog.h"
94 #include "sequence_dialog.h"
95 #include "stats_tree_dialog.h"
96 #include "tcp_stream_dialog.h"
97 #include "time_shift_dialog.h"
98 #include "voip_calls_dialog.h"
99 #include "wireshark_application.h"
101 #include <QClipboard>
102 #include <QMessageBox>
103 #include <QMetaObject>
112 const char *dfe_property_ = "display filter expression"; //TODO : Fix Translate
114 void MainWindow::openCaptureFile(QString& cf_path, QString& read_filter, unsigned int type)
116 QString file_name = "";
117 dfilter_t *rfcode = NULL;
121 // was a file name given as function parameter?
122 name_param = !cf_path.isEmpty();
124 testCaptureFileClose(false);
128 if (cf_path.isEmpty()) {
129 CaptureFileDialog open_dlg(this, capture_file_.capFile(), read_filter);
131 switch (prefs.gui_fileopen_style) {
133 case FO_STYLE_LAST_OPENED:
134 /* The user has specified that we should start out in the last directory
135 we looked in. If we've already opened a file, use its containing
136 directory, if we could determine it, as the directory, otherwise
137 use the "last opened" directory saved in the preferences file if
139 /* This is now the default behaviour in file_selection_new() */
142 case FO_STYLE_SPECIFIED:
143 /* The user has specified that we should always start out in a
144 specified directory; if they've specified that directory,
145 start out by showing the files in that dir. */
146 if (prefs.gui_fileopen_dir[0] != '\0')
147 open_dlg.setDirectory(prefs.gui_fileopen_dir);
151 if (open_dlg.open(file_name, type)) {
158 if (dfilter_compile(read_filter.toUtf8().constData(), &rfcode)) {
159 cf_set_rfcode(CaptureFile::globalCapFile(), rfcode);
161 /* Not valid. Tell the user, and go back and run the file
162 selection box again once they dismiss the alert. */
163 //bad_dfilter_alert_box(top_level, read_filter->str);
164 QMessageBox::warning(this, tr("Invalid Display Filter"),
165 QString("The filter expression ") +
167 QString(" isn't a valid display filter. (") +
168 dfilter_error_msg + QString(")."),
172 // go back to the selection dialogue only if the file
173 // was selected from this dialogue
179 /* Try to open the capture file. This closes the current file if it succeeds. */
180 CaptureFile::globalCapFile()->window = this;
181 if (cf_open(CaptureFile::globalCapFile(), cf_path.toUtf8().constData(), type, FALSE, &err) != CF_OK) {
182 /* We couldn't open it; don't dismiss the open dialog box,
183 just leave it around so that the user can, after they
184 dismiss the alert box popped up for the open error,
186 CaptureFile::globalCapFile()->window = NULL;
188 dfilter_free(rfcode);
193 switch (cf_read(CaptureFile::globalCapFile(), FALSE)) {
197 /* Just because we got an error, that doesn't mean we were unable
198 to read any of the file; we handle what we could get from the
202 case CF_READ_ABORTED:
203 /* The user bailed out of re-reading the capture file; the
204 capture file has been closed - just free the capture file name
205 string and return (without changing the last containing
207 capture_file_.setCapFile(NULL);
212 // get_dirname overwrites its path. Hopefully this isn't a problem.
213 wsApp->setLastOpenDir(get_dirname(cf_path.toUtf8().data()));
215 main_ui_->statusBar->showExpert();
218 void MainWindow::filterPackets(QString& new_filter, bool force)
220 cf_status_t cf_status;
222 cf_status = cf_filter_packets(CaptureFile::globalCapFile(), new_filter.toUtf8().data(), force);
224 if (cf_status == CF_OK) {
225 emit displayFilterSuccess(true);
226 if (new_filter.length() > 0) {
227 int index = df_combo_box_->findText(new_filter);
229 df_combo_box_->insertItem(0, new_filter);
230 df_combo_box_->setCurrentIndex(0);
233 df_combo_box_->setCurrentIndex(index);
237 emit displayFilterSuccess(false);
241 void MainWindow::layoutPanes()
243 QSplitter *parents[3];
245 // Reparent all widgets and add them back in the proper order below.
246 // This hides each widget as well.
247 packet_list_->setParent(main_ui_->mainStack);
248 proto_tree_->setParent(main_ui_->mainStack);
249 byte_view_tab_->setParent(main_ui_->mainStack);
250 empty_pane_.setParent(main_ui_->mainStack);
251 extra_split_.setParent(main_ui_->mainStack);
253 switch(prefs.gui_layout_type) {
256 extra_split_.setOrientation(Qt::Horizontal);
258 master_split_.setOrientation(Qt::Vertical);
263 extra_split_.setOrientation(Qt::Vertical);
265 master_split_.setOrientation(Qt::Horizontal);
269 g_assert_not_reached();
272 switch(prefs.gui_layout_type) {
275 parents[0] = &master_split_;
276 parents[1] = &master_split_;
277 parents[2] = &master_split_;
281 parents[0] = &master_split_;
282 parents[1] = &extra_split_;
283 parents[2] = &extra_split_;
287 parents[0] = &extra_split_;
288 parents[1] = &extra_split_;
289 parents[2] = &master_split_;
292 g_assert_not_reached();
295 if (parents[0] == &extra_split_) {
296 master_split_.addWidget(&extra_split_);
299 parents[0]->addWidget(getLayoutWidget(prefs.gui_layout_content_1));
301 if (parents[2] == &extra_split_) {
302 master_split_.addWidget(&extra_split_);
305 parents[1]->addWidget(getLayoutWidget(prefs.gui_layout_content_2));
306 parents[2]->addWidget(getLayoutWidget(prefs.gui_layout_content_3));
308 QList<QWidget *>split_widgets;
309 for (int i = 0; i < master_split_.count(); i++) {
310 split_widgets << master_split_.widget(i);
312 for (int i = 0; i < extra_split_.count(); i++) {
313 split_widgets << master_split_.widget(i);
315 foreach (QWidget *widget, split_widgets) {
317 if (widget == packet_list_ && !recent.packet_list_show) {
319 } else if (widget == proto_tree_ && !recent.tree_view_show) {
321 } else if (widget == byte_view_tab_ && !recent.byte_view_show) {
324 widget->setVisible(show);
328 void MainWindow::layoutToolbars()
330 Qt::ToolButtonStyle tbstyle = Qt::ToolButtonIconOnly;
331 switch (prefs.gui_toolbar_main_style) {
333 tbstyle = Qt::ToolButtonTextOnly;
336 tbstyle = Qt::ToolButtonTextUnderIcon;
339 main_ui_->mainToolBar->setToolButtonStyle(tbstyle);
342 void MainWindow::updateNameResolutionActions()
344 main_ui_->actionViewNameResolutionPhysical->setChecked(gbl_resolv_flags.mac_name);
345 main_ui_->actionViewNameResolutionNetwork->setChecked(gbl_resolv_flags.network_name);
346 main_ui_->actionViewNameResolutionTransport->setChecked(gbl_resolv_flags.transport_name);
349 void MainWindow::filterAction(QString &action_filter, FilterAction::Action action, FilterAction::ActionType type)
351 QString cur_filter, new_filter;
353 if (!df_combo_box_) return;
354 cur_filter = df_combo_box_->lineEdit()->text();
357 case FilterAction::ActionTypePlain:
358 new_filter = action_filter;
360 case FilterAction::ActionTypeAnd:
361 if (cur_filter.length()) {
362 new_filter = "(" + cur_filter + ") && (" + action_filter + ")";
364 new_filter = action_filter;
367 case FilterAction::ActionTypeOr:
368 if (cur_filter.length()) {
369 new_filter = "(" + cur_filter + ") || (" + action_filter + ")";
371 new_filter = action_filter;
374 case FilterAction::ActionTypeNot:
375 new_filter = "!(" + action_filter + ")";
377 case FilterAction::ActionTypeAndNot:
378 if (cur_filter.length()) {
379 new_filter = "(" + cur_filter + ") && !(" + action_filter + ")";
381 new_filter = "!(" + action_filter + ")";
384 case FilterAction::ActionTypeOrNot:
385 if (cur_filter.length()) {
386 new_filter = "(" + cur_filter + ") || !(" + action_filter + ")";
388 new_filter = "!(" + action_filter + ")";
392 g_assert_not_reached();
397 case FilterAction::ActionApply:
398 df_combo_box_->lineEdit()->setText(new_filter);
399 df_combo_box_->applyDisplayFilter();
401 case FilterAction::ActionPrepare:
402 df_combo_box_->lineEdit()->setText(new_filter);
403 df_combo_box_->lineEdit()->setFocus();
405 case FilterAction::ActionCopy:
406 wsApp->clipboard()->setText(new_filter);
409 qDebug() << "FIX FilterAction::Action" << action << "not implemented";
416 void MainWindow::captureCapturePrepared(capture_session *) {
418 setTitlebarForCaptureInProgress();
420 setWindowIcon(wsApp->captureIcon());
422 /* Disable menu items that make no sense if you're currently running
424 setForCaptureInProgress(true);
425 // set_capture_if_dialog_for_capture_in_progress(TRUE);
427 // /* Don't set up main window for a capture file. */
428 // main_set_for_capture_file(FALSE);
429 main_ui_->mainStack->setCurrentWidget(&master_split_);
430 #endif // HAVE_LIBPCAP
433 void MainWindow::captureCaptureUpdateStarted(capture_session *cap_session) {
434 Q_UNUSED(cap_session);
437 /* We've done this in "prepared" above, but it will be cleared while
438 switching to the next multiple file. */
439 setTitlebarForCaptureInProgress();
441 setForCaptureInProgress(true);
443 setForCapturedPackets(true);
444 #endif // HAVE_LIBPCAP
446 void MainWindow::captureCaptureUpdateFinished(capture_session *cap_session) {
447 Q_UNUSED(cap_session);
450 /* The capture isn't stopping any more - it's stopped. */
451 capture_stopping_ = false;
453 /* Update the main window as appropriate */
454 updateForUnsavedChanges();
456 /* Enable menu items that make sense if you're not currently running
458 setForCaptureInProgress(false);
460 setWindowIcon(wsApp->normalIcon());
462 if (global_capture_opts.quit_after_cap) {
463 // Command line asked us to quit after capturing.
464 // Don't pop up a dialog to ask for unsaved files etc.
467 #endif // HAVE_LIBPCAP
469 void MainWindow::captureCaptureFixedStarted(capture_session *cap_session) {
470 Q_UNUSED(cap_session);
472 #endif // HAVE_LIBPCAP
474 void MainWindow::captureCaptureFixedFinished(capture_session *cap_session) {
475 Q_UNUSED(cap_session);
478 /* The capture isn't stopping any more - it's stopped. */
479 capture_stopping_ = false;
481 /* Enable menu items that make sense if you're not currently running
483 setForCaptureInProgress(false);
485 setWindowIcon(wsApp->normalIcon());
487 if (global_capture_opts.quit_after_cap) {
488 // Command line asked us to quit after capturing.
489 // Don't pop up a dialog to ask for unsaved files etc.
492 #endif // HAVE_LIBPCAP
494 void MainWindow::captureCaptureStopping(capture_session *cap_session) {
495 Q_UNUSED(cap_session);
498 capture_stopping_ = true;
499 setMenusForCaptureStopping();
500 #endif // HAVE_LIBPCAP
502 void MainWindow::captureCaptureFailed(capture_session *cap_session) {
503 Q_UNUSED(cap_session);
505 /* Capture isn't stopping any more. */
506 capture_stopping_ = false;
508 setForCaptureInProgress(false);
509 main_ui_->mainStack->setCurrentWidget(main_welcome_);
511 setWindowIcon(wsApp->normalIcon());
513 if (global_capture_opts.quit_after_cap) {
514 // Command line asked us to quit after capturing.
515 // Don't pop up a dialog to ask for unsaved files etc.
518 #endif // HAVE_LIBPCAP
522 // Callbacks from cfile.c and file.c via CaptureFile::captureFileCallback
524 void MainWindow::captureFileOpened() {
525 if (capture_file_.window() != this) return;
527 file_set_dialog_.fileOpened(capture_file_.capFile());
528 setMenusForFileSet(true);
529 emit setCaptureFile(capture_file_.capFile());
532 void MainWindow::captureFileReadStarted() {
533 // tap_param_dlg_update();
535 /* Set up main window for a capture file. */
536 // main_set_for_capture_file(TRUE);
538 main_ui_->statusBar->popFileStatus();
539 QString msg = QString(tr("Loading: %1")).arg(get_basename(capture_file_.capFile()->filename));
540 main_ui_->statusBar->pushFileStatus(msg);
541 main_ui_->mainStack->setCurrentWidget(&master_split_);
542 WiresharkApplication::processEvents();
545 void MainWindow::captureFileReadFinished() {
548 if (!capture_file_.capFile()->is_tempfile && capture_file_.capFile()->filename) {
549 /* Add this filename to the list of recent files in the "Recent Files" submenu */
550 add_menu_recent_capture_file(capture_file_.capFile()->filename);
552 /* Remember folder for next Open dialog and save it in recent */
553 dir_path = get_dirname(g_strdup(capture_file_.capFile()->filename));
554 wsApp->setLastOpenDir(dir_path);
558 /* Update the appropriate parts of the main window. */
559 updateForUnsavedChanges();
561 /* Enable menu items that make sense if you have some captured packets. */
562 setForCapturedPackets(true);
564 main_ui_->statusBar->popFileStatus();
565 QString msg = QString().sprintf("%s", get_basename(capture_file_.capFile()->filename));
566 main_ui_->statusBar->pushFileStatus(msg);
567 emit setDissectedCaptureFile(capture_file_.capFile());
570 void MainWindow::captureFileClosing() {
571 setMenusForCaptureFile(true);
572 setForCapturedPackets(false);
573 setMenusForSelectedPacket();
574 setForCaptureInProgress(false);
576 // Reset expert info indicator
577 main_ui_->statusBar->hideExpert();
578 main_ui_->searchFrame->animatedHide();
579 // gtk_widget_show(expert_info_none);
580 emit setCaptureFile(NULL);
581 emit setDissectedCaptureFile(NULL);
584 void MainWindow::captureFileClosed() {
585 packets_bar_update();
587 file_set_dialog_.fileClosed();
588 setMenusForFileSet(false);
590 // Reset expert info indicator
591 main_ui_->statusBar->hideExpert();
593 main_ui_->statusBar->popFileStatus();
597 df_combo_box_->lineEdit()->setText("");
598 df_combo_box_->applyDisplayFilter();
601 setTitlebarForSelectedTreeRow();
602 setMenusForSelectedTreeRow();
605 void MainWindow::configurationProfileChanged(const gchar *profile_name) {
606 Q_UNUSED(profile_name);
607 /* Update window view and redraw the toolbar */
608 // main_titlebar_update();
609 filterExpressionsChanged();
610 // toolbar_redraw_all();
612 /* Reload list of interfaces on welcome page */
613 // welcome_if_panel_reload();
615 /* Recreate the packet list according to new preferences */
616 recreatePacketList();
618 /* Reload pane geometry, must be done after recreating the list */
619 // main_pane_load_window_geometry();
622 void MainWindow::filterExpressionsChanged()
624 // Recreate filter buttons
625 foreach (QAction *act, main_ui_->displayFilterToolBar->actions()) {
626 // Permanent actions shouldn't have data
627 if (act->property(dfe_property_).isValid()) {
628 main_ui_->displayFilterToolBar->removeAction(act);
633 for (struct filter_expression *fe = *pfilter_expression_head; fe != NULL; fe = fe->next) {
634 if (!fe->enabled) continue;
635 QAction *dfb_action = new QAction(fe->label, main_ui_->displayFilterToolBar);
636 dfb_action->setToolTip(fe->expression);
637 dfb_action->setData(fe->expression);
638 dfb_action->setProperty(dfe_property_, true);
639 main_ui_->displayFilterToolBar->addAction(dfb_action);
640 connect(dfb_action, SIGNAL(triggered()), this, SLOT(displayFilterButtonClicked()));
648 // ui/gtk/capture_dlg.c:start_capture_confirmed
650 void MainWindow::startCapture() {
652 interface_options interface_opts;
655 /* did the user ever select a capture interface before? */
656 if(global_capture_opts.num_selected == 0) {
657 QString msg = QString(tr("No interface selected"));
658 main_ui_->statusBar->pushTemporaryStatus(msg);
662 // Ideally we should have disabled the start capture
663 // toolbar buttons and menu items. This may not be the
664 // case, e.g. with QtMacExtras.
665 if(!capture_filter_valid_) {
666 QString msg = QString(tr("Invalid capture filter"));
667 main_ui_->statusBar->pushTemporaryStatus(msg);
671 /* XXX - we might need to init other pref data as well... */
672 // main_auto_scroll_live_changed(auto_scroll_live);
674 /* XXX - can this ever happen? */
675 if (cap_session_.state != CAPTURE_STOPPED)
678 /* close the currently loaded capture file */
679 cf_close((capture_file *) cap_session_.cf);
681 /* Copy the selected interfaces to the set of interfaces to use for
683 collect_ifaces(&global_capture_opts);
685 CaptureFile::globalCapFile()->window = this;
686 if (capture_start(&global_capture_opts, &cap_session_, main_window_update)) {
687 /* The capture succeeded, which means the capture filter syntax is
688 valid; add this capture filter to the recent capture filter list. */
689 for (i = 0; i < global_capture_opts.ifaces->len; i++) {
690 interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, i);
691 if (interface_opts.cfilter) {
692 // cfilter_combo_add_recent(interface_opts.cfilter);
696 CaptureFile::globalCapFile()->window = NULL;
698 #endif // HAVE_LIBPCAP
701 // Copied from ui/gtk/gui_utils.c
702 void MainWindow::pipeTimeout() {
706 gboolean result, result1;
711 /* try to read data from the pipe only 5 times, to avoid blocking */
712 while(iterations < 5) {
713 /*g_log(NULL, G_LOG_LEVEL_DEBUG, "pipe_timer_cb: new iteration");*/
715 /* Oddly enough although Named pipes don't work on win9x,
716 PeekNamedPipe does !!! */
717 handle = (HANDLE) _get_osfhandle (pipe_source_);
718 result = PeekNamedPipe(handle, NULL, 0, NULL, &avail, NULL);
720 /* Get the child process exit status */
721 result1 = GetExitCodeProcess((HANDLE)*(pipe_child_process_),
724 /* If the Peek returned an error, or there are bytes to be read
725 or the childwatcher thread has terminated then call the normal
727 if (!result || avail > 0 || childstatus != STILL_ACTIVE) {
729 /*g_log(NULL, G_LOG_LEVEL_DEBUG, "pipe_timer_cb: data avail");*/
731 /* And call the real handler */
732 if (!pipe_input_cb_(pipe_source_, pipe_user_data_)) {
733 g_log(NULL, G_LOG_LEVEL_DEBUG, "pipe_timer_cb: input pipe closed, iterations: %u", iterations);
734 /* pipe closed, return false so that the old timer is not run again */
740 /*g_log(NULL, G_LOG_LEVEL_DEBUG, "pipe_timer_cb: no data avail");*/
741 /* No data, stop now */
750 void MainWindow::pipeActivated(int source) {
754 g_assert(source == pipe_source_);
756 pipe_notifier_->setEnabled(false);
757 if (pipe_input_cb_(pipe_source_, pipe_user_data_)) {
758 pipe_notifier_->setEnabled(true);
760 delete pipe_notifier_;
765 void MainWindow::pipeNotifierDestroyed() {
769 pipe_notifier_ = NULL;
773 void MainWindow::stopCapture() {
774 //#ifdef HAVE_AIRPCAP
775 // if (airpcap_if_active)
776 // airpcap_set_toolbar_stop_capture(airpcap_if_active);
780 capture_stop(&cap_session_);
781 #endif // HAVE_LIBPCAP
784 // XXX - Copied from ui/gtk/menus.c
787 * Add the capture filename (with an absolute path) to the "Recent Files" menu.
789 // XXX - We should probably create a RecentFile class.
790 void MainWindow::updateRecentFiles() {
792 QMenu *recentMenu = main_ui_->menuOpenRecentCaptureFile;
793 QString action_cf_name;
801 /* Iterate through the actions in menuOpenRecentCaptureFile,
802 * removing special items, a maybe duplicate entry and every item above count_max */
803 int shortcut = Qt::Key_0;
804 foreach (recent_item_status *ri, wsApp->recentItems()) {
806 ra = new QAction(recentMenu);
807 ra->setData(ri->filename);
808 // XXX - Needs get_recent_item_status or equivalent
809 ra->setEnabled(ri->accessible);
810 recentMenu->insertAction(NULL, ra);
811 action_cf_name = ra->data().toString();
812 if (shortcut <= Qt::Key_9) {
813 ra->setShortcut(Qt::META | shortcut);
816 ra->setText(action_cf_name);
817 connect(ra, SIGNAL(triggered()), this, SLOT(recentActionTriggered()));
820 if (recentMenu->actions().count() > 0) {
821 // Separator + "Clear"
822 // XXX - Do we really need this?
823 ra = new QAction(recentMenu);
824 ra->setSeparator(true);
825 recentMenu->insertAction(NULL, ra);
827 ra = new QAction(recentMenu);
828 ra->setText(tr("Clear Menu"));
829 recentMenu->insertAction(NULL, ra);
830 connect(ra, SIGNAL(triggered()), wsApp, SLOT(clearRecentItems()));
832 if (main_ui_->actionDummyNoFilesFound) {
833 recentMenu->addAction(main_ui_->actionDummyNoFilesFound);
838 void MainWindow::recentActionTriggered() {
839 QAction *ra = qobject_cast<QAction*>(sender());
842 QString cfPath = ra->data().toString();
843 openCaptureFile(cfPath);
847 void MainWindow::setMenusForSelectedPacket()
849 // GList *list_entry = dissector_filter_list;
851 // gboolean properties = FALSE;
852 // const char *abbrev = NULL;
853 // char *prev_abbrev;
855 gboolean is_ip = FALSE, is_tcp = FALSE, is_udp = FALSE, is_sctp = FALSE;
857 gboolean is_tcp = FALSE, is_sctp = FALSE;
860 // /* Making the menu context-sensitive allows for easier selection of the
861 // desired item and has the added benefit, with large captures, of
862 // avoiding needless looping through huge lists for marked, ignored,
863 // or time-referenced packets. */
864 // gboolean is_ssl = epan_dissect_packet_contains_field(cf->edt, "ssl");
866 /* We have one or more items in the packet list */
867 gboolean have_frames = FALSE;
868 /* A frame is selected */
869 gboolean frame_selected = FALSE;
870 /* We have marked frames. (XXX - why check frame_selected?) */
871 gboolean have_marked = FALSE;
872 /* We have a marked frame other than the current frame (i.e.,
873 we have at least one marked frame, and either there's more
874 than one marked frame or the current frame isn't marked). */
875 gboolean another_is_marked = FALSE;
876 /* One or more frames are hidden by a display filter */
877 gboolean have_filtered = FALSE;
878 /* One or more frames have been ignored */
879 gboolean have_ignored = FALSE;
880 gboolean have_time_ref = FALSE;
881 /* We have a time reference frame other than the current frame (i.e.,
882 we have at least one time reference frame, and either there's more
883 than one time reference frame or the current frame isn't a
884 time reference frame). (XXX - why check frame_selected?) */
885 gboolean another_is_time_ref = FALSE;
887 if (capture_file_.capFile()) {
888 frame_selected = capture_file_.capFile()->current_frame != NULL;
889 have_frames = capture_file_.capFile()->count > 0;
890 have_marked = frame_selected && capture_file_.capFile()->marked_count > 0;
891 another_is_marked = have_marked &&
892 !(capture_file_.capFile()->marked_count == 1 && capture_file_.capFile()->current_frame->flags.marked);
893 have_filtered = capture_file_.capFile()->displayed_count > 0 && capture_file_.capFile()->displayed_count != capture_file_.capFile()->count;
894 have_ignored = capture_file_.capFile()->ignored_count > 0;
895 have_time_ref = capture_file_.capFile()->ref_time_count > 0;
896 another_is_time_ref = frame_selected && have_time_ref &&
897 !(capture_file_.capFile()->ref_time_count == 1 && capture_file_.capFile()->current_frame->flags.ref_time);
899 if (capture_file_.capFile()->edt)
901 proto_get_frame_protocols(capture_file_.capFile()->edt->pi.layers, NULL, &is_tcp, NULL, &is_sctp, NULL);
904 // if (cfile.edt && cfile.edt->tree) {
906 // header_field_info *hfinfo;
910 // ga = proto_all_finfos(cfile.edt->tree);
912 // for (ii = ga->len - 1; ii > 0 ; ii -= 1) {
914 // v = g_ptr_array_index (ga, ii);
915 // hfinfo = v->hfinfo;
917 // if (!g_str_has_prefix(hfinfo->abbrev, "text") &&
918 // !g_str_has_prefix(hfinfo->abbrev, "_ws.expert") &&
919 // !g_str_has_prefix(hfinfo->abbrev, "_ws.malformed")) {
921 // if (hfinfo->parent == -1) {
922 // abbrev = hfinfo->abbrev;
924 // abbrev = proto_registrar_get_abbrev(hfinfo->parent);
926 // properties = prefs_is_registered_protocol(abbrev);
932 main_ui_->actionEditMarkPacket->setEnabled(frame_selected);
933 main_ui_->actionEditMarkAllDisplayed->setEnabled(have_frames);
934 /* Unlike un-ignore, do not allow unmark of all frames when no frames are displayed */
935 main_ui_->actionEditUnmarkAllDisplayed->setEnabled(have_marked);
936 main_ui_->actionEditNextMark->setEnabled(another_is_marked);
937 main_ui_->actionEditPreviousMark->setEnabled(another_is_marked);
939 //#ifdef WANT_PACKET_EDITOR
940 // set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/EditPacket",
942 //#endif /* WANT_PACKET_EDITOR */
943 main_ui_->actionEditPacketComment->setEnabled(frame_selected && wtap_dump_can_write(capture_file_.capFile()->linktypes, WTAP_COMMENT_PER_PACKET));
945 main_ui_->actionEditIgnorePacket->setEnabled(frame_selected);
946 main_ui_->actionEditIgnoreAllDisplayed->setEnabled(have_filtered);
947 /* Allow un-ignore of all frames even with no frames currently displayed */
948 main_ui_->actionEditUnignoreAllDisplayed->setEnabled(have_ignored);
950 main_ui_->actionEditSetTimeReference->setEnabled(frame_selected);
951 main_ui_->actionEditUnsetAllTimeReferences->setEnabled(have_time_ref);
952 main_ui_->actionEditNextTimeReference->setEnabled(another_is_time_ref);
953 main_ui_->actionEditPreviousTimeReference->setEnabled(another_is_time_ref);
954 main_ui_->actionEditTimeShift->setEnabled(have_frames);
956 // set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ResizeAllColumns",
958 // set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/CollapseAll",
960 // set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/CollapseAll",
962 // set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ExpandAll",
964 // set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ExpandAll",
966 // set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ColorizeConversation",
968 // set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ResetColoring1-10",
969 // tmp_color_filters_used());
970 // set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ShowPacketinNewWindow",
972 // set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ShowPacketinNewWindow",
974 // set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ManuallyResolveAddress",
975 // frame_selected ? is_ip : FALSE);
976 // set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/SCTP",
977 // frame_selected ? is_sctp : FALSE);
978 // set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/FollowTCPStream",
979 // frame_selected ? is_tcp : FALSE);
980 // set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FollowTCPStream",
981 // frame_selected ? is_tcp : FALSE);
982 // set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/FollowUDPStream",
983 // frame_selected ? is_udp : FALSE);
984 // set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/FollowSSLStream",
985 // frame_selected ? is_ssl : FALSE);
986 // set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FollowSSLStream",
987 // frame_selected ? is_ssl : FALSE);
988 // set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter",
990 // set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter/Ethernet",
991 // frame_selected ? (cf->edt->pi.dl_src.type == AT_ETHER) : FALSE);
992 // set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter/IP",
993 // frame_selected ? is_ip : FALSE);
994 // set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter/TCP",
995 // frame_selected ? is_tcp : FALSE);
996 // set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter/UDP",
997 // frame_selected ? is_udp : FALSE);
998 // set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FollowUDPStream",
999 // frame_selected ? is_udp : FALSE);
1000 // set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter/PN-CBA",
1001 // frame_selected ? (cf->edt->pi.profinet_type != 0 && cf->edt->pi.profinet_type < 10) : FALSE);
1002 // set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation",
1004 // set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation/Ethernet",
1005 // frame_selected ? (cf->edt->pi.dl_src.type == AT_ETHER) : FALSE);
1006 // set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation/IP",
1007 // frame_selected ? is_ip : FALSE);
1008 // set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation/TCP",
1009 // frame_selected ? is_tcp : FALSE);
1010 // set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation/UDP",
1011 // frame_selected ? is_udp : FALSE);
1012 // set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation/PN-CBA",
1013 // frame_selected ? (cf->edt->pi.profinet_type != 0 && cf->edt->pi.profinet_type < 10) : FALSE);
1015 // if (properties) {
1016 // prev_abbrev = g_object_get_data(G_OBJECT(ui_manager_packet_list_menu), "menu_abbrev");
1017 // if (!prev_abbrev || (strcmp(prev_abbrev, abbrev) != 0)) {
1018 // /*No previous protocol or protocol changed - update Protocol Preferences menu*/
1019 // module_t *prefs_module_p = prefs_find_module(abbrev);
1020 // rebuild_protocol_prefs_menu(prefs_module_p, properties, ui_manager_packet_list_menu, "/PacketListMenuPopup/ProtocolPreferences");
1022 // g_object_set_data(G_OBJECT(ui_manager_packet_list_menu), "menu_abbrev", g_strdup(abbrev));
1023 // g_free (prev_abbrev);
1027 // set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ProtocolPreferences",
1029 // set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/Copy",
1031 // set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ApplyAsFilter",
1033 // set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/PrepareaFilter",
1035 // set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ResolveName",
1036 // frame_selected && (gbl_resolv_flags.mac_name || gbl_resolv_flags.network_name ||
1037 // gbl_resolv_flags.transport_name || gbl_resolv_flags.concurrent_dns));
1038 // set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/FollowTCPStream",
1039 // frame_selected ? is_tcp : FALSE);
1040 // set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/FollowUDPStream",
1041 // frame_selected ? is_udp : FALSE);
1042 // set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/FollowSSLStream",
1043 // frame_selected ? is_ssl : FALSE);
1044 // set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/ResolveName",
1045 // frame_selected && (gbl_resolv_flags.mac_name || gbl_resolv_flags.network_name ||
1046 // gbl_resolv_flags.transport_name || gbl_resolv_flags.concurrent_dns));
1047 // set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ToolsMenu/FirewallACLRules",
1049 main_ui_->menuTcpStreamGraphs->setEnabled(is_tcp);
1050 main_ui_->menuSCTP->setEnabled(is_sctp);
1051 main_ui_->actionSCTPAnalyseThisAssociation->setEnabled(is_sctp);
1052 main_ui_->actionSCTPShowAllAssociations->setEnabled(is_sctp);
1053 main_ui_->actionSCTPFilterThisAssociation->setEnabled(is_sctp);
1055 // while (list_entry != NULL) {
1056 // dissector_filter_t *filter_entry;
1059 // filter_entry = list_entry->data;
1060 // path = g_strdup_printf("/Menubar/AnalyzeMenu/ConversationFilterMenu/Filters/filter-%u", i);
1062 // set_menu_sensitivity(ui_manager_main_menubar, path,
1063 // menu_dissector_filter_spe_cb(/* frame_data *fd _U_*/ NULL, cf->edt, filter_entry));
1066 // list_entry = g_list_next(list_entry);
1070 void MainWindow::setMenusForSelectedTreeRow(field_info *fi) {
1071 //gboolean properties;
1074 // XXX Add commented items below
1076 if (capture_file_.capFile()) {
1077 capture_file_.capFile()->finfo_selected = fi;
1080 if (capture_file_.capFile() != NULL && fi != NULL) {
1082 header_field_info *hfinfo = fi->hfinfo;
1086 if (hfinfo->parent == -1) {
1087 abbrev = hfinfo->abbrev;
1088 id = (hfinfo->type == FT_PROTOCOL) ? proto_get_id((protocol_t *)hfinfo->strings) : -1;
1090 abbrev = proto_registrar_get_abbrev(hfinfo->parent);
1091 id = hfinfo->parent;
1093 properties = prefs_is_registered_protocol(abbrev);
1095 bool can_match_selected = proto_can_match_selected(capture_file_.capFile()->finfo_selected, capture_file_.capFile()->edt);
1096 // set_menu_sensitivity(ui_manager_tree_view_menu,
1097 // "/TreeViewPopup/GotoCorrespondingPacket", hfinfo->type == FT_FRAMENUM);
1098 // set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/Copy",
1101 // set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/CreateAColumn",
1102 // hfinfo->type != FT_NONE);
1103 // set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ColorizewithFilter",
1104 // proto_can_match_selected(cf->finfo_selected, cf->edt));
1105 // set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ProtocolPreferences",
1107 // set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/DisableProtocol",
1108 // (id == -1) ? FALSE : proto_can_toggle_protocol(id));
1109 // set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ExpandSubtrees",
1110 // cf->finfo_selected->tree_type != -1);
1111 // set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/WikiProtocolPage",
1112 // (id == -1) ? FALSE : TRUE);
1113 // set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FilterFieldReference",
1114 // (id == -1) ? FALSE : TRUE);
1115 // set_menu_sensitivity(ui_manager_main_menubar,
1116 main_ui_->actionFileExportPacketBytes->setEnabled(true);
1118 // set_menu_sensitivity(ui_manager_main_menubar,
1119 // "/Menubar/GoMenu/GotoCorrespondingPacket", hfinfo->type == FT_FRAMENUM);
1121 main_ui_->actionEditCopyDescription->setEnabled(can_match_selected);
1122 main_ui_->actionEditCopyFieldName->setEnabled(can_match_selected);
1123 main_ui_->actionEditCopyValue->setEnabled(can_match_selected);
1124 main_ui_->actionEditCopyAsFilter->setEnabled(can_match_selected);
1125 // set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/Copy/Description",
1126 // proto_can_match_selected(cf->finfo_selected, cf->edt));
1127 // set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/Copy/Fieldname",
1128 // proto_can_match_selected(cf->finfo_selected, cf->edt));
1129 // set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/Copy/Value",
1130 // proto_can_match_selected(cf->finfo_selected, cf->edt));
1131 // set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/Copy/AsFilter",
1132 // proto_can_match_selected(cf->finfo_selected, cf->edt));
1134 // set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/CreateAColumn",
1135 // hfinfo->type != FT_NONE);
1136 main_ui_->actionAnalyzeAAFSelected->setEnabled(can_match_selected);
1137 main_ui_->actionAnalyzeAAFNotSelected->setEnabled(can_match_selected);
1138 main_ui_->actionAnalyzeAAFAndSelected->setEnabled(can_match_selected);
1139 main_ui_->actionAnalyzeAAFOrSelected->setEnabled(can_match_selected);
1140 main_ui_->actionAnalyzeAAFAndNotSelected->setEnabled(can_match_selected);
1141 main_ui_->actionAnalyzeAAFOrNotSelected->setEnabled(can_match_selected);
1143 main_ui_->actionAnalyzePAFSelected->setEnabled(can_match_selected);
1144 main_ui_->actionAnalyzePAFNotSelected->setEnabled(can_match_selected);
1145 main_ui_->actionAnalyzePAFAndSelected->setEnabled(can_match_selected);
1146 main_ui_->actionAnalyzePAFOrSelected->setEnabled(can_match_selected);
1147 main_ui_->actionAnalyzePAFAndNotSelected->setEnabled(can_match_selected);
1148 main_ui_->actionAnalyzePAFOrNotSelected->setEnabled(can_match_selected);
1150 main_ui_->actionViewExpandSubtrees->setEnabled(capture_file_.capFile()->finfo_selected->tree_type != -1);
1151 // prev_abbrev = g_object_get_data(G_OBJECT(ui_manager_tree_view_menu), "menu_abbrev");
1152 // if (!prev_abbrev || (strcmp (prev_abbrev, abbrev) != 0)) {
1153 // /* No previous protocol or protocol changed - update Protocol Preferences menu */
1154 // module_t *prefs_module_p = prefs_find_module(abbrev);
1155 // rebuild_protocol_prefs_menu (prefs_module_p, properties);
1157 // g_object_set_data(G_OBJECT(ui_manager_tree_view_menu), "menu_abbrev", g_strdup(abbrev));
1158 // g_free (prev_abbrev);
1161 // set_menu_sensitivity(ui_manager_tree_view_menu,
1162 // "/TreeViewPopup/GotoCorrespondingPacket", FALSE);
1163 // set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/Copy", FALSE);
1164 // set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/CreateAColumn", FALSE);
1165 // set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ApplyAsFilter", FALSE);
1166 // set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/PrepareaFilter", FALSE);
1167 // set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ColorizewithFilter", FALSE);
1168 // set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ProtocolPreferences",
1170 // set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/DisableProtocol", FALSE);
1171 // set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ExpandSubtrees", FALSE);
1172 // set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/WikiProtocolPage",
1174 // set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FilterFieldReference",
1176 main_ui_->actionFileExportPacketBytes->setEnabled(false);
1177 // set_menu_sensitivity(ui_manager_main_menubar,
1178 // "/Menubar/GoMenu/GotoCorrespondingPacket", FALSE);
1179 main_ui_->actionEditCopyDescription->setEnabled(false);
1180 main_ui_->actionEditCopyFieldName->setEnabled(false);
1181 main_ui_->actionEditCopyValue->setEnabled(false);
1182 main_ui_->actionEditCopyAsFilter->setEnabled(false);
1183 // set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/CreateAColumn", FALSE);
1185 main_ui_->actionAnalyzeAAFSelected->setEnabled(false);
1186 main_ui_->actionAnalyzeAAFNotSelected->setEnabled(false);
1187 main_ui_->actionAnalyzeAAFAndSelected->setEnabled(false);
1188 main_ui_->actionAnalyzeAAFOrSelected->setEnabled(false);
1189 main_ui_->actionAnalyzeAAFAndNotSelected->setEnabled(false);
1190 main_ui_->actionAnalyzeAAFOrNotSelected->setEnabled(false);
1192 main_ui_->actionAnalyzePAFSelected->setEnabled(false);
1193 main_ui_->actionAnalyzePAFNotSelected->setEnabled(false);
1194 main_ui_->actionAnalyzePAFAndSelected->setEnabled(false);
1195 main_ui_->actionAnalyzePAFOrSelected->setEnabled(false);
1196 main_ui_->actionAnalyzePAFAndNotSelected->setEnabled(false);
1197 main_ui_->actionAnalyzePAFOrNotSelected->setEnabled(false);
1199 main_ui_->actionViewExpandSubtrees->setEnabled(false);
1203 void MainWindow::interfaceSelectionChanged()
1206 // XXX This doesn't disable the toolbar button when using
1208 if (global_capture_opts.num_selected > 0 && capture_filter_valid_) {
1209 main_ui_->actionCaptureStart->setEnabled(true);
1211 main_ui_->actionCaptureStart->setEnabled(false);
1213 #endif // HAVE_LIBPCAP
1216 void MainWindow::captureFilterSyntaxChanged(bool valid)
1218 capture_filter_valid_ = valid;
1219 interfaceSelectionChanged();
1222 void MainWindow::startInterfaceCapture(bool valid)
1224 capture_filter_valid_ = valid;
1228 void MainWindow::redissectPackets()
1230 if (capture_file_.capFile())
1231 cf_redissect_packets(capture_file_.capFile());
1232 main_ui_->statusBar->expertUpdate();
1235 void MainWindow::recreatePacketList()
1237 prefs.num_cols = g_list_length(prefs.col_list);
1239 col_cleanup(&CaptureFile::globalCapFile()->cinfo);
1240 build_column_format_array(&CaptureFile::globalCapFile()->cinfo, prefs.num_cols, FALSE);
1242 packet_list_->redrawVisiblePackets();
1243 packet_list_->hide();
1244 packet_list_->show();
1246 CaptureFile::globalCapFile()->columns_changed = FALSE; /* Reset value */
1249 void MainWindow::fieldsChanged()
1251 // Reload color filters
1252 color_filters_reload();
1254 // Syntax check filter
1255 // TODO: Check if syntax filter is still valid after fields have changed
1256 // and update background color.
1257 if (CaptureFile::globalCapFile()->dfilter) {
1258 // Check if filter is still valid
1259 dfilter_t *dfp = NULL;
1260 if (!dfilter_compile(CaptureFile::globalCapFile()->dfilter, &dfp)) {
1261 // TODO: Not valid, enable "Apply" button.
1262 g_free(CaptureFile::globalCapFile()->dfilter);
1263 CaptureFile::globalCapFile()->dfilter = NULL;
1268 if (have_custom_cols(&CaptureFile::globalCapFile()->cinfo)) {
1269 /* Recreate packet list according to new/changed/deleted fields */
1270 recreatePacketList();
1271 } else if (CaptureFile::globalCapFile()->state != FILE_CLOSED) {
1272 /* Redissect packets if we have any */
1276 proto_free_deregistered_fields();
1279 void MainWindow::setFeaturesEnabled(bool enabled)
1281 main_ui_->menuBar->setEnabled(enabled);
1282 main_ui_->mainToolBar->setEnabled(enabled);
1283 main_ui_->displayFilterToolBar->setEnabled(enabled);
1286 main_ui_->statusBar->clearMessage();
1290 main_ui_->statusBar->showMessage(tr("Please wait while Wireshark is initializing" UTF8_HORIZONTAL_ELLIPSIS));
1294 // On Qt4 + OS X with unifiedTitleAndToolBarOnMac set it's possible to make
1295 // the main window obnoxiously wide.
1297 // We might want to do something different here. We should probably merge
1298 // the dfilter and gui.filter_expressions code first.
1299 void MainWindow::addDisplayFilterButton(QString df_text)
1301 struct filter_expression *cur_fe = *pfilter_expression_head;
1302 struct filter_expression *fe = g_new0(struct filter_expression, 1);
1304 QFontMetrics fm = main_ui_->displayFilterToolBar->fontMetrics();
1305 QString label = fm.elidedText(df_text, Qt::ElideMiddle, fm.height() * 15);
1308 fe->label = qstring_strdup(label);
1309 fe->expression = qstring_strdup(df_text);
1312 *pfilter_expression_head = fe;
1314 while (cur_fe->next) {
1315 cur_fe = cur_fe->next;
1321 filterExpressionsChanged();
1324 void MainWindow::displayFilterButtonClicked()
1326 QAction *dfb_action = qobject_cast<QAction*>(sender());
1329 df_combo_box_->lineEdit()->setText(dfb_action->data().toString());
1330 df_combo_box_->applyDisplayFilter();
1331 df_combo_box_->lineEdit()->setFocus();
1335 void MainWindow::openStatCommandDialog(const QString &menu_path, const char *arg, void *userdata)
1337 QString slot = QString("statCommand%1").arg(menu_path);
1338 QMetaObject::invokeMethod(this, slot.toLatin1().constData(), Q_ARG(const char *, arg), Q_ARG(void *, userdata));
1343 void MainWindow::on_actionFileOpen_triggered()
1348 void MainWindow::on_actionFileMerge_triggered()
1353 void MainWindow::on_actionFileImportFromHexDump_triggered()
1355 importCaptureFile();
1358 void MainWindow::on_actionFileClose_triggered() {
1359 if (testCaptureFileClose())
1360 main_ui_->mainStack->setCurrentWidget(main_welcome_);
1363 void MainWindow::on_actionFileSave_triggered()
1365 saveCaptureFile(capture_file_.capFile(), FALSE);
1368 void MainWindow::on_actionFileSaveAs_triggered()
1370 saveAsCaptureFile(capture_file_.capFile(), FALSE, TRUE);
1373 void MainWindow::on_actionFileSetListFiles_triggered()
1375 file_set_dialog_.exec();
1378 void MainWindow::on_actionFileSetNextFile_triggered()
1380 fileset_entry *entry = fileset_get_next();
1383 QString new_cf_path = entry->fullname;
1384 openCaptureFile(new_cf_path);
1388 void MainWindow::on_actionFileSetPreviousFile_triggered()
1390 fileset_entry *entry = fileset_get_previous();
1393 QString new_cf_path = entry->fullname;
1394 openCaptureFile(new_cf_path);
1398 void MainWindow::on_actionFileExportPackets_triggered()
1400 exportSelectedPackets();
1403 void MainWindow::on_actionFileExportAsPlainText_triggered()
1405 exportDissections(export_type_text);
1408 void MainWindow::on_actionFileExportAsCSV_triggered()
1410 exportDissections(export_type_csv);
1413 void MainWindow::on_actionFileExportAsCArrays_triggered()
1415 exportDissections(export_type_carrays);
1418 void MainWindow::on_actionFileExportAsPSML_triggered()
1420 exportDissections(export_type_psml);
1423 void MainWindow::on_actionFileExportAsPDML_triggered()
1425 exportDissections(export_type_pdml);
1428 void MainWindow::on_actionFileExportPacketBytes_triggered()
1432 if (!capture_file_.capFile() || !capture_file_.capFile()->finfo_selected) return;
1434 file_name = QFileDialog::getSaveFileName(this,
1435 tr("Wireshark: Export Selected Packet Bytes"),
1436 wsApp->lastOpenDir().canonicalPath(),
1437 tr("Raw data (*.bin *.dat *.raw);;Any File (*.*)")
1440 if (file_name.length() > 0) {
1441 const guint8 *data_p;
1444 data_p = tvb_get_ptr(capture_file_.capFile()->finfo_selected->ds_tvb, 0, -1) +
1445 capture_file_.capFile()->finfo_selected->start;
1446 fd = ws_open(file_name.toUtf8().constData(), O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0666);
1448 open_failure_alert_box(file_name.toUtf8().constData(), errno, TRUE);
1451 if (write(fd, data_p, capture_file_.capFile()->finfo_selected->length) < 0) {
1452 write_failure_alert_box(file_name.toUtf8().constData(), errno);
1456 if (::close(fd) < 0) {
1457 write_failure_alert_box(file_name.toUtf8().constData(), errno);
1461 /* Save the directory name for future file dialogs. */
1462 wsApp->setLastOpenDir(&file_name);
1465 void MainWindow::on_actionFileExportPDU_triggered()
1467 ExportPDUDialog *exportpdu_dialog = new ExportPDUDialog(this);
1469 if (exportpdu_dialog->isMinimized() == true)
1471 exportpdu_dialog->showNormal();
1475 exportpdu_dialog->show();
1478 exportpdu_dialog->raise();
1479 exportpdu_dialog->activateWindow();
1482 void MainWindow::on_actionFileExportSSLSessionKeys_triggered()
1488 keylist_len = ssl_session_key_count();
1489 /* don't show up the dialog, if no data has to be saved */
1490 if (keylist_len < 1) {
1491 /* shouldn't happen as the menu item should have been greyed out */
1492 QMessageBox::warning(
1495 tr("There are no SSL Session Keys to save."),
1501 save_title.append(QString("Wireshark: Export SSL Session Keys (%1 key%2").
1502 arg(keylist_len).arg(plurality(keylist_len, "", "s")));
1503 file_name = QFileDialog::getSaveFileName(this,
1505 wsApp->lastOpenDir().canonicalPath(),
1506 tr("SSL Session Keys (*.keys *.txt);;Any File (*.*)")
1508 if (file_name.length() > 0) {
1512 keylist = ssl_export_sessions();
1513 fd = ws_open(file_name.toUtf8().constData(), O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0666);
1515 open_failure_alert_box(file_name.toUtf8().constData(), errno, TRUE);
1520 * Thanks, Microsoft, for not using size_t for the third argument to
1521 * _write(). Presumably this string will be <= 4GiB long....
1523 if (ws_write(fd, keylist, (unsigned int)strlen(keylist)) < 0) {
1524 write_failure_alert_box(file_name.toUtf8().constData(), errno);
1529 if (::close(fd) < 0) {
1530 write_failure_alert_box(file_name.toUtf8().constData(), errno);
1535 /* Save the directory name for future file dialogs. */
1536 wsApp->setLastOpenDir(&file_name);
1541 void MainWindow::on_actionFileExportObjectsDICOM_triggered()
1543 new ExportObjectDialog(this, capture_file_.capFile(), ExportObjectDialog::Dicom);
1546 void MainWindow::on_actionFileExportObjectsHTTP_triggered()
1548 new ExportObjectDialog(this, capture_file_.capFile(), ExportObjectDialog::Http);
1551 void MainWindow::on_actionFileExportObjectsSMB_triggered()
1553 new ExportObjectDialog(this, capture_file_.capFile(), ExportObjectDialog::Smb);
1556 void MainWindow::on_actionFileExportObjectsTFTP_triggered()
1558 new ExportObjectDialog(this, capture_file_.capFile(), ExportObjectDialog::Tftp);
1561 void MainWindow::on_actionFilePrint_triggered()
1563 PrintDialog pdlg(this, capture_file_.capFile());
1570 // XXX This should probably be somewhere else.
1571 void MainWindow::actionEditCopyTriggered(MainWindow::CopySelected selection_type)
1573 char label_str[ITEM_LABEL_LENGTH];
1576 if (!capture_file_.capFile()) return;
1578 switch(selection_type) {
1579 case CopySelectedDescription:
1580 if (capture_file_.capFile()->finfo_selected->rep &&
1581 strlen (capture_file_.capFile()->finfo_selected->rep->representation) > 0) {
1582 clip.append(capture_file_.capFile()->finfo_selected->rep->representation);
1585 case CopySelectedFieldName:
1586 if (capture_file_.capFile()->finfo_selected->hfinfo->abbrev != 0) {
1587 clip.append(capture_file_.capFile()->finfo_selected->hfinfo->abbrev);
1590 case CopySelectedValue:
1591 if (capture_file_.capFile()->edt != 0) {
1592 gchar* field_str = get_node_field_value(capture_file_.capFile()->finfo_selected, capture_file_.capFile()->edt);
1593 clip.append(field_str);
1599 if (clip.length() == 0) {
1600 /* If no representation then... Try to read the value */
1601 proto_item_fill_label(capture_file_.capFile()->finfo_selected, label_str);
1602 clip.append(label_str);
1605 if (clip.length()) {
1606 wsApp->clipboard()->setText(clip);
1608 QString err = tr("Couldn't copy text. Try another item.");
1609 main_ui_->statusBar->pushTemporaryStatus(err);
1613 void MainWindow::on_actionEditCopyDescription_triggered()
1615 actionEditCopyTriggered(CopySelectedDescription);
1618 void MainWindow::on_actionEditCopyFieldName_triggered()
1620 actionEditCopyTriggered(CopySelectedFieldName);
1623 void MainWindow::on_actionEditCopyValue_triggered()
1625 actionEditCopyTriggered(CopySelectedValue);
1628 void MainWindow::on_actionEditCopyAsFilter_triggered()
1630 matchFieldFilter(FilterAction::ActionCopy, FilterAction::ActionTypePlain);
1633 void MainWindow::on_actionEditFindPacket_triggered()
1635 if (packet_list_->model()->rowCount() < 1) {
1638 previous_focus_ = wsApp->focusWidget();
1639 connect(previous_focus_, SIGNAL(destroyed()), this, SLOT(resetPreviousFocus()));
1640 main_ui_->goToFrame->animatedHide();
1641 if (main_ui_->searchFrame->isVisible()) {
1642 main_ui_->searchFrame->animatedHide();
1644 main_ui_->searchFrame->animatedShow();
1648 void MainWindow::on_actionEditFindNext_triggered()
1650 main_ui_->searchFrame->findNext();
1653 void MainWindow::on_actionEditFindPrevious_triggered()
1655 main_ui_->searchFrame->findPrevious();
1658 void MainWindow::on_actionEditMarkPacket_triggered()
1660 packet_list_->markFrame();
1663 void MainWindow::on_actionEditMarkAllDisplayed_triggered()
1665 packet_list_->markAllDisplayedFrames(true);
1668 void MainWindow::on_actionEditUnmarkAllDisplayed_triggered()
1670 packet_list_->markAllDisplayedFrames(false);
1673 void MainWindow::on_actionEditNextMark_triggered()
1675 if (capture_file_.capFile())
1676 cf_find_packet_marked(capture_file_.capFile(), SD_FORWARD);
1679 void MainWindow::on_actionEditPreviousMark_triggered()
1681 if (capture_file_.capFile())
1682 cf_find_packet_marked(capture_file_.capFile(), SD_BACKWARD);
1685 void MainWindow::on_actionEditIgnorePacket_triggered()
1687 packet_list_->ignoreFrame();
1690 void MainWindow::on_actionEditIgnoreAllDisplayed_triggered()
1692 packet_list_->ignoreAllDisplayedFrames(true);
1695 void MainWindow::on_actionEditUnignoreAllDisplayed_triggered()
1697 packet_list_->ignoreAllDisplayedFrames(false);
1700 void MainWindow::on_actionEditSetTimeReference_triggered()
1702 packet_list_->setTimeReference();
1705 void MainWindow::on_actionEditUnsetAllTimeReferences_triggered()
1707 packet_list_->unsetAllTimeReferences();
1710 void MainWindow::on_actionEditNextTimeReference_triggered()
1712 if (!capture_file_.capFile()) return;
1713 cf_find_packet_time_reference(capture_file_.capFile(), SD_FORWARD);
1716 void MainWindow::on_actionEditPreviousTimeReference_triggered()
1718 if (!capture_file_.capFile()) return;
1719 cf_find_packet_time_reference(capture_file_.capFile(), SD_BACKWARD);
1722 void MainWindow::on_actionEditTimeShift_triggered()
1724 TimeShiftDialog ts_dialog(this, capture_file_.capFile());
1725 connect(this, SIGNAL(setCaptureFile(capture_file*)),
1726 &ts_dialog, SLOT(setCaptureFile(capture_file*)));
1730 void MainWindow::on_actionEditPacketComment_triggered()
1732 PacketCommentDialog pc_dialog(this, packet_list_->packetComment());
1733 if (pc_dialog.exec() == QDialog::Accepted) {
1734 packet_list_->setPacketComment(pc_dialog.text());
1735 updateForUnsavedChanges();
1739 void MainWindow::on_actionEditConfigurationProfiles_triggered()
1741 ProfileDialog cp_dialog;
1746 void MainWindow::on_actionEditPreferences_triggered()
1748 PreferencesDialog pref_dialog;
1752 // Emitting PacketDissectionChanged directly from PreferencesDialog
1753 // can cause problems. Queue them up and emit them here.
1754 foreach (WiresharkApplication::AppSignal app_signal, pref_dialog.appSignals()) {
1755 wsApp->emitAppSignal(app_signal);
1761 void MainWindow::showHideMainWidgets(QAction *action)
1766 bool show = action->isChecked();
1767 QWidget *widget = action->data().value<QWidget*>();
1769 if (widget == main_ui_->mainToolBar) {
1770 recent.main_toolbar_show = show;
1771 } else if (widget == main_ui_->displayFilterToolBar) {
1772 recent.filter_toolbar_show = show;
1773 // } else if (widget == main_ui_->wirelessToolbar) {
1774 // recent.wireless_toolbar_show = show;
1775 } else if (widget == main_ui_->statusBar) {
1776 recent.statusbar_show = show;
1777 } else if (widget == packet_list_) {
1778 recent.packet_list_show = show;
1779 } else if (widget == proto_tree_) {
1780 recent.tree_view_show = show;
1781 } else if (widget == byte_view_tab_) {
1782 recent.byte_view_show = show;
1786 widget->setVisible(show);
1790 Q_DECLARE_METATYPE(ts_type)
1792 void MainWindow::setTimestampFormat(QAction *action)
1797 ts_type tsf = action->data().value<ts_type>();
1798 if (recent.gui_time_format != tsf) {
1799 timestamp_set_type(tsf);
1800 recent.gui_time_format = tsf;
1801 if (capture_file_.capFile()) {
1802 /* This call adjusts column width */
1803 cf_timestamp_auto_precision(capture_file_.capFile());
1806 packet_list_->redrawVisiblePackets();
1811 Q_DECLARE_METATYPE(ts_precision)
1813 void MainWindow::setTimestampPrecision(QAction *action)
1818 ts_precision tsp = action->data().value<ts_precision>();
1819 if (recent.gui_time_precision != tsp) {
1820 /* the actual precision will be set in packet_list_queue_draw() below */
1821 timestamp_set_precision(tsp);
1822 recent.gui_time_precision = tsp;
1823 if (capture_file_.capFile()) {
1824 /* This call adjusts column width */
1825 cf_timestamp_auto_precision(capture_file_.capFile());
1828 packet_list_->redrawVisiblePackets();
1833 void MainWindow::on_actionViewTimeDisplaySecondsWithHoursAndMinutes_triggered(bool checked)
1836 recent.gui_seconds_format = TS_SECONDS_HOUR_MIN_SEC;
1838 recent.gui_seconds_format = TS_SECONDS_DEFAULT;
1840 timestamp_set_seconds_type(recent.gui_seconds_format);
1842 if (capture_file_.capFile()) {
1843 /* This call adjusts column width */
1844 cf_timestamp_auto_precision(capture_file_.capFile());
1847 packet_list_->redrawVisiblePackets();
1851 void MainWindow::setNameResolution()
1853 gbl_resolv_flags.mac_name = main_ui_->actionViewNameResolutionPhysical->isChecked() ? TRUE : FALSE;
1854 gbl_resolv_flags.network_name = main_ui_->actionViewNameResolutionNetwork->isChecked() ? TRUE : FALSE;
1855 gbl_resolv_flags.transport_name = main_ui_->actionViewNameResolutionTransport->isChecked() ? TRUE : FALSE;
1858 packet_list_->redrawVisiblePackets();
1862 void MainWindow::on_actionViewNameResolutionPhysical_triggered()
1864 setNameResolution();
1867 void MainWindow::on_actionViewNameResolutionNetwork_triggered()
1869 setNameResolution();
1872 void MainWindow::on_actionViewNameResolutionTransport_triggered()
1874 setNameResolution();
1877 void MainWindow::zoomText()
1879 // Scale by 10%, rounding to nearest half point, minimum 1 point.
1880 // XXX Small sizes repeat. It might just be easier to create a map of multipliers.
1881 mono_font_ = QFont(wsApp->monospaceFont());
1882 qreal zoom_size = wsApp->monospaceFont().pointSize() * 2 * qPow(1.1, recent.gui_zoom_level);
1883 zoom_size = qRound(zoom_size) / 2.0;
1884 zoom_size = qMax(zoom_size, 1.0);
1885 mono_font_.setPointSizeF(zoom_size);
1886 emit monospaceFontChanged(mono_font_);
1889 void MainWindow::on_actionViewZoomIn_triggered()
1891 recent.gui_zoom_level++;
1895 void MainWindow::on_actionViewZoomOut_triggered()
1897 recent.gui_zoom_level--;
1901 void MainWindow::on_actionViewNormalSize_triggered()
1903 recent.gui_zoom_level = 0;
1907 void MainWindow::on_actionViewColorizePacketList_triggered(bool checked) {
1908 recent.packet_list_colorize = checked;
1909 color_filters_enable(checked);
1910 packet_list_->packetListModel()->resetColorized();
1911 packet_list_->update();
1914 void MainWindow::on_actionViewResizeColumns_triggered()
1916 for (int col = 0; col < packet_list_->packetListModel()->columnCount(); col++) {
1917 packet_list_->resizeColumnToContents(col);
1921 void MainWindow::on_actionViewReload_triggered()
1923 cf_reload(CaptureFile::globalCapFile());
1926 // Expand / collapse slots in proto_tree
1932 // XXX This should probably be somewhere else.
1933 void MainWindow::matchFieldFilter(FilterAction::Action action, FilterAction::ActionType filter_type)
1935 QString field_filter;
1937 if (packet_list_->contextMenuActive()) {
1938 field_filter = packet_list_->getFilterFromRowAndColumn();
1939 } else if (capture_file_.capFile() && capture_file_.capFile()->finfo_selected) {
1940 field_filter = proto_construct_match_selected_string(capture_file_.capFile()->finfo_selected,
1941 capture_file_.capFile()->edt);
1946 if (field_filter.isEmpty()) {
1947 QString err = tr("No filter available. Try another ");
1948 err.append(packet_list_->contextMenuActive() ? "column" : "item");
1950 main_ui_->statusBar->pushTemporaryStatus(err);
1954 filterAction(field_filter, action, filter_type);
1957 // XXX We could probably create the analyze and prepare actions
1958 // dynamically using FilterActions and consolidate the methods
1959 // below into one callback.
1960 void MainWindow::on_actionAnalyzeAAFSelected_triggered()
1962 matchFieldFilter(FilterAction::ActionApply, FilterAction::ActionTypePlain);
1965 void MainWindow::on_actionAnalyzeAAFNotSelected_triggered()
1967 matchFieldFilter(FilterAction::ActionApply, FilterAction::ActionTypeNot);
1970 void MainWindow::on_actionAnalyzeAAFAndSelected_triggered()
1972 matchFieldFilter(FilterAction::ActionApply, FilterAction::ActionTypeAnd);
1975 void MainWindow::on_actionAnalyzeAAFOrSelected_triggered()
1977 matchFieldFilter(FilterAction::ActionApply, FilterAction::ActionTypeOr);
1980 void MainWindow::on_actionAnalyzeAAFAndNotSelected_triggered()
1982 matchFieldFilter(FilterAction::ActionApply, FilterAction::ActionTypeAndNot);
1985 void MainWindow::on_actionAnalyzeAAFOrNotSelected_triggered()
1987 matchFieldFilter(FilterAction::ActionApply, FilterAction::ActionTypeOrNot);
1990 void MainWindow::on_actionAnalyzePAFSelected_triggered()
1992 matchFieldFilter(FilterAction::ActionPrepare, FilterAction::ActionTypePlain);
1995 void MainWindow::on_actionAnalyzePAFNotSelected_triggered()
1997 matchFieldFilter(FilterAction::ActionPrepare, FilterAction::ActionTypeNot);
2000 void MainWindow::on_actionAnalyzePAFAndSelected_triggered()
2002 matchFieldFilter(FilterAction::ActionPrepare, FilterAction::ActionTypeAnd);
2005 void MainWindow::on_actionAnalyzePAFOrSelected_triggered()
2007 matchFieldFilter(FilterAction::ActionPrepare, FilterAction::ActionTypeOr);
2010 void MainWindow::on_actionAnalyzePAFAndNotSelected_triggered()
2012 matchFieldFilter(FilterAction::ActionPrepare, FilterAction::ActionTypeAndNot);
2015 void MainWindow::on_actionAnalyzePAFOrNotSelected_triggered()
2017 matchFieldFilter(FilterAction::ActionPrepare, FilterAction::ActionTypeOrNot);
2020 void MainWindow::on_actionAnalyzeDecodeAs_triggered()
2022 QAction *da_action = qobject_cast<QAction*>(sender());
2023 bool create_new = false;
2024 if (da_action && da_action->data().toBool() == true) {
2028 DecodeAsDialog da_dialog(this, capture_file_.capFile(), create_new);
2029 connect(this, SIGNAL(setCaptureFile(capture_file*)),
2030 &da_dialog, SLOT(setCaptureFile(capture_file*)));
2034 void MainWindow::openFollowStreamDialog(follow_type_t type) {
2035 FollowStreamDialog *fsd = new FollowStreamDialog(this, type, capture_file_.capFile());
2036 connect(fsd, SIGNAL(updateFilter(QString&, bool)), this, SLOT(filterPackets(QString&, bool)));
2037 connect(fsd, SIGNAL(goToPacket(int)), packet_list_, SLOT(goToPacket(int)));
2039 fsd->follow(getFilter());
2043 void MainWindow::on_actionAnalyzeFollowTCPStream_triggered()
2045 openFollowStreamDialog(FOLLOW_TCP);
2048 void MainWindow::on_actionAnalyzeFollowUDPStream_triggered()
2050 openFollowStreamDialog(FOLLOW_UDP);
2053 void MainWindow::on_actionAnalyzeFollowSSLStream_triggered()
2055 openFollowStreamDialog(FOLLOW_SSL);
2058 void MainWindow::openSCTPAllAssocsDialog()
2060 SCTPAllAssocsDialog *sctp_dialog = new SCTPAllAssocsDialog(this, capture_file_.capFile());
2061 connect(sctp_dialog, SIGNAL(filterPackets(QString&,bool)),
2062 this, SLOT(filterPackets(QString&,bool)));
2063 connect(this, SIGNAL(setCaptureFile(capture_file*)),
2064 sctp_dialog, SLOT(setCaptureFile(capture_file*)));
2065 sctp_dialog->fillTable();
2067 if (sctp_dialog->isMinimized() == true)
2069 sctp_dialog->showNormal();
2073 sctp_dialog->show();
2076 sctp_dialog->raise();
2077 sctp_dialog->activateWindow();
2080 void MainWindow::on_actionSCTPShowAllAssociations_triggered()
2082 openSCTPAllAssocsDialog();
2085 void MainWindow::on_actionSCTPAnalyseThisAssociation_triggered()
2087 SCTPAssocAnalyseDialog *sctp_analyse = new SCTPAssocAnalyseDialog(this, NULL, capture_file_.capFile());
2088 connect(sctp_analyse, SIGNAL(filterPackets(QString&,bool)),
2089 this, SLOT(filterPackets(QString&,bool)));
2091 if (sctp_analyse->isMinimized() == true)
2093 sctp_analyse->showNormal();
2097 sctp_analyse->show();
2100 sctp_analyse->raise();
2101 sctp_analyse->activateWindow();
2104 void MainWindow::on_actionSCTPFilterThisAssociation_triggered()
2106 sctp_assoc_info_t* assoc = SCTPAssocAnalyseDialog::findAssocForPacket(capture_file_.capFile());
2108 QString newFilter = QString("sctp.assoc_index==%1").arg(assoc->assoc_id);
2110 emit filterPackets(newFilter, false);
2115 // Next / previous / first / last slots in packet_list
2119 void MainWindow::on_actionStatisticsFlowGraph_triggered()
2121 SequenceDialog *sequence_dialog = new SequenceDialog(this, capture_file_.capFile());
2122 connect(sequence_dialog, SIGNAL(goToPacket(int)),
2123 packet_list_, SLOT(goToPacket(int)));
2124 connect(this, SIGNAL(setCaptureFile(capture_file*)),
2125 sequence_dialog, SLOT(setCaptureFile(capture_file*)));
2126 sequence_dialog->show();
2129 void MainWindow::openTcpStreamDialog(int graph_type)
2131 TCPStreamDialog *stream_dialog = new TCPStreamDialog(this, capture_file_.capFile(), (tcp_graph_type)graph_type);
2132 connect(stream_dialog, SIGNAL(goToPacket(int)),
2133 packet_list_, SLOT(goToPacket(int)));
2134 connect(this, SIGNAL(setCaptureFile(capture_file*)),
2135 stream_dialog, SLOT(setCaptureFile(capture_file*)));
2136 stream_dialog->show();
2139 void MainWindow::on_actionStatisticsTcpStreamStevens_triggered()
2141 openTcpStreamDialog(GRAPH_TSEQ_STEVENS);
2144 void MainWindow::on_actionStatisticsTcpStreamTcptrace_triggered()
2146 openTcpStreamDialog(GRAPH_TSEQ_TCPTRACE);
2149 void MainWindow::on_actionStatisticsTcpStreamThroughput_triggered()
2151 openTcpStreamDialog(GRAPH_THROUGHPUT);
2154 void MainWindow::on_actionStatisticsTcpStreamRoundTripTime_triggered()
2156 openTcpStreamDialog(GRAPH_RTT);
2159 void MainWindow::on_actionStatisticsTcpStreamWindowScaling_triggered()
2161 openTcpStreamDialog(GRAPH_WSCALE);
2164 void MainWindow::openStatisticsTreeDialog(const gchar *abbr)
2166 StatsTreeDialog *st_dialog = new StatsTreeDialog(this, capture_file_.capFile(), abbr);
2167 // connect(st_dialog, SIGNAL(goToPacket(int)),
2168 // packet_list_, SLOT(goToPacket(int)));
2169 connect(this, SIGNAL(setCaptureFile(capture_file*)),
2170 st_dialog, SLOT(setCaptureFile(capture_file*)));
2174 void MainWindow::on_actionStatistics29WestTopics_Advertisements_by_Topic_triggered()
2176 openStatisticsTreeDialog("lbmr_topic_ads_topic");
2179 void MainWindow::on_actionStatistics29WestTopics_Advertisements_by_Source_triggered()
2181 openStatisticsTreeDialog("lbmr_topic_ads_source");
2184 void MainWindow::on_actionStatistics29WestTopics_Advertisements_by_Transport_triggered()
2186 openStatisticsTreeDialog("lbmr_topic_ads_transport");
2189 void MainWindow::on_actionStatistics29WestTopics_Queries_by_Topic_triggered()
2191 openStatisticsTreeDialog("lbmr_topic_queries_topic");
2194 void MainWindow::on_actionStatistics29WestTopics_Queries_by_Receiver_triggered()
2196 openStatisticsTreeDialog("lbmr_topic_queries_receiver");
2199 void MainWindow::on_actionStatistics29WestTopics_Wildcard_Queries_by_Pattern_triggered()
2201 openStatisticsTreeDialog("lbmr_topic_queries_pattern");
2204 void MainWindow::on_actionStatistics29WestTopics_Wildcard_Queries_by_Receiver_triggered()
2206 openStatisticsTreeDialog("lbmr_topic_queries_pattern_receiver");
2209 void MainWindow::on_actionStatistics29WestQueues_Advertisements_by_Queue_triggered()
2211 openStatisticsTreeDialog("lbmr_queue_ads_queue");
2214 void MainWindow::on_actionStatistics29WestQueues_Advertisements_by_Source_triggered()
2216 openStatisticsTreeDialog("lbmr_queue_ads_source");
2219 void MainWindow::on_actionStatistics29WestQueues_Queries_by_Queue_triggered()
2221 openStatisticsTreeDialog("lbmr_queue_queries_queue");
2224 void MainWindow::on_actionStatistics29WestQueues_Queries_by_Receiver_triggered()
2226 openStatisticsTreeDialog("lbmr_queue_queries_receiver");
2229 void MainWindow::on_actionStatistics29WestUIM_Streams_triggered()
2231 LBMStreamDialog *stream_dialog = new LBMStreamDialog(this, capture_file_.capFile());
2232 // connect(stream_dialog, SIGNAL(goToPacket(int)),
2233 // packet_list_, SLOT(goToPacket(int)));
2234 connect(this, SIGNAL(setCaptureFile(capture_file*)),
2235 stream_dialog, SLOT(setCaptureFile(capture_file*)));
2236 stream_dialog->show();
2239 void MainWindow::on_actionStatistics29WestUIM_Stream_Flow_Graph_triggered()
2241 LBMUIMFlowDialog * uimflow_dialog = new LBMUIMFlowDialog(this, capture_file_.capFile());
2242 connect(uimflow_dialog, SIGNAL(goToPacket(int)),
2243 packet_list_, SLOT(goToPacket(int)));
2244 connect(this, SIGNAL(setCaptureFile(capture_file*)),
2245 uimflow_dialog, SLOT(setCaptureFile(capture_file*)));
2246 uimflow_dialog->show();
2249 void MainWindow::on_actionStatistics29WestLBTRM_triggered()
2251 LBMLBTRMTransportDialog * lbtrm_dialog = new LBMLBTRMTransportDialog(this, capture_file_.capFile());
2252 connect(lbtrm_dialog, SIGNAL(goToPacket(int)),
2253 packet_list_, SLOT(goToPacket(int)));
2254 connect(this, SIGNAL(setCaptureFile(capture_file*)),
2255 lbtrm_dialog, SLOT(setCaptureFile(capture_file*)));
2256 lbtrm_dialog->show();
2258 void MainWindow::on_actionStatistics29WestLBTRU_triggered()
2260 LBMLBTRUTransportDialog * lbtru_dialog = new LBMLBTRUTransportDialog(this, capture_file_.capFile());
2261 connect(lbtru_dialog, SIGNAL(goToPacket(int)),
2262 packet_list_, SLOT(goToPacket(int)));
2263 connect(this, SIGNAL(setCaptureFile(capture_file*)),
2264 lbtru_dialog, SLOT(setCaptureFile(capture_file*)));
2265 lbtru_dialog->show();
2268 void MainWindow::on_actionStatisticsANCP_triggered()
2270 openStatisticsTreeDialog("ancp");
2273 void MainWindow::on_actionStatisticsBACappInstanceId_triggered()
2275 openStatisticsTreeDialog("bacapp_instanceid");
2278 void MainWindow::on_actionStatisticsBACappIP_triggered()
2280 openStatisticsTreeDialog("bacapp_ip");
2283 void MainWindow::on_actionStatisticsBACappObjectId_triggered()
2285 openStatisticsTreeDialog("bacapp_objectid");
2288 void MainWindow::on_actionStatisticsBACappService_triggered()
2290 openStatisticsTreeDialog("bacapp_service");
2293 void MainWindow::on_actionStatisticsCollectd_triggered()
2295 openStatisticsTreeDialog("collectd");
2298 void MainWindow::statCommandConversations(const char *arg, void *userdata)
2300 ConversationDialog *conv_dialog = new ConversationDialog(this, capture_file_.capFile(), GPOINTER_TO_INT(userdata), arg);
2301 connect(conv_dialog, SIGNAL(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)),
2302 this, SLOT(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)));
2303 connect(conv_dialog, SIGNAL(openFollowStreamDialog(follow_type_t)),
2304 this, SLOT(openFollowStreamDialog(follow_type_t)));
2305 connect(conv_dialog, SIGNAL(openTcpStreamGraph(int)),
2306 this, SLOT(openTcpStreamDialog(int)));
2307 connect(this, SIGNAL(setCaptureFile(capture_file*)),
2308 conv_dialog, SLOT(setCaptureFile(capture_file*)));
2309 conv_dialog->show();
2312 void MainWindow::on_actionStatisticsConversations_triggered()
2314 statCommandConversations(NULL, NULL);
2317 void MainWindow::statCommandEndpoints(const char *arg, void *userdata)
2319 EndpointDialog *endp_dialog = new EndpointDialog(this, capture_file_.capFile(), GPOINTER_TO_INT(userdata), arg);
2320 connect(endp_dialog, SIGNAL(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)),
2321 this, SLOT(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)));
2322 connect(endp_dialog, SIGNAL(openFollowStreamDialog(follow_type_t)),
2323 this, SLOT(openFollowStreamDialog(follow_type_t)));
2324 connect(endp_dialog, SIGNAL(openTcpStreamGraph(int)),
2325 this, SLOT(openTcpStreamDialog(int)));
2326 connect(this, SIGNAL(setCaptureFile(capture_file*)),
2327 endp_dialog, SLOT(setCaptureFile(capture_file*)));
2328 endp_dialog->show();
2331 void MainWindow::on_actionStatisticsEndpoints_triggered()
2333 statCommandEndpoints(NULL, NULL);
2336 void MainWindow::on_actionStatisticsHART_IP_triggered()
2338 openStatisticsTreeDialog("hart_ip");
2341 void MainWindow::on_actionStatisticsHTTPPacketCounter_triggered()
2343 openStatisticsTreeDialog("http");
2346 void MainWindow::on_actionStatisticsHTTPRequests_triggered()
2348 openStatisticsTreeDialog("http_req");
2351 void MainWindow::on_actionStatisticsHTTPLoadDistribution_triggered()
2353 openStatisticsTreeDialog("http_srv");
2356 void MainWindow::on_actionStatisticsPacketLen_triggered()
2358 openStatisticsTreeDialog("plen");
2361 void MainWindow::statCommandIOGraph(const char *arg, void *userdata)
2365 IOGraphDialog *iog_dialog = new IOGraphDialog(this, capture_file_.capFile());
2366 connect(iog_dialog, SIGNAL(goToPacket(int)), packet_list_, SLOT(goToPacket(int)));
2367 connect(this, SIGNAL(setCaptureFile(capture_file*)),
2368 iog_dialog, SLOT(setCaptureFile(capture_file*)));
2372 void MainWindow::on_actionStatisticsIOGraph_triggered()
2374 statCommandIOGraph(NULL, NULL);
2376 void MainWindow::on_actionStatisticsSametime_triggered()
2378 openStatisticsTreeDialog("sametime");
2383 void MainWindow::openVoipCallsDialog(bool all_flows)
2385 VoipCallsDialog *voip_calls_dialog = new VoipCallsDialog(this, capture_file_.capFile(), all_flows);
2386 connect(voip_calls_dialog, SIGNAL(goToPacket(int)),
2387 packet_list_, SLOT(goToPacket(int)));
2388 connect(voip_calls_dialog, SIGNAL(updateFilter(QString&, bool)),
2389 this, SLOT(filterPackets(QString&, bool)));
2390 connect(this, SIGNAL(setCaptureFile(capture_file*)),
2391 voip_calls_dialog, SLOT(setCaptureFile(capture_file*)));
2392 voip_calls_dialog->show();
2395 void MainWindow::on_actionTelephonyVoipCalls_triggered()
2397 openVoipCallsDialog();
2400 void MainWindow::on_actionTelephonyISUPMessages_triggered()
2402 openStatisticsTreeDialog("isup_msg");
2405 void MainWindow::on_actionTelephonyRTSPPacketCounter_triggered()
2407 openStatisticsTreeDialog("rtsp");
2410 void MainWindow::on_actionTelephonySMPPOperations_triggered()
2412 openStatisticsTreeDialog("smpp_commands");
2415 void MainWindow::on_actionTelephonyUCPMessages_triggered()
2417 openStatisticsTreeDialog("ucp_messages");
2420 void MainWindow::on_actionTelephonySipFlows_triggered()
2422 openVoipCallsDialog(true);
2426 void MainWindow::on_actionHelpContents_triggered() {
2428 wsApp->helpTopicAction(HELP_CONTENT);
2431 void MainWindow::on_actionHelpMPWireshark_triggered() {
2433 wsApp->helpTopicAction(LOCALPAGE_MAN_WIRESHARK);
2436 void MainWindow::on_actionHelpMPWireshark_Filter_triggered() {
2437 wsApp->helpTopicAction(LOCALPAGE_MAN_WIRESHARK_FILTER);
2440 void MainWindow::on_actionHelpMPCapinfos_triggered() {
2441 wsApp->helpTopicAction(LOCALPAGE_MAN_CAPINFOS);
2444 void MainWindow::on_actionHelpMPDumpcap_triggered() {
2445 wsApp->helpTopicAction(LOCALPAGE_MAN_DUMPCAP);
2448 void MainWindow::on_actionHelpMPEditcap_triggered() {
2449 wsApp->helpTopicAction(LOCALPAGE_MAN_EDITCAP);
2452 void MainWindow::on_actionHelpMPMergecap_triggered() {
2453 wsApp->helpTopicAction(LOCALPAGE_MAN_MERGECAP);
2456 void MainWindow::on_actionHelpMPRawShark_triggered() {
2457 wsApp->helpTopicAction(LOCALPAGE_MAN_RAWSHARK);
2460 void MainWindow::on_actionHelpMPReordercap_triggered() {
2461 wsApp->helpTopicAction(LOCALPAGE_MAN_REORDERCAP);
2464 void MainWindow::on_actionHelpMPText2cap_triggered() {
2465 wsApp->helpTopicAction(LOCALPAGE_MAN_TEXT2PCAP);
2468 void MainWindow::on_actionHelpMPTShark_triggered() {
2469 wsApp->helpTopicAction(LOCALPAGE_MAN_TSHARK);
2472 void MainWindow::on_actionHelpWebsite_triggered() {
2474 wsApp->helpTopicAction(ONLINEPAGE_HOME);
2477 void MainWindow::on_actionHelpFAQ_triggered() {
2479 wsApp->helpTopicAction(ONLINEPAGE_FAQ);
2482 void MainWindow::on_actionHelpAsk_triggered() {
2484 wsApp->helpTopicAction(ONLINEPAGE_ASK);
2487 void MainWindow::on_actionHelpDownloads_triggered() {
2489 wsApp->helpTopicAction(ONLINEPAGE_DOWNLOAD);
2492 void MainWindow::on_actionHelpWiki_triggered() {
2494 wsApp->helpTopicAction(ONLINEPAGE_WIKI);
2497 void MainWindow::on_actionHelpSampleCaptures_triggered() {
2499 wsApp->helpTopicAction(ONLINEPAGE_SAMPLE_FILES);
2502 #ifdef HAVE_SOFTWARE_UPDATE
2503 void MainWindow::checkForUpdates()
2505 software_update_check();
2509 void MainWindow::on_actionHelpAbout_triggered()
2511 AboutDialog *about_dialog = new AboutDialog(this);
2513 if (about_dialog->isMinimized() == true)
2515 about_dialog->showNormal();
2519 about_dialog->show();
2522 about_dialog->raise();
2523 about_dialog->activateWindow();
2526 void MainWindow::on_actionGoGoToPacket_triggered() {
2527 if (packet_list_->model()->rowCount() < 1) {
2530 previous_focus_ = wsApp->focusWidget();
2531 connect(previous_focus_, SIGNAL(destroyed()), this, SLOT(resetPreviousFocus()));
2533 main_ui_->searchFrame->animatedHide();
2534 if (main_ui_->goToFrame->isVisible()) {
2535 main_ui_->goToFrame->animatedHide();
2537 main_ui_->goToFrame->animatedShow();
2539 main_ui_->goToLineEdit->setFocus();
2542 void MainWindow::resetPreviousFocus() {
2543 previous_focus_ = NULL;
2546 void MainWindow::on_goToCancel_clicked()
2548 main_ui_->goToFrame->animatedHide();
2549 if (previous_focus_) {
2550 disconnect(previous_focus_, SIGNAL(destroyed()), this, SLOT(resetPreviousFocus()));
2551 previous_focus_->setFocus();
2552 resetPreviousFocus();
2556 void MainWindow::on_goToGo_clicked()
2558 int packet_num = main_ui_->goToLineEdit->text().toInt();
2560 if (packet_num > 0) {
2561 packet_list_->goToPacket(packet_num);
2563 on_goToCancel_clicked();
2566 void MainWindow::on_goToLineEdit_returnPressed()
2568 on_goToGo_clicked();
2571 void MainWindow::on_actionCaptureStart_triggered()
2573 //#ifdef HAVE_AIRPCAP
2574 // airpcap_if_active = airpcap_if_selected;
2575 // if (airpcap_if_active)
2576 // airpcap_set_toolbar_start_capture(airpcap_if_active);
2579 // if (cap_open_w) {
2581 // * There's an options dialog; get the values from it and close it.
2583 // gboolean success;
2585 // /* Determine if "capture start" while building of the "capture options" window */
2586 // /* is in progress. If so, ignore the "capture start. */
2587 // /* XXX: Would it be better/cleaner for the "capture options" window code to */
2588 // /* disable the capture start button temporarily ? */
2589 // if (cap_open_complete == FALSE) {
2590 // return; /* Building options window: ignore "capture start" */
2592 // success = capture_dlg_prep(cap_open_w);
2593 // window_destroy(GTK_WIDGET(cap_open_w));
2595 // return; /* error in options dialog */
2598 main_ui_->mainStack->setCurrentWidget(&master_split_);
2601 if (global_capture_opts.num_selected == 0) {
2602 QString err_msg = tr("No Interface Selected");
2603 main_ui_->statusBar->pushTemporaryStatus(err_msg);
2607 /* XXX - will closing this remove a temporary file? */
2608 if (testCaptureFileClose(FALSE, *new QString(" before starting a new capture")))
2610 #endif // HAVE_LIBPCAP
2613 void MainWindow::on_actionCaptureStop_triggered()
2618 void MainWindow::on_actionStatisticsCaptureFileProperties_triggered()
2620 CaptureFilePropertiesDialog *capture_file_properties_dialog = new CaptureFilePropertiesDialog(this, capture_file_.capFile());
2621 connect(capture_file_properties_dialog, SIGNAL(captureCommentChanged()),
2622 this, SLOT(updateForUnsavedChanges()));
2623 connect(this, SIGNAL(setCaptureFile(capture_file*)),
2624 capture_file_properties_dialog, SLOT(setCaptureFile(capture_file*)));
2625 capture_file_properties_dialog->show();
2629 void MainWindow::on_actionCaptureOptions_triggered()
2631 connect(&capture_interfaces_dialog_, SIGNAL(setFilterValid(bool)), this, SLOT(startInterfaceCapture(bool)));
2632 capture_interfaces_dialog_.SetTab(0);
2633 capture_interfaces_dialog_.updateInterfaces();
2635 if (capture_interfaces_dialog_.isMinimized() == true)
2637 capture_interfaces_dialog_.showNormal();
2641 capture_interfaces_dialog_.show();
2644 capture_interfaces_dialog_.raise();
2645 capture_interfaces_dialog_.activateWindow();
2648 void MainWindow::on_actionCaptureRefreshInterfaces_triggered()
2650 wsApp->refreshLocalInterfaces();
2661 * indent-tabs-mode: nil
2664 * ex: set shiftwidth=4 tabstop=8 expandtab:
2665 * :indentSize=4:tabSize=8:noTabs=true: