Allow "capture info data" to not be a singleton.
[metze/wireshark/wip.git] / ui / qt / main_window_slots.cpp
index 9f77bd487f0be6a8864f0c93a44557a63bc44406..cb6f8eff0f9787b818b6fe94b8dc3fbc9502d769 100644 (file)
 
 #include <config.h>
 
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
+// Qt 5.5.0 + Visual C++ 2013
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable:4996)
 #endif
 
 #include "main_window.h"
@@ -34,7 +32,6 @@
 
 #ifdef _WIN32
 #include <windows.h>
-#include <io.h>
 #endif
 
 #ifdef HAVE_LIBPCAP
 
 #include "wsutil/file_util.h"
 #include "wsutil/filesystem.h"
-#include <wsutil/str_util.h>
+#include "wsutil/str_util.h"
 
 #include "epan/addr_resolv.h"
-#include "epan/color_dissector_filters.h"
+#include "epan/dissector_filters.h"
 #include "epan/column.h"
+#include "epan/dfilter/dfilter-macro.h"
 #include "epan/epan_dissect.h"
 #include "epan/filter_expressions.h"
 #include "epan/prefs.h"
+#include "epan/uat.h"
 #include "epan/value_string.h"
 
+#ifdef HAVE_LUA
+#include <epan/wslua/init_wslua.h>
+#endif
+
 #include "ui/alert_box.h"
 #ifdef HAVE_LIBPCAP
 #include "ui/capture_ui_utils.h"
@@ -68,6 +71,7 @@
 #include "ui/recent_utils.h"
 #include "ui/ssl_key_export.h"
 #include "ui/ui_util.h"
+#include "ui/qt/simple_dialog.h"
 
 #ifdef HAVE_SOFTWARE_UPDATE
 #include "ui/software_update.h"
 #include "color_utils.h"
 #include "coloring_rules_dialog.h"
 #include "conversation_dialog.h"
+#include "conversation_hash_tables_dialog.h"
+#include "enabled_protocols_dialog.h"
 #include "decode_as_dialog.h"
 #include "display_filter_edit.h"
 #include "display_filter_expression_dialog.h"
+#include "dissector_tables_dialog.h"
 #include "endpoint_dialog.h"
 #include "expert_info_dialog.h"
 #include "export_object_dialog.h"
 #if HAVE_EXTCAP
 #include "extcap_options_dialog.h"
 #endif
+#include "filter_action.h"
 #include "filter_dialog.h"
+#include "funnel_statistics.h"
+#include "gsm_map_summary_dialog.h"
+#include "iax2_analysis_dialog.h"
 #include "io_graph_dialog.h"
 #include "lbm_stream_dialog.h"
 #include "lbm_uimflow_dialog.h"
 #include "lbm_lbtrm_transport_dialog.h"
 #include "lbm_lbtru_transport_dialog.h"
+#include "lte_mac_statistics_dialog.h"
+#include "lte_rlc_statistics_dialog.h"
+#include "lte_rlc_graph_dialog.h"
+#include "mtp3_summary_dialog.h"
+#include "multicast_statistics_dialog.h"
 #include "packet_comment_dialog.h"
 #include "packet_dialog.h"
 #include "packet_list.h"
 #include "protocol_hierarchy_dialog.h"
 #include "qt_ui_utils.h"
 #include "resolved_addresses_dialog.h"
+#include "rpc_service_response_time_dialog.h"
 #include "rtp_stream_dialog.h"
 #include "rtp_analysis_dialog.h"
 #include "sctp_all_assocs_dialog.h"
 #include "sequence_dialog.h"
 #include "stats_tree_dialog.h"
 #include "stock_icon.h"
+#include "supported_protocols_dialog.h"
 #include "tap_parameter_dialog.h"
 #include "tcp_stream_dialog.h"
 #include "time_shift_dialog.h"
+#include "uat_dialog.h"
 #include "voip_calls_dialog.h"
 #include "wireshark_application.h"
-#include "filter_action.h"
+#include "wlan_statistics_dialog.h"
 
 #include <QClipboard>
 #include <QFileInfo>
 // Public slots
 //
 
-const char *dfe_property_ = "display filter expression"; //TODO : Fix Translate
+static const char *dfe_property_ = "display filter expression"; //TODO : Fix Translate
 
-bool MainWindow::openCaptureFile(QString& cf_path, QString& read_filter, unsigned int type)
+// We're too lazy to sublcass QAction.
+static const char *color_number_property_ = "color number";
+
+bool MainWindow::openCaptureFile(QString cf_path, QString read_filter, unsigned int type)
 {
     QString file_name = "";
     dfilter_t *rfcode = NULL;
@@ -246,7 +268,7 @@ bool MainWindow::openCaptureFile(QString& cf_path, QString& read_filter, unsigne
     return true;
 }
 
-void MainWindow::filterPackets(QString& new_filter, bool force)
+void MainWindow::filterPackets(QString new_filter, bool force)
 {
     cf_status_t cf_status;
 
@@ -259,14 +281,18 @@ void MainWindow::filterPackets(QString& new_filter, bool force)
             if (index == -1) {
                 df_combo_box_->insertItem(0, new_filter);
                 df_combo_box_->setCurrentIndex(0);
-            }
-            else {
+            } else {
                 df_combo_box_->setCurrentIndex(index);
             }
+        } else {
+            df_combo_box_->lineEdit()->clear();
         }
     } else {
         emit displayFilterSuccess(false);
     }
+    if (packet_list_) {
+        packet_list_->resetColumns();
+    }
 }
 
 // A new layout should be applied when it differs from the old layout AND
@@ -279,7 +305,11 @@ void MainWindow::layoutPanes()
     QVector<unsigned> new_layout = QVector<unsigned>() << prefs.gui_layout_type
                                                        << prefs.gui_layout_content_1
                                                        << prefs.gui_layout_content_2
-                                                       << prefs.gui_layout_content_3;
+                                                       << prefs.gui_layout_content_3
+                                                       << recent.packet_list_show
+                                                       << recent.tree_view_show
+                                                       << recent.byte_view_show;
+
     if (cur_layout_ == new_layout) return;
 
     QSplitter *parents[3];
@@ -422,9 +452,15 @@ void MainWindow::layoutToolbars()
         break;
     case TB_STYLE_BOTH:
         tbstyle = Qt::ToolButtonTextUnderIcon;
+        break;
     }
 
     main_ui_->mainToolBar->setToolButtonStyle(tbstyle);
+
+    main_ui_->mainToolBar->setVisible(recent.main_toolbar_show);
+    main_ui_->displayFilterToolBar->setVisible(recent.filter_toolbar_show);
+    main_ui_->wirelessToolBar->setVisible(recent.wireless_toolbar_show);
+    main_ui_->statusBar->setVisible(recent.statusbar_show);
 }
 
 void MainWindow::updatePreferenceActions()
@@ -437,6 +473,31 @@ void MainWindow::updatePreferenceActions()
     main_ui_->actionGoAutoScroll->setChecked(prefs.capture_auto_scroll);
 }
 
+void MainWindow::updateRecentActions()
+{
+    main_ui_->actionViewMainToolbar->setChecked(recent.main_toolbar_show);
+    main_ui_->actionViewFilterToolbar->setChecked(recent.filter_toolbar_show);
+    main_ui_->actionViewWirelessToolbar->setChecked(recent.wireless_toolbar_show);
+    main_ui_->actionViewStatusBar->setChecked(recent.statusbar_show);
+    main_ui_->actionViewPacketList->setChecked(recent.packet_list_show);
+    main_ui_->actionViewPacketDetails->setChecked(recent.tree_view_show);
+    main_ui_->actionViewPacketBytes->setChecked(recent.byte_view_show);
+
+    foreach (QAction* tda, td_actions.keys()) {
+        if (recent.gui_time_format == td_actions[tda]) {
+            tda->setChecked(true);
+        }
+    }
+    foreach (QAction* tpa, tp_actions.keys()) {
+        if (recent.gui_time_precision == tp_actions[tpa]) {
+            tpa->setChecked(true);
+        }
+    }
+    main_ui_->actionViewTimeDisplaySecondsWithHoursAndMinutes->setChecked(recent.gui_seconds_format == TS_SECONDS_HOUR_MIN_SEC);
+
+    main_ui_->actionViewColorizePacketList->setChecked(recent.packet_list_colorize);
+}
+
 void MainWindow::filterAction(QString &action_filter, FilterAction::Action action, FilterAction::ActionType type)
 {
     QString cur_filter, new_filter;
@@ -631,6 +692,8 @@ void MainWindow::captureFileReadStarted(const QString &action) {
     QString msgtip = QString();
     main_ui_->statusBar->pushFileStatus(msg, msgtip);
     main_ui_->mainStack->setCurrentWidget(&master_split_);
+    main_ui_->actionAnalyzeReloadLuaPlugins->setEnabled(false);
+
     WiresharkApplication::processEvents();
 }
 
@@ -654,18 +717,36 @@ void MainWindow::captureFileReadFinished() {
     setForCapturedPackets(true);
 
     main_ui_->statusBar->setFileName(capture_file_);
+    main_ui_->actionAnalyzeReloadLuaPlugins->setEnabled(true);
+
+    packet_list_->captureFileReadFinished();
 
     emit setDissectedCaptureFile(capture_file_.capFile());
 }
 
+void MainWindow::captureFileRetapStarted()
+{
+    // XXX Push a status message?
+    freeze();
+}
+
+void MainWindow::captureFileRetapFinished()
+{
+    thaw();
+}
+
+void MainWindow::captureFileFlushTapsData()
+{
+    draw_tap_listeners(FALSE);
+}
+
 void MainWindow::captureFileClosing() {
     setMenusForCaptureFile(true);
     setForCapturedPackets(false);
-    setMenusForSelectedPacket();
     setForCaptureInProgress(false);
 
     // Reset expert information indicator
-    main_ui_->statusBar->hideExpert();
+    main_ui_->statusBar->captureFileClosing();
     main_ui_->searchFrame->animatedHide();
 //    gtk_widget_show(expert_info_none);
     emit setCaptureFile(NULL);
@@ -677,13 +758,16 @@ void MainWindow::captureFileClosed() {
 
     file_set_dialog_.fileClosed();
     setMenusForFileSet(false);
+    setWindowModified(false);
 
     // Reset expert information indicator
-    main_ui_->statusBar->hideExpert();
+    main_ui_->statusBar->captureFileClosing();
 
     main_ui_->statusBar->popFileStatus();
 
-    setTitlebarForSelectedTreeRow();
+    setDefaultWindowTitle();
+    setWindowIcon(wsApp->normalIcon());
+    setMenusForSelectedPacket();
     setMenusForSelectedTreeRow();
 
     if (!global_capture_opts.multi_files_on)
@@ -694,7 +778,7 @@ void MainWindow::captureFileSaveStarted(const QString &file_path)
 {
     QFileInfo file_info(file_path);
     main_ui_->statusBar->popFileStatus();
-    main_ui_->statusBar->pushFileStatus(tr("Saving %1...").arg(file_info.baseName()));
+    main_ui_->statusBar->pushFileStatus(tr("Saving %1" UTF8_HORIZONTAL_ELLIPSIS).arg(file_info.baseName()));
 }
 
 void MainWindow::filterExpressionsChanged()
@@ -702,13 +786,13 @@ void MainWindow::filterExpressionsChanged()
     // Recreate filter buttons
     foreach (QAction *act, main_ui_->displayFilterToolBar->actions()) {
         // Permanent actions shouldn't have data
-        if (act->property(dfe_property_).isValid() || act->isSeparator()) {
+        if (act->property(dfe_property_).isValid()) {
             main_ui_->displayFilterToolBar->removeAction(act);
             delete act;
         }
     }
 
-    bool first = true;
+    // XXX Add a context menu for removing and changing buttons.
     for (struct filter_expression *fe = *pfilter_expression_head; fe != NULL; fe = fe->next) {
         if (!fe->enabled) continue;
         QAction *dfb_action = new QAction(fe->label, main_ui_->displayFilterToolBar);
@@ -717,10 +801,6 @@ void MainWindow::filterExpressionsChanged()
         dfb_action->setProperty(dfe_property_, true);
         main_ui_->displayFilterToolBar->addAction(dfb_action);
         connect(dfb_action, SIGNAL(triggered()), this, SLOT(displayFilterButtonClicked()));
-        if (first) {
-            first = false;
-            main_ui_->displayFilterToolBar->insertSeparator(dfb_action);
-        }
     }
 }
 
@@ -743,8 +823,6 @@ void MainWindow::startCapture() {
         return;
     }
 
-    main_ui_->mainStack->setCurrentWidget(&master_split_);
-
     // Ideally we should have disabled the start capture
     // toolbar buttons and menu items. This may not be the
     // case, e.g. with QtMacExtras.
@@ -755,6 +833,8 @@ void MainWindow::startCapture() {
         return;
     }
 
+    main_ui_->mainStack->setCurrentWidget(&master_split_);
+
     /* XXX - we might need to init other pref data as well... */
 
     /* XXX - can this ever happen? */
@@ -769,12 +849,12 @@ void MainWindow::startCapture() {
     collect_ifaces(&global_capture_opts);
 
     CaptureFile::globalCapFile()->window = this;
-    if (capture_start(&global_capture_opts, &cap_session_, main_window_update)) {
+    if (capture_start(&global_capture_opts, &cap_session_, &info_data_, main_window_update)) {
         capture_options *capture_opts = cap_session_.capture_opts;
         GString *interface_names;
 
         /* enable autoscroll timer as needed. */
-        packet_list_->setAutoScroll(main_ui_->actionGoAutoScroll->isChecked());
+        packet_list_->setVerticalAutoScroll(main_ui_->actionGoAutoScroll->isChecked());
 
         /* Add "interface name<live capture in progress>" on main status bar */
         interface_names = get_iface_list_string(capture_opts, 0);
@@ -889,7 +969,16 @@ void MainWindow::stopCapture() {
     main_ui_->statusBar->setFileName(capture_file_);
 
     /* disable autoscroll timer if any. */
-    packet_list_->setAutoScroll(false);
+    packet_list_->setVerticalAutoScroll(false);
+}
+
+// Keep focus rects from showing through the welcome screen. Primarily for
+// OS X.
+void MainWindow::mainStackChanged(int)
+{
+    for (int i = 0; i < main_ui_->mainStack->count(); i++) {
+        main_ui_->mainStack->widget(i)->setEnabled(i == main_ui_->mainStack->currentIndex());
+    }
 }
 
 // XXX - Copied from ui/gtk/menus.c
@@ -957,35 +1046,42 @@ void MainWindow::recentActionTriggered() {
 
 void MainWindow::setMenusForSelectedPacket()
 {
-//    gboolean is_ip = FALSE, is_tcp = FALSE, is_udp = FALSE, is_sctp = FALSE, is_ssl = FALSE;
-    gboolean is_tcp = FALSE, is_sctp = FALSE, is_rtp = FALSE;
+    gboolean is_ip = FALSE, is_tcp = FALSE, is_udp = FALSE, is_sctp = FALSE, is_ssl = FALSE, is_rtp = FALSE, is_lte_rlc = FALSE;
 
-//    /* Making the menu context-sensitive allows for easier selection of the
-//       desired item and has the added benefit, with large captures, of
-//       avoiding needless looping through huge lists for marked, ignored,
-//       or time-referenced packets. */
-//    gboolean is_ssl = epan_dissect_packet_contains_field(cf->edt, "ssl");
+    /* Making the menu context-sensitive allows for easier selection of the
+       desired item and has the added benefit, with large captures, of
+       avoiding needless looping through huge lists for marked, ignored,
+       or time-referenced packets. */
 
     /* We have one or more items in the packet list */
-    gboolean have_frames = FALSE;
+    bool have_frames = false;
     /* A frame is selected */
-    gboolean frame_selected = FALSE;
+    bool frame_selected = false;
     /* We have marked frames.  (XXX - why check frame_selected?) */
-    gboolean have_marked = FALSE;
+    bool have_marked = false;
     /* We have a marked frame other than the current frame (i.e.,
        we have at least one marked frame, and either there's more
        than one marked frame or the current frame isn't marked). */
-    gboolean another_is_marked = FALSE;
+    bool another_is_marked = false;
     /* One or more frames are hidden by a display filter */
-    gboolean have_filtered = FALSE;
+    bool have_filtered = false;
     /* One or more frames have been ignored */
-    gboolean have_ignored = FALSE;
-    gboolean have_time_ref = FALSE;
+    bool have_ignored = false;
+    bool have_time_ref = false;
     /* We have a time reference frame other than the current frame (i.e.,
        we have at least one time reference frame, and either there's more
        than one time reference frame or the current frame isn't a
        time reference frame). (XXX - why check frame_selected?) */
-    gboolean another_is_time_ref = FALSE;
+    bool another_is_time_ref = false;
+    /* We have a valid filter expression */
+    bool have_filter_expr = false;
+
+    QList<QAction *> cc_actions = QList<QAction *>()
+            << main_ui_->actionViewColorizeConversation1 << main_ui_->actionViewColorizeConversation2
+            << main_ui_->actionViewColorizeConversation3 << main_ui_->actionViewColorizeConversation4
+            << main_ui_->actionViewColorizeConversation5 << main_ui_->actionViewColorizeConversation6
+            << main_ui_->actionViewColorizeConversation7 << main_ui_->actionViewColorizeConversation8
+            << main_ui_->actionViewColorizeConversation9 << main_ui_->actionViewColorizeConversation10;
 
     if (capture_file_.capFile()) {
         frame_selected = capture_file_.capFile()->current_frame != NULL;
@@ -1001,36 +1097,13 @@ void MainWindow::setMenusForSelectedPacket()
 
         if (capture_file_.capFile()->edt)
         {
-            proto_get_frame_protocols(capture_file_.capFile()->edt->pi.layers, NULL, &is_tcp, NULL, &is_sctp, NULL, &is_rtp);
+            proto_get_frame_protocols(capture_file_.capFile()->edt->pi.layers,
+                                      &is_ip, &is_tcp, &is_udp, &is_sctp,
+                                      &is_ssl, &is_rtp, &is_lte_rlc);
         }
     }
-//    if (cfile.edt && cfile.edt->tree) {
-//        GPtrArray          *ga;
-//        header_field_info  *hfinfo;
-//        field_info         *v;
-//        guint              ii;
 
-//        ga = proto_all_finfos(cfile.edt->tree);
-
-//        for (ii = ga->len - 1; ii > 0 ; ii -= 1) {
-
-//            v = g_ptr_array_index (ga, ii);
-//            hfinfo =  v->hfinfo;
-
-//            if (!g_str_has_prefix(hfinfo->abbrev, "text") &&
-//                !g_str_has_prefix(hfinfo->abbrev, "_ws.expert") &&
-//                !g_str_has_prefix(hfinfo->abbrev, "_ws.malformed")) {
-
-//                if (hfinfo->parent == -1) {
-//                    abbrev = hfinfo->abbrev;
-//                } else {
-//                    abbrev = proto_registrar_get_abbrev(hfinfo->parent);
-//                }
-//                properties = prefs_is_registered_protocol(abbrev);
-//                break;
-//            }
-//        }
-//    }
+    have_filter_expr = !packet_list_->getFilterFromRowAndColumn().isEmpty();
 
     main_ui_->actionEditMarkPacket->setEnabled(frame_selected);
     main_ui_->actionEditMarkAllDisplayed->setEnabled(have_frames);
@@ -1039,10 +1112,10 @@ void MainWindow::setMenusForSelectedPacket()
     main_ui_->actionEditNextMark->setEnabled(another_is_marked);
     main_ui_->actionEditPreviousMark->setEnabled(another_is_marked);
 
-//#ifdef WANT_PACKET_EDITOR
+#ifdef WANT_PACKET_EDITOR
 //    set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/EditPacket",
 //                         frame_selected);
-//#endif /* WANT_PACKET_EDITOR */
+#endif // WANT_PACKET_EDITOR
     main_ui_->actionEditPacketComment->setEnabled(frame_selected && wtap_dump_can_write(capture_file_.capFile()->linktypes, WTAP_COMMENT_PER_PACKET));
 
     main_ui_->actionEditIgnorePacket->setEnabled(frame_selected);
@@ -1056,284 +1129,227 @@ void MainWindow::setMenusForSelectedPacket()
     main_ui_->actionEditPreviousTimeReference->setEnabled(another_is_time_ref);
     main_ui_->actionEditTimeShift->setEnabled(have_frames);
 
-    main_ui_->actionViewColorizeConversation1->setEnabled(frame_selected);
-    main_ui_->actionViewColorizeConversation2->setEnabled(frame_selected);
-    main_ui_->actionViewColorizeConversation3->setEnabled(frame_selected);
-    main_ui_->actionViewColorizeConversation4->setEnabled(frame_selected);
-    main_ui_->actionViewColorizeConversation5->setEnabled(frame_selected);
-    main_ui_->actionViewColorizeConversation6->setEnabled(frame_selected);
-    main_ui_->actionViewColorizeConversation7->setEnabled(frame_selected);
-    main_ui_->actionViewColorizeConversation8->setEnabled(frame_selected);
-    main_ui_->actionViewColorizeConversation9->setEnabled(frame_selected);
-    main_ui_->actionViewColorizeConversation10->setEnabled(frame_selected);
+    main_ui_->actionGoGoToLinkedPacket->setEnabled(false);
+
+    main_ui_->actionAnalyzeAAFSelected->setEnabled(have_filter_expr);
+    main_ui_->actionAnalyzeAAFNotSelected->setEnabled(have_filter_expr);
+    main_ui_->actionAnalyzeAAFAndSelected->setEnabled(have_filter_expr);
+    main_ui_->actionAnalyzeAAFOrSelected->setEnabled(have_filter_expr);
+    main_ui_->actionAnalyzeAAFAndNotSelected->setEnabled(have_filter_expr);
+    main_ui_->actionAnalyzeAAFOrNotSelected->setEnabled(have_filter_expr);
+
+    main_ui_->actionAnalyzePAFSelected->setEnabled(have_filter_expr);
+    main_ui_->actionAnalyzePAFNotSelected->setEnabled(have_filter_expr);
+    main_ui_->actionAnalyzePAFAndSelected->setEnabled(have_filter_expr);
+    main_ui_->actionAnalyzePAFOrSelected->setEnabled(have_filter_expr);
+    main_ui_->actionAnalyzePAFAndNotSelected->setEnabled(have_filter_expr);
+    main_ui_->actionAnalyzePAFOrNotSelected->setEnabled(have_filter_expr);
+
+    main_ui_->actionAnalyzeFollowTCPStream->setEnabled(is_tcp);
+    main_ui_->actionAnalyzeFollowUDPStream->setEnabled(is_udp);
+    main_ui_->actionAnalyzeFollowSSLStream->setEnabled(is_ssl);
+
+    foreach (QAction *cc_action, cc_actions) {
+        cc_action->setEnabled(frame_selected);
+    }
     main_ui_->actionViewColorizeNewConversationRule->setEnabled(frame_selected);
 
     main_ui_->actionViewColorizeResetColorization->setEnabled(tmp_color_filters_used());
 
     main_ui_->actionViewColorizeNewConversationRule->setEnabled(frame_selected);
-//    set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/ResetColoring1-10",
-//                         tmp_color_filters_used());
 
     main_ui_->actionViewShowPacketInNewWindow->setEnabled(frame_selected);
-//    set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ManuallyResolveAddress",
-//                         frame_selected ? is_ip : FALSE);
-//    set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/SCTP",
-//                         frame_selected ? is_sctp : FALSE);
-//    set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/FollowTCPStream",
-//                         frame_selected ? is_tcp : FALSE);
-//    set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FollowTCPStream",
-//                         frame_selected ? is_tcp : FALSE);
-//    set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/FollowUDPStream",
-//                         frame_selected ? is_udp : FALSE);
-//    set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/FollowSSLStream",
-//                         frame_selected ? is_ssl : FALSE);
-//    set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FollowSSLStream",
-//                         frame_selected ? is_ssl : FALSE);
+    main_ui_->actionViewEditResolvedName->setEnabled(frame_selected && is_ip);
 
     main_ui_->menuConversationFilter->clear();
-    for (GList *color_list_entry = color_conv_filter_list; color_list_entry; color_list_entry = g_list_next(color_list_entry)) {
-        color_conversation_filter_t* color_filter = (color_conversation_filter_t *)color_list_entry->data;
-        QAction *conv_action = main_ui_->menuConversationFilter->addAction(color_filter->display_name);
+
+    packet_list_->conversationMenu()->clear();
+    packet_list_->colorizeMenu()->clear();
+
+    for (GList *conv_filter_list_entry = conv_filter_list; conv_filter_list_entry; conv_filter_list_entry = g_list_next(conv_filter_list_entry)) {
+        // Main menu items
+        conversation_filter_t* conv_filter = (conversation_filter_t *)conv_filter_list_entry->data;
+        QAction *conv_action = main_ui_->menuConversationFilter->addAction(conv_filter->display_name);
 
         bool enable = false;
         QString filter;
-        if (capture_file_.capFile()->edt) {
-            enable = color_filter->is_filter_valid(&capture_file_.capFile()->edt->pi);
-            filter = color_filter->build_filter_string(&capture_file_.capFile()->edt->pi);
+        if (capture_file_.capFile() && capture_file_.capFile()->edt) {
+            enable = conv_filter->is_filter_valid(&capture_file_.capFile()->edt->pi);
+            filter = gchar_free_to_qstring(conv_filter->build_filter_string(&capture_file_.capFile()->edt->pi));
         }
         conv_action->setEnabled(enable);
         conv_action->setData(filter);
         connect(conv_action, SIGNAL(triggered()), this, SLOT(applyConversationFilter()));
-    }
 
-//    set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FollowUDPStream",
-//                         frame_selected ? is_udp : FALSE);
-//    set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ConversationFilter/PN-CBA",
-//                         frame_selected ? (cf->edt->pi.profinet_type != 0 && cf->edt->pi.profinet_type < 10) : FALSE);
-//    set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation",
-//                         frame_selected);
-//    set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation/Ethernet",
-//                         frame_selected ? (cf->edt->pi.dl_src.type == AT_ETHER) : FALSE);
-//    set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation/IP",
-//                         frame_selected ? is_ip : FALSE);
-//    set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation/TCP",
-//                         frame_selected ? is_tcp : FALSE);
-//    set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation/UDP",
-//                         frame_selected ? is_udp : FALSE);
-//    set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ColorizeConversation/PN-CBA",
-//                         frame_selected ? (cf->edt->pi.profinet_type != 0 && cf->edt->pi.profinet_type < 10) : FALSE);
-
-//    if (properties) {
-//        prev_abbrev = g_object_get_data(G_OBJECT(ui_manager_packet_list_menu), "menu_abbrev");
-//        if (!prev_abbrev || (strcmp(prev_abbrev, abbrev) != 0)) {
-//          /*No previous protocol or protocol changed - update Protocol Preferences menu*/
-//            module_t *prefs_module_p = prefs_find_module(abbrev);
-//            rebuild_protocol_prefs_menu(prefs_module_p, properties, ui_manager_packet_list_menu, "/PacketListMenuPopup/ProtocolPreferences");
-
-//            g_object_set_data(G_OBJECT(ui_manager_packet_list_menu), "menu_abbrev", g_strdup(abbrev));
-//            g_free (prev_abbrev);
-//        }
-//    }
+        // Packet list context menu items
+        packet_list_->conversationMenu()->addAction(conv_action);
+
+        QMenu *submenu = packet_list_->colorizeMenu()->addMenu(conv_action->text());
+        int i = 1;
+        foreach (QAction *cc_action, cc_actions) {
+            QAction *colorize_action = submenu->addAction(cc_action->icon(), cc_action->text());
+            colorize_action->setProperty(color_number_property_, i++);
+            colorize_action->setData(filter);
+            colorize_action->setEnabled(enable);
+            connect(colorize_action, SIGNAL(triggered()), this, SLOT(colorizeWithFilter()));
+        }
+
+        QAction *conv_rule_action = submenu->addAction(main_ui_->actionViewColorizeNewConversationRule->text());
+        conv_rule_action->setData(conv_action->data());
+        conv_rule_action->setEnabled(enable);
+        connect(conv_rule_action, SIGNAL(triggered()), this, SLOT(colorizeWithFilter()));
+    }
 
-//    set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ProtocolPreferences",
-//                             properties);
-//    set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/Copy",
-//                         frame_selected);
-//    set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/ApplyAsFilter",
-//                         frame_selected);
-//    set_menu_sensitivity(ui_manager_packet_list_menu, "/PacketListMenuPopup/PrepareaFilter",
-//                         frame_selected);
-//    set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ResolveName",
-//                         frame_selected && (gbl_resolv_flags.mac_name || gbl_resolv_flags.network_name ||
-//                                            gbl_resolv_flags.transport_name || gbl_resolv_flags.concurrent_dns));
-//    set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/FollowTCPStream",
-//                         frame_selected ? is_tcp : FALSE);
-//    set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/FollowUDPStream",
-//                         frame_selected ? is_udp : FALSE);
-//    set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/AnalyzeMenu/FollowSSLStream",
-//                         frame_selected ? is_ssl : FALSE);
 //    set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/ResolveName",
 //                         frame_selected && (gbl_resolv_flags.mac_name || gbl_resolv_flags.network_name ||
 //                                            gbl_resolv_flags.transport_name || gbl_resolv_flags.concurrent_dns));
 //    set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ToolsMenu/FirewallACLRules",
 //                         frame_selected);
     main_ui_->menuTcpStreamGraphs->setEnabled(is_tcp);
-    main_ui_->menuSCTP->setEnabled(is_sctp);
     main_ui_->actionSCTPAnalyseThisAssociation->setEnabled(is_sctp);
     main_ui_->actionSCTPShowAllAssociations->setEnabled(is_sctp);
     main_ui_->actionSCTPFilterThisAssociation->setEnabled(is_sctp);
     main_ui_->actionTelephonyRTPStreamAnalysis->setEnabled(is_rtp);
-
-//    while (list_entry != NULL) {
-//        dissector_filter_t *filter_entry;
-//        gchar *path;
-
-//        filter_entry = list_entry->data;
-//        path = g_strdup_printf("/Menubar/AnalyzeMenu/ConversationFilterMenu/Filters/filter-%u", i);
-
-//        set_menu_sensitivity(ui_manager_main_menubar, path,
-//            menu_dissector_filter_spe_cb(/* frame_data *fd _U_*/ NULL, cf->edt, filter_entry));
-//        g_free(path);
-//        i++;
-//        list_entry = g_list_next(list_entry);
-//    }
+    main_ui_->actionTelephonyLteRlcGraph->setEnabled(is_lte_rlc);
 }
 
 void MainWindow::setMenusForSelectedTreeRow(field_info *fi) {
-    // XXX Add commented items below
+
+    bool can_match_selected = false;
+    bool is_framenum = false;
+    bool have_field_info = false;
+    bool have_subtree = false;
+    bool can_open_url = false;
+    QString field_filter;
+    int field_id = -1;
+
+    QList<QAction *> cc_actions = QList<QAction *>()
+            << main_ui_->actionViewColorizeConversation1 << main_ui_->actionViewColorizeConversation2
+            << main_ui_->actionViewColorizeConversation3 << main_ui_->actionViewColorizeConversation4
+            << main_ui_->actionViewColorizeConversation5 << main_ui_->actionViewColorizeConversation6
+            << main_ui_->actionViewColorizeConversation7 << main_ui_->actionViewColorizeConversation8
+            << main_ui_->actionViewColorizeConversation9 << main_ui_->actionViewColorizeConversation10;
 
     if (capture_file_.capFile()) {
         capture_file_.capFile()->finfo_selected = fi;
+
+        if (fi && fi->tree_type != -1) {
+            have_subtree = true;
+        }
     }
 
     if (capture_file_.capFile() != NULL && fi != NULL) {
-        header_field_info *hfinfo = capture_file_.capFile()->finfo_selected->hfinfo;
+        header_field_info *hfinfo = fi->hfinfo;
+        int linked_frame = -1;
+
+        have_field_info = true;
+        can_match_selected = proto_can_match_selected(capture_file_.capFile()->finfo_selected, capture_file_.capFile()->edt);
+        if (hfinfo && hfinfo->type == FT_FRAMENUM) {
+            is_framenum = true;
+            linked_frame = fvalue_get_uinteger(&fi->value);
+        }
 
-        /*
-        const char *abbrev;
-        char *prev_abbrev;
+        char *tmp_field = proto_construct_match_selected_string(fi, capture_file_.capFile()->edt);
+        field_filter = QString(tmp_field);
+        wmem_free(NULL, tmp_field);
+
+        field_id = fi->hfinfo->id;
+        /* if the selected field isn't a protocol, get its parent */
+        if (!proto_registrar_is_protocol(field_id)) {
+            field_id = proto_registrar_get_parent(fi->hfinfo->id);
+        }
 
-        if (hfinfo->parent == -1) {
-            abbrev = hfinfo->abbrev;
-            id = (hfinfo->type == FT_PROTOCOL) ? proto_get_id((protocol_t *)hfinfo->strings) : -1;
+        if (field_id >= 0) {
+            can_open_url = true;
+            main_ui_->actionContextWikiProtocolPage->setData(field_id);
+            main_ui_->actionContextFilterFieldReference->setData(field_id);
         } else {
-            abbrev = proto_registrar_get_abbrev(hfinfo->parent);
-            id = hfinfo->parent;
+            main_ui_->actionContextWikiProtocolPage->setData(QVariant());
+            main_ui_->actionContextFilterFieldReference->setData(QVariant());
         }
-        properties = prefs_is_registered_protocol(abbrev);
-        */
-        bool can_match_selected = proto_can_match_selected(capture_file_.capFile()->finfo_selected, capture_file_.capFile()->edt);
-        bool is_framenum = hfinfo && hfinfo->type == FT_FRAMENUM ? true : false;
-//        set_menu_sensitivity(ui_manager_tree_view_menu,
-//                             "/TreeViewPopup/GotoCorrespondingPacket", hfinfo->type == FT_FRAMENUM);
-        main_ui_->actionViewShowPacketReferenceInNewWindow->setEnabled(is_framenum);
-//        set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/Copy",
-//                             TRUE);
-
-//        set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/CreateAColumn",
-//                             hfinfo->type != FT_NONE);
-//        set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ColorizewithFilter",
-//                             proto_can_match_selected(cf->finfo_selected, cf->edt));
-//        set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ProtocolPreferences",
-//                             properties);
-//        set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/DisableProtocol",
-//                             (id == -1) ? FALSE : proto_can_toggle_protocol(id));
-//        set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ExpandSubtrees",
-//                             cf->finfo_selected->tree_type != -1);
-//        set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/WikiProtocolPage",
-//                             (id == -1) ? FALSE : TRUE);
-//        set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FilterFieldReference",
-//                             (id == -1) ? FALSE : TRUE);
-//        set_menu_sensitivity(ui_manager_main_menubar,
-        main_ui_->actionFileExportPacketBytes->setEnabled(true);
-
-//        set_menu_sensitivity(ui_manager_main_menubar,
-//                             "/Menubar/GoMenu/GotoCorrespondingPacket", hfinfo->type == FT_FRAMENUM);
-        main_ui_->actionCopyAllVisibleItems->setEnabled(true);
-        main_ui_->actionCopyAllVisibleSelectedTreeItems->setEnabled(can_match_selected);
-        main_ui_->actionEditCopyDescription->setEnabled(can_match_selected);
-        main_ui_->actionEditCopyFieldName->setEnabled(can_match_selected);
-        main_ui_->actionEditCopyValue->setEnabled(can_match_selected);
-        main_ui_->actionEditCopyAsFilter->setEnabled(can_match_selected);
-//        set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/Copy/Description",
-//                             proto_can_match_selected(cf->finfo_selected, cf->edt));
-//        set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/Copy/Fieldname",
-//                             proto_can_match_selected(cf->finfo_selected, cf->edt));
-//        set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/Copy/Value",
-//                             proto_can_match_selected(cf->finfo_selected, cf->edt));
-//        set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/EditMenu/Copy/AsFilter",
-//                             proto_can_match_selected(cf->finfo_selected, cf->edt));
-
-        main_ui_->actionAnalyzeCreateAColumn->setEnabled(can_match_selected);
-
-        main_ui_->actionAnalyzeAAFSelected->setEnabled(can_match_selected);
-        main_ui_->actionAnalyzeAAFNotSelected->setEnabled(can_match_selected);
-        main_ui_->actionAnalyzeAAFAndSelected->setEnabled(can_match_selected);
-        main_ui_->actionAnalyzeAAFOrSelected->setEnabled(can_match_selected);
-        main_ui_->actionAnalyzeAAFAndNotSelected->setEnabled(can_match_selected);
-        main_ui_->actionAnalyzeAAFOrNotSelected->setEnabled(can_match_selected);
-
-        main_ui_->actionAnalyzePAFSelected->setEnabled(can_match_selected);
-        main_ui_->actionAnalyzePAFNotSelected->setEnabled(can_match_selected);
-        main_ui_->actionAnalyzePAFAndSelected->setEnabled(can_match_selected);
-        main_ui_->actionAnalyzePAFOrSelected->setEnabled(can_match_selected);
-        main_ui_->actionAnalyzePAFAndNotSelected->setEnabled(can_match_selected);
-        main_ui_->actionAnalyzePAFOrNotSelected->setEnabled(can_match_selected);
-
-        main_ui_->menuConversationFilter->clear();
-        for (GList *color_list_entry = color_conv_filter_list; color_list_entry; color_list_entry = g_list_next(color_list_entry)) {
-            color_conversation_filter_t* color_filter = (color_conversation_filter_t *)color_list_entry->data;
-            QAction *conv_action = main_ui_->menuConversationFilter->addAction(color_filter->display_name);
-
-            bool enable = false;
-            QString filter;
-            if (capture_file_.capFile()->edt) {
-                enable = color_filter->is_filter_valid(&capture_file_.capFile()->edt->pi);
-                filter = color_filter->build_filter_string(&capture_file_.capFile()->edt->pi);
-            }
-            conv_action->setEnabled(enable);
-            conv_action->setData(filter);
-            connect(conv_action, SIGNAL(triggered()), this, SLOT(applyConversationFilter()));
+
+        if (linked_frame > 0) {
+            main_ui_->actionGoGoToLinkedPacket->setData(linked_frame);
+        } else {
+            main_ui_->actionGoGoToLinkedPacket->setData(QVariant());
         }
+    }
 
-        main_ui_->actionViewExpandSubtrees->setEnabled(capture_file_.capFile()->finfo_selected->tree_type != -1);
+    // Always enable / disable the following items.
+    main_ui_->actionFileExportPacketBytes->setEnabled(have_field_info);
 
-//        prev_abbrev = g_object_get_data(G_OBJECT(ui_manager_tree_view_menu), "menu_abbrev");
-//        if (!prev_abbrev || (strcmp (prev_abbrev, abbrev) != 0)) {
-//            /* No previous protocol or protocol changed - update Protocol Preferences menu */
-//            module_t *prefs_module_p = prefs_find_module(abbrev);
-//            rebuild_protocol_prefs_menu (prefs_module_p, properties);
+    main_ui_->actionCopyAllVisibleItems->setEnabled(capture_file_.capFile() != NULL);
+    main_ui_->actionCopyAllVisibleSelectedTreeItems->setEnabled(can_match_selected);
+    main_ui_->actionEditCopyDescription->setEnabled(can_match_selected);
+    main_ui_->actionEditCopyFieldName->setEnabled(can_match_selected);
+    main_ui_->actionEditCopyValue->setEnabled(can_match_selected);
+    main_ui_->actionEditCopyAsFilter->setEnabled(can_match_selected);
 
-//            g_object_set_data(G_OBJECT(ui_manager_tree_view_menu), "menu_abbrev", g_strdup(abbrev));
-//            g_free (prev_abbrev);
-//        }
-    } else {
-//        set_menu_sensitivity(ui_manager_tree_view_menu,
-//                             "/TreeViewPopup/GotoCorrespondingPacket", FALSE);
-//        set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/Copy", FALSE);
-//        set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/CreateAColumn", FALSE);
-//        set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ApplyAsFilter", FALSE);
-//        set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/PrepareaFilter", FALSE);
-//        set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ColorizewithFilter", FALSE);
-//        set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ProtocolPreferences",
-//                             FALSE);
-//        set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/DisableProtocol", FALSE);
-//        set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ExpandSubtrees", FALSE);
-//        set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/WikiProtocolPage",
-//                             FALSE);
-//        set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/FilterFieldReference",
-//                             FALSE);
-        main_ui_->actionFileExportPacketBytes->setEnabled(false);
-//        set_menu_sensitivity(ui_manager_main_menubar,
-//                             "/Menubar/GoMenu/GotoCorrespondingPacket", FALSE);
-        if (capture_file_.capFile() != NULL)
-            main_ui_->actionCopyAllVisibleItems->setEnabled(true);
-        else
-            main_ui_->actionCopyAllVisibleItems->setEnabled(false);
-        main_ui_->actionCopyAllVisibleSelectedTreeItems->setEnabled(false);
-        main_ui_->actionEditCopyDescription->setEnabled(false);
-        main_ui_->actionEditCopyFieldName->setEnabled(false);
-        main_ui_->actionEditCopyValue->setEnabled(false);
-        main_ui_->actionEditCopyAsFilter->setEnabled(false);
-
-        main_ui_->actionAnalyzeCreateAColumn->setEnabled(false);
-
-        main_ui_->actionAnalyzeAAFSelected->setEnabled(false);
-        main_ui_->actionAnalyzeAAFNotSelected->setEnabled(false);
-        main_ui_->actionAnalyzeAAFAndSelected->setEnabled(false);
-        main_ui_->actionAnalyzeAAFOrSelected->setEnabled(false);
-        main_ui_->actionAnalyzeAAFAndNotSelected->setEnabled(false);
-        main_ui_->actionAnalyzeAAFOrNotSelected->setEnabled(false);
-
-        main_ui_->actionAnalyzePAFSelected->setEnabled(false);
-        main_ui_->actionAnalyzePAFNotSelected->setEnabled(false);
-        main_ui_->actionAnalyzePAFAndSelected->setEnabled(false);
-        main_ui_->actionAnalyzePAFOrSelected->setEnabled(false);
-        main_ui_->actionAnalyzePAFAndNotSelected->setEnabled(false);
-        main_ui_->actionAnalyzePAFOrNotSelected->setEnabled(false);
-
-        main_ui_->actionViewExpandSubtrees->setEnabled(false);
+    main_ui_->actionViewExpandSubtrees->setEnabled(have_subtree);
+
+    main_ui_->actionGoGoToLinkedPacket->setEnabled(is_framenum);
+
+    main_ui_->actionAnalyzeCreateAColumn->setEnabled(can_match_selected);
+
+    main_ui_->actionContextShowLinkedPacketInNewWindow->setEnabled(is_framenum);
+
+    main_ui_->actionContextWikiProtocolPage->setEnabled(can_open_url);
+    main_ui_->actionContextFilterFieldReference->setEnabled(can_open_url);
+
+
+    // Only enable / disable the following items if we have focus so that we
+    // don't clobber anything we may have set in setMenusForSelectedPacket.
+    if (!proto_tree_ || !proto_tree_->hasFocus()) return;
+
+    main_ui_->menuConversationFilter->clear();
+    for (GList *conv_filter_list_entry = conv_filter_list; conv_filter_list_entry; conv_filter_list_entry = g_list_next(conv_filter_list_entry)) {
+        conversation_filter_t* conv_filter = (conversation_filter_t *)conv_filter_list_entry->data;
+        QAction *conv_action = main_ui_->menuConversationFilter->addAction(conv_filter->display_name);
+
+        bool enable = false;
+        QString filter;
+        if (fi && capture_file_.capFile() && capture_file_.capFile()->edt) {
+            enable = conv_filter->is_filter_valid(&capture_file_.capFile()->edt->pi);
+            filter = conv_filter->build_filter_string(&capture_file_.capFile()->edt->pi);
+        }
+        conv_action->setEnabled(enable);
+        conv_action->setData(filter);
+        connect(conv_action, SIGNAL(triggered()), this, SLOT(applyConversationFilter()));
+    }
+
+    proto_tree_->colorizeMenu()->clear();
+    int i = 1;
+    foreach (QAction *cc_action, cc_actions) {
+        QAction *colorize_action = proto_tree_->colorizeMenu()->addAction(cc_action->icon(), cc_action->text());
+        colorize_action->setProperty(color_number_property_, i++);
+        colorize_action->setData(field_filter);
+        colorize_action->setEnabled(!field_filter.isEmpty());
+        connect(colorize_action, SIGNAL(triggered()), this, SLOT(colorizeWithFilter()));
     }
+
+    QAction *conv_rule_action = proto_tree_->colorizeMenu()->addAction(main_ui_->actionViewColorizeNewConversationRule->text());
+    conv_rule_action->setData(field_filter);
+    conv_rule_action->setEnabled(!field_filter.isEmpty());
+    connect(conv_rule_action, SIGNAL(triggered()), this, SLOT(colorizeWithFilter()));
+
+//    set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ResolveName",
+//                         frame_selected && (gbl_resolv_flags.mac_name || gbl_resolv_flags.network_name ||
+//                                            gbl_resolv_flags.transport_name || gbl_resolv_flags.concurrent_dns));
+
+
+    main_ui_->actionAnalyzeAAFSelected->setEnabled(can_match_selected);
+    main_ui_->actionAnalyzeAAFNotSelected->setEnabled(can_match_selected);
+    main_ui_->actionAnalyzeAAFAndSelected->setEnabled(can_match_selected);
+    main_ui_->actionAnalyzeAAFOrSelected->setEnabled(can_match_selected);
+    main_ui_->actionAnalyzeAAFAndNotSelected->setEnabled(can_match_selected);
+    main_ui_->actionAnalyzeAAFOrNotSelected->setEnabled(can_match_selected);
+
+    main_ui_->actionAnalyzePAFSelected->setEnabled(can_match_selected);
+    main_ui_->actionAnalyzePAFNotSelected->setEnabled(can_match_selected);
+    main_ui_->actionAnalyzePAFAndSelected->setEnabled(can_match_selected);
+    main_ui_->actionAnalyzePAFOrSelected->setEnabled(can_match_selected);
+    main_ui_->actionAnalyzePAFAndNotSelected->setEnabled(can_match_selected);
+    main_ui_->actionAnalyzePAFOrNotSelected->setEnabled(can_match_selected);
 }
 
 void MainWindow::interfaceSelectionChanged()
@@ -1363,47 +1379,43 @@ void MainWindow::startInterfaceCapture(bool valid)
 
 void MainWindow::redissectPackets()
 {
-    if (capture_file_.capFile())
+    if (capture_file_.capFile()) {
         cf_redissect_packets(capture_file_.capFile());
-    main_ui_->statusBar->expertUpdate();
+        main_ui_->statusBar->expertUpdate();
+    }
+
+    proto_free_deregistered_fields();
+}
+
+void MainWindow::checkDisplayFilter()
+{
+    if (!df_combo_box_->checkDisplayFilter()) {
+        g_free(CaptureFile::globalCapFile()->dfilter);
+        CaptureFile::globalCapFile()->dfilter = NULL;
+    }
 }
 
 void MainWindow::fieldsChanged()
 {
-    // Reload color filters
     color_filters_reload();
+    tap_listeners_dfilter_recompile();
 
-    // Syntax check filter
-    // TODO: Check if syntax filter is still valid after fields have changed
-    //       and update background color.
-    if (CaptureFile::globalCapFile()->dfilter) {
-        // Check if filter is still valid
-        dfilter_t *dfp = NULL;
-        if (!dfilter_compile(CaptureFile::globalCapFile()->dfilter, &dfp, NULL)) {
-            // TODO: Not valid, enable "Apply" button.
-            // TODO: get an error message and display it?
-            g_free(CaptureFile::globalCapFile()->dfilter);
-            CaptureFile::globalCapFile()->dfilter = NULL;
-        }
-        dfilter_free(dfp);
-    }
+    emit checkDisplayFilter();
 
     if (have_custom_cols(&CaptureFile::globalCapFile()->cinfo)) {
-        /* Recreate packet list according to new/changed/deleted fields */
-        packet_list_->redrawVisiblePackets();
-    } else if (CaptureFile::globalCapFile()->state != FILE_CLOSED) {
-        /* Redissect packets if we have any */
-        redissectPackets();
+        // Recreate packet list columns according to new/changed/deleted fields
+        packet_list_->fieldsChanged(CaptureFile::globalCapFile());
     }
 
-    proto_free_deregistered_fields();
+    emit reloadFields();
 }
 
 void MainWindow::showAccordionFrame(AccordionFrame *show_frame, bool toggle)
 {
     QList<AccordionFrame *>frame_list = QList<AccordionFrame *>()
             << main_ui_->goToFrame << main_ui_->searchFrame
-            << main_ui_->columnEditorFrame << main_ui_->preferenceEditorFrame;
+            << main_ui_->addressEditorFrame << main_ui_->columnEditorFrame
+            << main_ui_->preferenceEditorFrame;
 
     frame_list.removeAll(show_frame);
     foreach (AccordionFrame *af, frame_list) af->animatedHide();
@@ -1523,36 +1535,15 @@ void MainWindow::on_actionDisplayFilterExpression_triggered()
     dfe_dialog->show();
 }
 
-// On Qt4 + OS X with unifiedTitleAndToolBarOnMac set it's possible to make
-// the main window obnoxiously wide.
-
-// We might want to do something different here. We should probably merge
-// the dfilter and gui.filter_expressions code first.
-void MainWindow::addDisplayFilterButton(QString df_text)
+void MainWindow::on_actionNewDisplayFilterExpression_triggered()
 {
-    struct filter_expression *cur_fe = *pfilter_expression_head;
-    struct filter_expression *fe = g_new0(struct filter_expression, 1);
-
-    QFontMetrics fm = main_ui_->displayFilterToolBar->fontMetrics();
-    QString label = fm.elidedText(df_text, Qt::ElideMiddle, fm.height() * 15);
-
-    fe->enabled = TRUE;
-    fe->label = qstring_strdup(label);
-    fe->expression = qstring_strdup(df_text);
-
-    if (!cur_fe) {
-        *pfilter_expression_head = fe;
-    } else {
-        while (cur_fe->next) {
-            cur_fe = cur_fe->next;
-        }
-        cur_fe->next = fe;
-    }
-
-    prefs_main_write();
-    filterExpressionsChanged();
+    main_ui_->filterExpressionFrame->addExpression(df_combo_box_->lineEdit()->text());
+    showAccordionFrame(main_ui_->filterExpressionFrame);
 }
 
+// On Qt4 + OS X with unifiedTitleAndToolBarOnMac set it's possible to make
+// the main window obnoxiously wide.
+
 void MainWindow::displayFilterButtonClicked()
 {
     QAction *dfb_action = qobject_cast<QAction*>(sender());
@@ -1577,8 +1568,8 @@ void MainWindow::openTapParameterDialog(const QString cfg_str, const QString arg
 
     connect(tp_dialog, SIGNAL(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)),
             this, SLOT(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)));
-    connect(tp_dialog, SIGNAL(updateFilter(QString&, bool)),
-            this, SLOT(filterPackets(QString&, bool)));
+    connect(tp_dialog, SIGNAL(updateFilter(QString)),
+            df_combo_box_->lineEdit(), SLOT(setText(QString)));
     tp_dialog->show();
 }
 
@@ -1625,7 +1616,7 @@ void MainWindow::on_actionFileSaveAs_triggered()
 
 void MainWindow::on_actionFileSetListFiles_triggered()
 {
-    file_set_dialog_.exec();
+    file_set_dialog_.show();
 }
 
 void MainWindow::on_actionFileSetNextFile_triggered()
@@ -1701,12 +1692,12 @@ void MainWindow::on_actionFileExportPacketBytes_triggered()
             open_failure_alert_box(file_name.toUtf8().constData(), errno, TRUE);
             return;
         }
-        if (write(fd, data_p, capture_file_.capFile()->finfo_selected->length) < 0) {
+        if (ws_write(fd, data_p, capture_file_.capFile()->finfo_selected->length) < 0) {
             write_failure_alert_box(file_name.toUtf8().constData(), errno);
-            ::close(fd);
+            ws_close(fd);
             return;
         }
-        if (::close(fd) < 0) {
+        if (ws_close(fd) < 0) {
             write_failure_alert_box(file_name.toUtf8().constData(), errno);
             return;
         }
@@ -1775,11 +1766,11 @@ void MainWindow::on_actionFileExportSSLSessionKeys_triggered()
          */
         if (ws_write(fd, keylist, (unsigned int)strlen(keylist)) < 0) {
             write_failure_alert_box(file_name.toUtf8().constData(), errno);
-            ::close(fd);
+            ws_close(fd);
             g_free(keylist);
             return;
         }
-        if (::close(fd) < 0) {
+        if (ws_close(fd) < 0) {
             write_failure_alert_box(file_name.toUtf8().constData(), errno);
             g_free(keylist);
             return;
@@ -1845,21 +1836,23 @@ void MainWindow::actionEditCopyTriggered(MainWindow::CopySelected selection_type
 
     if (!capture_file_.capFile()) return;
 
+    field_info *finfo_selected = capture_file_.capFile()->finfo_selected;
+
     switch(selection_type) {
     case CopySelectedDescription:
-        if (capture_file_.capFile()->finfo_selected->rep &&
-                strlen (capture_file_.capFile()->finfo_selected->rep->representation) > 0) {
-            clip.append(capture_file_.capFile()->finfo_selected->rep->representation);
+        if (finfo_selected && finfo_selected->rep
+                && strlen (finfo_selected->rep->representation) > 0) {
+            clip.append(finfo_selected->rep->representation);
         }
         break;
     case CopySelectedFieldName:
-        if (capture_file_.capFile()->finfo_selected->hfinfo->abbrev != 0) {
-            clip.append(capture_file_.capFile()->finfo_selected->hfinfo->abbrev);
+        if (finfo_selected && finfo_selected->hfinfo->abbrev != 0) {
+            clip.append(finfo_selected->hfinfo->abbrev);
         }
         break;
     case CopySelectedValue:
-        if (capture_file_.capFile()->edt != 0) {
-            gchar* field_str = get_node_field_value(capture_file_.capFile()->finfo_selected, capture_file_.capFile()->edt);
+        if (finfo_selected && capture_file_.capFile()->edt != 0) {
+            gchar* field_str = get_node_field_value(finfo_selected, capture_file_.capFile()->edt);
             clip.append(field_str);
             g_free(field_str);
         }
@@ -1874,11 +1867,12 @@ void MainWindow::actionEditCopyTriggered(MainWindow::CopySelected selection_type
 
         break;
     case CopyAllVisibleSelectedTreeItems:
-        clip.append(proto_tree_->currentItem()->text(0));
-        clip.append("\n");
-
-        recursiveCopyProtoTreeItems(proto_tree_->currentItem(), clip, 1);
+        if (proto_tree_->selectedItems().count() > 0) {
+            clip.append(proto_tree_->currentItem()->text(0));
+            clip.append("\n");
 
+            recursiveCopyProtoTreeItems(proto_tree_->currentItem(), clip, 1);
+        }
         break;
     }
 
@@ -1934,6 +1928,9 @@ void MainWindow::on_actionEditFindPacket_triggered()
     previous_focus_ = wsApp->focusWidget();
     connect(previous_focus_, SIGNAL(destroyed()), this, SLOT(resetPreviousFocus()));
     showAccordionFrame(main_ui_->searchFrame, true);
+    if (main_ui_->searchFrame->isVisible()) {
+        main_ui_->searchFrame->setFocus();
+    }
 }
 
 void MainWindow::on_actionEditFindNext_triggered()
@@ -1948,17 +1945,23 @@ void MainWindow::on_actionEditFindPrevious_triggered()
 
 void MainWindow::on_actionEditMarkPacket_triggered()
 {
+    freeze();
     packet_list_->markFrame();
+    thaw();
 }
 
 void MainWindow::on_actionEditMarkAllDisplayed_triggered()
 {
+    freeze();
     packet_list_->markAllDisplayedFrames(true);
+    thaw();
 }
 
 void MainWindow::on_actionEditUnmarkAllDisplayed_triggered()
 {
+    freeze();
     packet_list_->markAllDisplayedFrames(false);
+    thaw();
 }
 
 void MainWindow::on_actionEditNextMark_triggered()
@@ -1975,17 +1978,23 @@ void MainWindow::on_actionEditPreviousMark_triggered()
 
 void MainWindow::on_actionEditIgnorePacket_triggered()
 {
+    freeze();
     packet_list_->ignoreFrame();
+    thaw();
 }
 
 void MainWindow::on_actionEditIgnoreAllDisplayed_triggered()
 {
+    freeze();
     packet_list_->ignoreAllDisplayedFrames(true);
+    thaw();
 }
 
 void MainWindow::on_actionEditUnignoreAllDisplayed_triggered()
 {
+    freeze();
     packet_list_->ignoreAllDisplayedFrames(false);
+    thaw();
 }
 
 void MainWindow::on_actionEditSetTimeReference_triggered()
@@ -2015,6 +2024,7 @@ void MainWindow::on_actionEditTimeShift_triggered()
     TimeShiftDialog ts_dialog(this, capture_file_.capFile());
     connect(this, SIGNAL(setCaptureFile(capture_file*)),
             &ts_dialog, SLOT(setCaptureFile(capture_file*)));
+    connect(&ts_dialog, SIGNAL(timeShifted()), packet_list_, SLOT(applyTimeShift()));
     ts_dialog.exec();
 }
 
@@ -2041,11 +2051,9 @@ void MainWindow::showPreferencesDialog(PreferencesDialog::PreferencesPane start_
     pref_dialog.setPane(start_pane);
     pref_dialog.exec();
 
-    // Emitting PacketDissectionChanged directly from PreferencesDialog
-    // can cause problems. Queue them up and emit them here.
-    foreach (WiresharkApplication::AppSignal app_signal, pref_dialog.appSignals()) {
-        wsApp->emitAppSignal(app_signal);
-    }
+    // Emitting PacketDissectionChanged directly from a QDialog can cause
+    // problems on OS X.
+    wsApp->flushAppSignals();
 }
 
 void MainWindow::showPreferencesDialog(QString module_name)
@@ -2055,11 +2063,9 @@ void MainWindow::showPreferencesDialog(QString module_name)
     pref_dialog.setPane(module_name);
     pref_dialog.exec();
 
-    // Emitting PacketDissectionChanged directly from PreferencesDialog
-    // can cause problems. Queue them up and emit them here.
-    foreach (WiresharkApplication::AppSignal app_signal, pref_dialog.appSignals()) {
-        wsApp->emitAppSignal(app_signal);
-    }
+    // Emitting PacketDissectionChanged directly from a QDialog can cause
+    // problems on OS X.
+    wsApp->flushAppSignals();
 }
 
 void MainWindow::on_actionEditPreferences_triggered()
@@ -2123,7 +2129,7 @@ void MainWindow::setTimestampFormat(QAction *action)
             cf_timestamp_auto_precision(capture_file_.capFile());
         }
         if (packet_list_) {
-            packet_list_->redrawVisiblePackets();
+            packet_list_->resetColumns();
         }
     }
 }
@@ -2145,7 +2151,7 @@ void MainWindow::setTimestampPrecision(QAction *action)
             cf_timestamp_auto_precision(capture_file_.capFile());
         }
         if (packet_list_) {
-            packet_list_->redrawVisiblePackets();
+            packet_list_->resetColumns();
         }
     }
 }
@@ -2164,8 +2170,21 @@ void MainWindow::on_actionViewTimeDisplaySecondsWithHoursAndMinutes_triggered(bo
         cf_timestamp_auto_precision(capture_file_.capFile());
     }
     if (packet_list_) {
-        packet_list_->redrawVisiblePackets();
+        packet_list_->resetColumns();
+    }
+}
+
+void MainWindow::on_actionViewEditResolvedName_triggered()
+{
+//    int column = packet_list_->selectedColumn();
+    int column = -1;
+
+    if (packet_list_->currentIndex().isValid()) {
+        column = packet_list_->currentIndex().column();
     }
+
+    main_ui_->addressEditorFrame->editAddresses(capture_file_, column);
+    showAccordionFrame(main_ui_->addressEditorFrame);
 }
 
 void MainWindow::setNameResolution()
@@ -2175,7 +2194,7 @@ void MainWindow::setNameResolution()
     gbl_resolv_flags.transport_name = main_ui_->actionViewNameResolutionTransport->isChecked() ? TRUE : FALSE;
 
     if (packet_list_) {
-        packet_list_->redrawVisiblePackets();
+        packet_list_->resetColumns();
     }
 }
 
@@ -2228,13 +2247,13 @@ void MainWindow::on_actionViewColorizePacketList_triggered(bool checked) {
     recent.packet_list_colorize = checked;
     color_filters_enable(checked);
     packet_list_->packetListModel()->resetColorized();
-    packet_list_->update();
 }
 
 void MainWindow::on_actionViewColoringRules_triggered()
 {
     ColoringRulesDialog coloring_rules_dialog(this);
-
+    connect(&coloring_rules_dialog, SIGNAL(accepted()),
+            packet_list_, SLOT(recolorPackets()));
     coloring_rules_dialog.exec();
 }
 
@@ -2249,26 +2268,26 @@ void MainWindow::colorizeConversation(bool create_rule)
         guint8 cc_num = cc_action->data().toUInt();
         gchar *filter = NULL;
 
-        const color_conversation_filter_t *color_filter = find_color_conversation_filter("tcp");
+        const conversation_filter_t *color_filter = find_conversation_filter("tcp");
         if ((color_filter != NULL) && (color_filter->is_filter_valid(pi)))
             filter = color_filter->build_filter_string(pi);
         if (filter == NULL) {
-            color_filter = find_color_conversation_filter("udp");
+            color_filter = find_conversation_filter("udp");
             if ((color_filter != NULL) && (color_filter->is_filter_valid(pi)))
                 filter = color_filter->build_filter_string(pi);
         }
         if (filter == NULL) {
-            color_filter = find_color_conversation_filter("ip");
+            color_filter = find_conversation_filter("ip");
             if ((color_filter != NULL) && (color_filter->is_filter_valid(pi)))
                 filter = color_filter->build_filter_string(pi);
         }
         if (filter == NULL) {
-            color_filter = find_color_conversation_filter("ipv6");
+            color_filter = find_conversation_filter("ipv6");
             if ((color_filter != NULL) && (color_filter->is_filter_valid(pi)))
                 filter = color_filter->build_filter_string(pi);
         }
         if (filter == NULL) {
-            color_filter = find_color_conversation_filter("eth");
+            color_filter = find_conversation_filter("eth");
             if ((color_filter != NULL) && (color_filter->is_filter_valid(pi)))
                 filter = color_filter->build_filter_string(pi);
         }
@@ -2279,6 +2298,8 @@ void MainWindow::colorizeConversation(bool create_rule)
 
         if (create_rule) {
             ColoringRulesDialog coloring_rules_dialog(this, filter);
+            connect(&coloring_rules_dialog, SIGNAL(accepted()),
+                    packet_list_, SLOT(recolorPackets()));
             coloring_rules_dialog.exec();
         } else {
             color_filters_set_tmp(cc_num, filter, FALSE);
@@ -2288,6 +2309,31 @@ void MainWindow::colorizeConversation(bool create_rule)
     setMenusForSelectedPacket();
 }
 
+void MainWindow::colorizeWithFilter()
+{
+    QAction *colorize_action = qobject_cast<QAction *>(sender());
+    if (!colorize_action) return;
+
+    QString filter = colorize_action->data().toString();
+    if (filter.isEmpty()) return;
+
+    bool ok = false;
+    int color_number = colorize_action->property(color_number_property_).toInt(&ok);
+
+    if (ok) {
+        // Assume "Color X"
+        color_filters_set_tmp(color_number, filter.toUtf8().constData(), FALSE);
+        packet_list_->recolorPackets();
+    } else {
+        // New coloring rule
+        ColoringRulesDialog coloring_rules_dialog(window(), filter);
+        connect(&coloring_rules_dialog, SIGNAL(accepted()),
+                packet_list_, SLOT(recolorPackets()));
+        coloring_rules_dialog.exec();
+    }
+    main_ui_->actionViewColorizeResetColorization->setEnabled(tmp_color_filters_used());
+}
+
 void MainWindow::on_actionViewColorizeResetColorization_triggered()
 {
     color_filters_reset_tmp();
@@ -2329,19 +2375,39 @@ void MainWindow::openPacketDialog(bool from_reference)
 
         connect(this, SIGNAL(monospaceFontChanged(QFont)),
                 packet_dialog, SIGNAL(monospaceFontChanged(QFont)));
+        connect(this, SIGNAL(closePacketDialogs()),
+                packet_dialog, SLOT(close()));
         zoomText(); // Emits monospaceFontChanged
 
         packet_dialog->show();
     }
 }
 
+void MainWindow::on_actionViewInternalsConversationHashTables_triggered()
+{
+    ConversationHashTablesDialog *conversation_hash_tables_dlg = new ConversationHashTablesDialog(this);
+    conversation_hash_tables_dlg->show();
+}
+
+void MainWindow::on_actionViewInternalsDissectorTables_triggered()
+{
+    DissectorTablesDialog *dissector_tables_dlg = new DissectorTablesDialog(this);
+    dissector_tables_dlg->show();
+}
+
+void MainWindow::on_actionViewInternalsSupportedProtocols_triggered()
+{
+    SupportedProtocolsDialog *supported_protocols_dlg = new SupportedProtocolsDialog(this);
+    supported_protocols_dlg->show();
+}
+
 void MainWindow::on_actionViewShowPacketInNewWindow_triggered()
 {
     openPacketDialog();
 }
 
 // This is only used in ProtoTree. Defining it here makes more sense.
-void MainWindow::on_actionViewShowPacketReferenceInNewWindow_triggered()
+void MainWindow::on_actionContextShowLinkedPacketInNewWindow_triggered()
 {
     openPacketDialog(true);
 }
@@ -2351,27 +2417,36 @@ void MainWindow::on_actionViewReload_triggered()
     cf_reload(CaptureFile::globalCapFile());
 }
 
+void MainWindow::on_actionViewReload_as_File_Format_or_Capture_triggered()
+{
+    capture_file *cf = CaptureFile::globalCapFile();
+
+    if (cf->open_type == WTAP_TYPE_AUTO)
+        cf->open_type = open_info_name_to_type("MIME Files Format");
+    else /* TODO: This should be latest format chosen by user */
+        cf->open_type = WTAP_TYPE_AUTO;
+
+    cf_reload(cf);
+}
+
+
 // Expand / collapse slots in proto_tree
 
 // Go Menu
 
 // Analyze Menu
 
-// XXX This should probably be somewhere else.
 void MainWindow::matchFieldFilter(FilterAction::Action action, FilterAction::ActionType filter_type)
 {
     QString field_filter;
-    char* tmp_field;
 
-    if (packet_list_->contextMenuActive()) {
+    if (packet_list_->contextMenuActive() || packet_list_->hasFocus()) {
         field_filter = packet_list_->getFilterFromRowAndColumn();
     } else if (capture_file_.capFile() && capture_file_.capFile()->finfo_selected) {
-        tmp_field = proto_construct_match_selected_string(capture_file_.capFile()->finfo_selected,
+        char *tmp_field = proto_construct_match_selected_string(capture_file_.capFile()->finfo_selected,
                                                        capture_file_.capFile()->edt);
         field_filter = QString(tmp_field);
         wmem_free(NULL, tmp_field);
-    } else {
-        return;
     }
 
     if (field_filter.isEmpty()) {
@@ -2396,6 +2471,19 @@ void MainWindow::on_actionAnalyzeDisplayFilters_triggered()
     display_filter_dlg_->activateWindow();
 }
 
+struct epan_uat;
+void MainWindow::on_actionAnalyzeDisplayFilterMacros_triggered()
+{
+    struct epan_uat* dfm_uat;
+    dfilter_macro_get_uat(&dfm_uat);
+    UatDialog uat_dlg(parentWidget(), dfm_uat);
+
+    uat_dlg.exec();
+    // Emitting PacketDissectionChanged directly from a QDialog can cause
+    // problems on OS X.
+    wsApp->flushAppSignals();
+}
+
 void MainWindow::on_actionAnalyzeCreateAColumn_triggered()
 {
     gint colnr = 0;
@@ -2487,6 +2575,16 @@ void MainWindow::on_actionAnalyzePAFOrNotSelected_triggered()
     matchFieldFilter(FilterAction::ActionPrepare, FilterAction::ActionTypeOrNot);
 }
 
+void MainWindow::on_actionAnalyzeEnabledProtocols_triggered()
+{
+    EnabledProtocolsDialog enable_proto_dialog(this);
+    enable_proto_dialog.exec();
+
+    // Emitting PacketDissectionChanged directly from a QDialog can cause
+    // problems on OS X.
+    wsApp->flushAppSignals();
+}
+
 void MainWindow::on_actionAnalyzeDecodeAs_triggered()
 {
     QAction *da_action = qobject_cast<QAction*>(sender());
@@ -2499,15 +2597,47 @@ void MainWindow::on_actionAnalyzeDecodeAs_triggered()
     connect(this, SIGNAL(setCaptureFile(capture_file*)),
             &da_dialog, SLOT(setCaptureFile(capture_file*)));
     da_dialog.exec();
+
+    // Emitting PacketDissectionChanged directly from a QDialog can cause
+    // problems on OS X.
+    wsApp->flushAppSignals();
+}
+
+void MainWindow::on_actionAnalyzeReloadLuaPlugins_triggered()
+{
+#ifdef HAVE_LUA
+    if (wsApp->isReloadingLua())
+        return;
+
+    wsApp->setReloadingLua(true);
+
+    wslua_reload_plugins(NULL, NULL);
+    funnel_statistics_reload_menus();
+    reloadDynamicMenus();
+    closePacketDialogs();
+
+    // Preferences may have been deleted so close all widgets using prefs
+    proto_tree_->closeContextMenu();
+    main_ui_->preferenceEditorFrame->animatedHide();
+
+    char *gdp_path, *dp_path;
+    wsApp->readConfigurationFiles(&gdp_path, &dp_path, true);
+
+    fieldsChanged();
+    redissectPackets();
+
+    wsApp->setReloadingLua(false);
+    SimpleDialog::displayQueuedMessages();
+#endif
 }
 
 void MainWindow::openFollowStreamDialog(follow_type_t type) {
     FollowStreamDialog *fsd = new FollowStreamDialog(*this, capture_file_, type);
-    connect(fsd, SIGNAL(updateFilter(QString&, bool)), this, SLOT(filterPackets(QString&, bool)));
+    connect(fsd, SIGNAL(updateFilter(QString, bool)), this, SLOT(filterPackets(QString, bool)));
     connect(fsd, SIGNAL(goToPacket(int)), packet_list_, SLOT(goToPacket(int)));
 
-    fsd->follow(getFilter());
     fsd->show();
+    fsd->follow(getFilter());
 }
 
 void MainWindow::on_actionAnalyzeFollowTCPStream_triggered()
@@ -2528,8 +2658,8 @@ void MainWindow::on_actionAnalyzeFollowSSLStream_triggered()
 void MainWindow::openSCTPAllAssocsDialog()
 {
     SCTPAllAssocsDialog *sctp_dialog = new SCTPAllAssocsDialog(this, capture_file_.capFile());
-    connect(sctp_dialog, SIGNAL(filterPackets(QString&,bool)),
-            this, SLOT(filterPackets(QString&,bool)));
+    connect(sctp_dialog, SIGNAL(filterPackets(QString,bool)),
+            this, SLOT(filterPackets(QString,bool)));
     connect(this, SIGNAL(setCaptureFile(capture_file*)),
             sctp_dialog, SLOT(setCaptureFile(capture_file*)));
     sctp_dialog->fillTable();
@@ -2555,8 +2685,8 @@ void MainWindow::on_actionSCTPShowAllAssociations_triggered()
 void MainWindow::on_actionSCTPAnalyseThisAssociation_triggered()
 {
     SCTPAssocAnalyseDialog *sctp_analyse = new SCTPAssocAnalyseDialog(this, NULL, capture_file_.capFile());
-    connect(sctp_analyse, SIGNAL(filterPackets(QString&,bool)),
-            this, SLOT(filterPackets(QString&,bool)));
+    connect(sctp_analyse, SIGNAL(filterPackets(QString,bool)),
+            this, SLOT(filterPackets(QString,bool)));
 
     if (sctp_analyse->isMinimized() == true)
     {
@@ -2581,6 +2711,21 @@ void MainWindow::on_actionSCTPFilterThisAssociation_triggered()
     }
 }
 
+// -z wlan,stat
+void MainWindow::statCommandWlanStatistics(const char *arg, void *)
+{
+    WlanStatisticsDialog *wlan_stats_dlg = new WlanStatisticsDialog(*this, capture_file_, arg);
+    connect(wlan_stats_dlg, SIGNAL(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)),
+            this, SLOT(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)));
+    wlan_stats_dlg->show();
+}
+
+void MainWindow::on_actionWirelessWlanStatistics_triggered()
+{
+    statCommandWlanStatistics(NULL, NULL);
+}
+
+// -z expert
 void MainWindow::statCommandExpertInfo(const char *, void *)
 {
     ExpertInfoDialog *expert_dialog = new ExpertInfoDialog(*this, capture_file_);
@@ -2649,6 +2794,20 @@ void MainWindow::on_actionStatisticsTcpStreamWindowScaling_triggered()
     openTcpStreamDialog(GRAPH_WSCALE);
 }
 
+// -z mcast,stat
+void MainWindow::statCommandMulticastStatistics(const char *arg, void *)
+{
+    MulticastStatisticsDialog *mcast_stats_dlg = new MulticastStatisticsDialog(*this, capture_file_, arg);
+    connect(mcast_stats_dlg, SIGNAL(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)),
+            this, SLOT(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)));
+    mcast_stats_dlg->show();
+}
+
+void MainWindow::on_actionStatisticsUdpMulticastStreams_triggered()
+{
+    statCommandMulticastStatistics(NULL, NULL);
+}
+
 void MainWindow::openStatisticsTreeDialog(const gchar *abbr)
 {
     StatsTreeDialog *st_dialog = new StatsTreeDialog(*this, capture_file_, abbr);
@@ -2781,6 +2940,7 @@ void MainWindow::on_actionStatisticsCollectd_triggered()
     openStatisticsTreeDialog("collectd");
 }
 
+// -z conv,...
 void MainWindow::statCommandConversations(const char *arg, void *userdata)
 {
     ConversationDialog *conv_dialog = new ConversationDialog(*this, capture_file_, GPOINTER_TO_INT(userdata), arg);
@@ -2798,6 +2958,7 @@ void MainWindow::on_actionStatisticsConversations_triggered()
     statCommandConversations(NULL, NULL);
 }
 
+// -z endpoints,...
 void MainWindow::statCommandEndpoints(const char *arg, void *userdata)
 {
     EndpointDialog *endp_dialog = new EndpointDialog(*this, capture_file_, GPOINTER_TO_INT(userdata), arg);
@@ -2840,10 +3001,12 @@ void MainWindow::on_actionStatisticsPacketLengths_triggered()
     openStatisticsTreeDialog("plen");
 }
 
+// -z io,stat
 void MainWindow::statCommandIOGraph(const char *, void *)
 {
     IOGraphDialog *iog_dialog = new IOGraphDialog(*this, capture_file_);
     connect(iog_dialog, SIGNAL(goToPacket(int)), packet_list_, SLOT(goToPacket(int)));
+    connect(this, SIGNAL(reloadFields()), iog_dialog, SLOT(reloadFields()));
     iog_dialog->show();
 }
 
@@ -2883,8 +3046,8 @@ void MainWindow::openVoipCallsDialog(bool all_flows)
     VoipCallsDialog *voip_calls_dialog = new VoipCallsDialog(*this, capture_file_, all_flows);
     connect(voip_calls_dialog, SIGNAL(goToPacket(int)),
             packet_list_, SLOT(goToPacket(int)));
-    connect(voip_calls_dialog, SIGNAL(updateFilter(QString&, bool)),
-            this, SLOT(filterPackets(QString&, bool)));
+    connect(voip_calls_dialog, SIGNAL(updateFilter(QString, bool)),
+            this, SLOT(filterPackets(QString, bool)));
     voip_calls_dialog->show();
 }
 
@@ -2893,11 +3056,83 @@ void MainWindow::on_actionTelephonyVoipCalls_triggered()
     openVoipCallsDialog();
 }
 
+void MainWindow::on_actionTelephonyGsmMapSummary_triggered()
+{
+    GsmMapSummaryDialog *gms_dialog = new GsmMapSummaryDialog(*this, capture_file_);
+    gms_dialog->show();
+}
+
+void MainWindow::on_actionTelephonyIax2StreamAnalysis_triggered()
+{
+    Iax2AnalysisDialog *iax2_analysis_dialog = new  Iax2AnalysisDialog(*this, capture_file_);
+    connect(iax2_analysis_dialog, SIGNAL(goToPacket(int)),
+            packet_list_, SLOT(goToPacket(int)));
+    iax2_analysis_dialog->show();
+}
+
 void MainWindow::on_actionTelephonyISUPMessages_triggered()
 {
     openStatisticsTreeDialog("isup_msg");
 }
 
+// -z mac-lte,stat
+void MainWindow::statCommandLteMacStatistics(const char *arg, void *)
+{
+    LteMacStatisticsDialog *lte_mac_stats_dlg = new LteMacStatisticsDialog(*this, capture_file_, arg);
+    connect(lte_mac_stats_dlg, SIGNAL(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)),
+            this, SLOT(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)));
+    lte_mac_stats_dlg->show();
+}
+
+void MainWindow::on_actionTelephonyLteMacStatistics_triggered()
+{
+    statCommandLteMacStatistics(NULL, NULL);
+}
+
+void MainWindow::statCommandLteRlcStatistics(const char *arg, void *)
+{
+    LteRlcStatisticsDialog *lte_rlc_stats_dlg = new LteRlcStatisticsDialog(*this, capture_file_, arg);
+    connect(lte_rlc_stats_dlg, SIGNAL(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)),
+            this, SLOT(filterAction(QString&,FilterAction::Action,FilterAction::ActionType)));
+    // N.B. It is necessary for the RLC Statistics window to launch the RLC graph in this way, to ensure
+    // that the goToPacket() signal/slot connection gets set up...
+    connect(lte_rlc_stats_dlg, SIGNAL(launchRLCGraph(bool, guint16, guint8, guint16, guint16, guint8)),
+            this, SLOT(launchRLCGraph(bool, guint16, guint8, guint16, guint16, guint8)));
+
+    lte_rlc_stats_dlg->show();
+}
+
+void MainWindow::on_actionTelephonyLteRlcStatistics_triggered()
+{
+    statCommandLteRlcStatistics(NULL, NULL);
+}
+
+void MainWindow::launchRLCGraph(bool channelKnown,
+                                guint16 ueid, guint8 rlcMode,
+                                guint16 channelType, guint16 channelId, guint8 direction)
+{
+    LteRlcGraphDialog *lrg_dialog = new LteRlcGraphDialog(*this, capture_file_, channelKnown);
+    connect(lrg_dialog, SIGNAL(goToPacket(int)), packet_list_, SLOT(goToPacket(int)));
+    // This is a bit messy, but wanted to hide these parameters from users of
+    // on_actionTelephonyLteRlcGraph_triggered().
+    if (channelKnown) {
+        lrg_dialog->setChannelInfo(ueid, rlcMode, channelType, channelId, direction);
+    }
+    lrg_dialog->show();
+}
+
+void MainWindow::on_actionTelephonyLteRlcGraph_triggered()
+{
+    // We don't yet know the channel.
+    launchRLCGraph(false, 0, 0, 0, 0, 0);
+}
+
+void MainWindow::on_actionTelephonyMtp3Summary_triggered()
+{
+    Mtp3SummaryDialog *mtp3s_dialog = new Mtp3SummaryDialog(*this, capture_file_);
+    mtp3s_dialog->show();
+}
+
 void MainWindow::on_actionTelephonyRTPStreams_triggered()
 {
     RtpStreamDialog *rtp_stream_dialog = new  RtpStreamDialog(*this, capture_file_);
@@ -2905,8 +3140,8 @@ void MainWindow::on_actionTelephonyRTPStreams_triggered()
             packet_list_, SLOT(redrawVisiblePackets()));
     connect(rtp_stream_dialog, SIGNAL(goToPacket(int)),
             packet_list_, SLOT(goToPacket(int)));
-    connect(rtp_stream_dialog, SIGNAL(updateFilter(QString&, bool)),
-            this, SLOT(filterPackets(QString&, bool)));
+    connect(rtp_stream_dialog, SIGNAL(updateFilter(QString, bool)),
+            this, SLOT(filterPackets(QString, bool)));
     rtp_stream_dialog->show();
 }
 
@@ -2940,33 +3175,33 @@ void MainWindow::on_actionTelephonySipFlows_triggered()
 
 // Bluetooth Menu
 
-void MainWindow::on_actionATT_Server_Attributes_triggered()
+void MainWindow::on_actionBluetoothATT_Server_Attributes_triggered()
 {
     BluetoothAttServerAttributesDialog *bluetooth_att_sever_attributes_dialog = new BluetoothAttServerAttributesDialog(*this, capture_file_);
     connect(bluetooth_att_sever_attributes_dialog, SIGNAL(goToPacket(int)),
             packet_list_, SLOT(goToPacket(int)));
-    connect(bluetooth_att_sever_attributes_dialog, SIGNAL(updateFilter(QString&, bool)),
-            this, SLOT(filterPackets(QString&, bool)));
+    connect(bluetooth_att_sever_attributes_dialog, SIGNAL(updateFilter(QString, bool)),
+            this, SLOT(filterPackets(QString, bool)));
     bluetooth_att_sever_attributes_dialog->show();
 }
 
-void MainWindow::on_actionDevices_triggered()
+void MainWindow::on_actionBluetoothDevices_triggered()
 {
     BluetoothDevicesDialog *bluetooth_devices_dialog = new BluetoothDevicesDialog(*this, capture_file_);
     connect(bluetooth_devices_dialog, SIGNAL(goToPacket(int)),
             packet_list_, SLOT(goToPacket(int)));
-    connect(bluetooth_devices_dialog, SIGNAL(updateFilter(QString&, bool)),
-            this, SLOT(filterPackets(QString&, bool)));
+    connect(bluetooth_devices_dialog, SIGNAL(updateFilter(QString, bool)),
+            this, SLOT(filterPackets(QString, bool)));
     bluetooth_devices_dialog->show();
 }
 
-void MainWindow::on_actionHCI_Summary_triggered()
+void MainWindow::on_actionBluetoothHCI_Summary_triggered()
 {
     BluetoothHciSummaryDialog *bluetooth_hci_summary_dialog = new BluetoothHciSummaryDialog(*this, capture_file_);
     connect(bluetooth_hci_summary_dialog, SIGNAL(goToPacket(int)),
             packet_list_, SLOT(goToPacket(int)));
-    connect(bluetooth_hci_summary_dialog, SIGNAL(updateFilter(QString&, bool)),
-            this, SLOT(filterPackets(QString&, bool)));
+    connect(bluetooth_hci_summary_dialog, SIGNAL(updateFilter(QString, bool)),
+            this, SLOT(filterPackets(QString, bool)));
     bluetooth_hci_summary_dialog->show();
 }
 
@@ -3085,9 +3320,79 @@ void MainWindow::on_actionGoGoToPacket_triggered() {
     }
 }
 
+void MainWindow::on_actionGoGoToLinkedPacket_triggered()
+{
+    QAction *gta = qobject_cast<QAction*>(sender());
+    if (!gta) return;
+
+    bool ok = false;
+    int packet_num = gta->data().toInt(&ok);
+    if (!ok) return;
+
+    packet_list_->goToPacket(packet_num);
+}
+
+// gtk/main_menubar.c:goto_conversation_frame
+void MainWindow::goToConversationFrame(bool go_next) {
+    gchar     *filter       = NULL;
+    dfilter_t *dfcode       = NULL;
+    gboolean   found_packet = FALSE;
+    packet_info *pi = &(capture_file_.capFile()->edt->pi);
+    conversation_filter_t* conv_filter;
+
+    /* Try to build a conversation
+     * filter in the order TCP, UDP, IP, Ethernet and apply the
+     * coloring */
+    conv_filter = find_conversation_filter("tcp");
+    if ((conv_filter != NULL) && (conv_filter->is_filter_valid(pi)))
+        filter = conv_filter->build_filter_string(pi);
+    conv_filter = find_conversation_filter("udp");
+    if ((conv_filter != NULL) && (conv_filter->is_filter_valid(pi)))
+        filter = conv_filter->build_filter_string(pi);
+    conv_filter = find_conversation_filter("ip");
+    if ((conv_filter != NULL) && (conv_filter->is_filter_valid(pi)))
+        filter = conv_filter->build_filter_string(pi);
+    conv_filter = find_conversation_filter("ipv6");
+    if ((conv_filter != NULL) && (conv_filter->is_filter_valid(pi)))
+        filter = conv_filter->build_filter_string(pi);
+
+    if( filter == NULL ) {
+        main_ui_->statusBar->pushTemporaryStatus(tr("Unable to build conversation filter."));
+        g_free(filter);
+        return;
+    }
+
+    if (!dfilter_compile(filter, &dfcode, NULL)) {
+        /* The attempt failed; report an error. */
+        main_ui_->statusBar->pushTemporaryStatus(tr("Error compiling filter for this conversation."));
+        g_free(filter);
+        return;
+    }
+
+    found_packet = cf_find_packet_dfilter(capture_file_.capFile(), dfcode, go_next ? SD_FORWARD : SD_BACKWARD);
+
+    if (!found_packet) {
+        /* We didn't find a packet */
+        main_ui_->statusBar->pushTemporaryStatus(tr("No previous/next packet in conversation."));
+    }
+
+    dfilter_free(dfcode);
+    g_free(filter);
+}
+
+void MainWindow::on_actionGoNextConversationPacket_triggered()
+{
+    goToConversationFrame(true);
+}
+
+void MainWindow::on_actionGoPreviousConversationPacket_triggered()
+{
+    goToConversationFrame(false);
+}
+
 void MainWindow::on_actionGoAutoScroll_toggled(bool checked)
 {
-    packet_list_->setAutoScroll(checked);
+    packet_list_->setVerticalAutoScroll(checked);
 }
 
 void MainWindow::resetPreviousFocus() {
@@ -3106,11 +3411,8 @@ void MainWindow::on_goToCancel_clicked()
 
 void MainWindow::on_goToGo_clicked()
 {
-    int packet_num = main_ui_->goToLineEdit->text().toInt();
+    gotoFrame(main_ui_->goToLineEdit->text().toInt());
 
-    if (packet_num > 0) {
-        packet_list_->goToPacket(packet_num);
-    }
     on_goToCancel_clicked();
 }
 
@@ -3155,7 +3457,8 @@ void MainWindow::on_actionCaptureStart_triggered()
     }
 
     /* XXX - will closing this remove a temporary file? */
-    if (testCaptureFileClose(FALSE, *new QString(" before starting a new capture"))) {
+    QString before_what(tr(" before starting a new capture"));
+    if (testCaptureFileClose(FALSE, before_what)) {
         startCapture();
     } else {
         // simply clicking the button sets it to 'checked' even though we've
@@ -3232,7 +3535,9 @@ void MainWindow::on_actionCaptureOptions_triggered()
 
 void MainWindow::on_actionCaptureRefreshInterfaces_triggered()
 {
+    main_ui_->actionCaptureRefreshInterfaces->setEnabled(false);
     wsApp->refreshLocalInterfaces();
+    main_ui_->actionCaptureRefreshInterfaces->setEnabled(true);
 }
 #endif
 
@@ -3263,6 +3568,14 @@ void MainWindow::externalMenuItem_triggered()
     }
 }
 
+void MainWindow::gotoFrame(int packet_num)
+{
+    if ( packet_num > 0 )
+    {
+        packet_list_->goToPacket(packet_num);
+    }
+}
+
 #ifdef HAVE_EXTCAP
 void MainWindow::extcap_options_finished(int result)
 {
@@ -3286,6 +3599,103 @@ void MainWindow::showExtcapOptionsDialog(QString &device_name)
 }
 #endif
 
+// Q_DECLARE_METATYPE(field_info *) called in proto_tree.h
+
+void MainWindow::on_actionContextCopyBytesHexTextDump_triggered()
+{
+    QAction *ca = qobject_cast<QAction*>(sender());
+    if (!ca) return;
+
+    field_info *fi = ca->data().value<field_info *>();
+
+    byte_view_tab_->copyData(ByteViewTab::copyDataHexTextDump, fi);
+}
+
+void MainWindow::on_actionContextCopyBytesHexDump_triggered()
+{
+    QAction *ca = qobject_cast<QAction*>(sender());
+    if (!ca) return;
+
+    field_info *fi = ca->data().value<field_info *>();
+
+    byte_view_tab_->copyData(ByteViewTab::copyDataHexDump, fi);
+}
+
+void MainWindow::on_actionContextCopyBytesPrintableText_triggered()
+{
+    QAction *ca = qobject_cast<QAction*>(sender());
+    if (!ca) return;
+
+    field_info *fi = ca->data().value<field_info *>();
+
+    byte_view_tab_->copyData(ByteViewTab::copyDataPrintableText, fi);
+}
+
+void MainWindow::on_actionContextCopyBytesHexStream_triggered()
+{
+    QAction *ca = qobject_cast<QAction*>(sender());
+    if (!ca) return;
+
+    field_info *fi = ca->data().value<field_info *>();
+
+    byte_view_tab_->copyData(ByteViewTab::copyDataHexStream, fi);
+}
+
+void MainWindow::on_actionContextCopyBytesBinary_triggered()
+{
+    QAction *ca = qobject_cast<QAction*>(sender());
+    if (!ca) return;
+
+    field_info *fi = ca->data().value<field_info *>();
+
+    byte_view_tab_->copyData(ByteViewTab::copyDataBinary, fi);
+}
+
+void MainWindow::on_actionContextWikiProtocolPage_triggered()
+{
+    QAction *wa = qobject_cast<QAction*>(sender());
+    if (!wa) return;
+
+    bool ok = false;
+    int field_id = wa->data().toInt(&ok);
+    if (!ok) return;
+
+    const QString proto_abbrev = proto_registrar_get_abbrev(field_id);
+
+    int ret = QMessageBox::question(this, wsApp->windowTitleString(tr("Wiki Page for %1").arg(proto_abbrev)),
+                                   tr("<p>The Wireshark Wiki is maintained by the community.</p>"
+                                      "<p>The page you are about to load might be wonderful, "
+                                      "incomplete, wrong, or nonexistent.</p>"
+                                      "<p>Proceed to the wiki?</p>"),
+                                   QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
+
+    if (ret != QMessageBox::Yes) return;
+
+    QUrl wiki_url = QString("https://wiki.wireshark.org/Protocols/%1").arg(proto_abbrev);
+    QDesktopServices::openUrl(wiki_url);
+}
+
+void MainWindow::on_actionContextFilterFieldReference_triggered()
+{
+    QAction *wa = qobject_cast<QAction*>(sender());
+    if (!wa) return;
+
+    bool ok = false;
+    int field_id = wa->data().toInt(&ok);
+    if (!ok) return;
+
+    const QString proto_abbrev = proto_registrar_get_abbrev(field_id);
+
+    QUrl dfref_url = QString("https://www.wireshark.org/docs/dfref/%1/%2")
+            .arg(proto_abbrev[0])
+            .arg(proto_abbrev);
+    QDesktopServices::openUrl(dfref_url);
+}
+
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+
 /*
  * Editor modelines
  *