Rename ui_util.h -> ws_ui_util.h
[gd/wireshark/.git] / ui / qt / main_window.h
index 6b6a8c93dd96bd9c4a860f6b81bca579e2afd674..0ab3614e4da1b01819fac12363dcf05f2cdbf8d1 100644 (file)
 
 #include "file.h"
 
-#include "ui/ui_util.h"
+#include "ui/ws_ui_util.h"
+#include "ui/iface_toolbar.h"
 
 #include <epan/prefs.h>
 #include <epan/plugin_if.h>
+#include <epan/timestamp.h>
 
 #ifdef HAVE_LIBPCAP
 #include "capture_opts.h"
 #include "capture_file.h"
 #include "capture_file_dialog.h"
 #include "capture_file_properties_dialog.h"
-#include "capture_interfaces_dialog.h"
-#include "display_filter_combo.h"
-#include "file_set_dialog.h"
+#include <ui/qt/widgets/display_filter_combo.h>
 #include "filter_action.h"
 #include "follow_stream_dialog.h"
 #include "preferences_dialog.h"
 
 class AccordionFrame;
 class ByteViewTab;
+class CaptureInterfacesDialog;
+class FileSetDialog;
+class FilterDialog;
 class FunnelStatistics;
 class MainWelcome;
 class PacketList;
 class ProtoTree;
 class WirelessFrame;
+class DragDropToolBar;
 
 class QAction;
 class QActionGroup;
@@ -74,6 +78,12 @@ namespace Ui {
     class MainWindow;
 }
 
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+Q_DECLARE_METATYPE(QToolBar *)
+#endif
+Q_DECLARE_METATYPE(ts_type)
+Q_DECLARE_METATYPE(ts_precision)
+
 class MainWindow : public QMainWindow
 {
     Q_OBJECT
@@ -86,16 +96,28 @@ public:
     QString getFilter();
 #ifdef HAVE_LIBPCAP
     capture_session *captureSession() { return &cap_session_; }
+    info_data_t *captureInfoData() { return &info_data_; }
 #endif
 
     virtual QMenu *createPopupMenu();
 
+    void gotoFrame(int packet_num);
+    CaptureFile *captureFile() { return &capture_file_; }
+
+    void removeAdditionalToolbar(QString toolbarName);
+
+    void addInterfaceToolbar(const iface_toolbar *toolbar_entry);
+    void removeInterfaceToolbar(const gchar *menu_title);
+
 protected:
-    bool eventFilter(QObject *obj, QEvent *event);
-    void keyPressEvent(QKeyEvent *event);
-    void closeEvent(QCloseEvent *event);
-    void dragEnterEvent(QDragEnterEvent *event);
-    void dropEvent(QDropEvent *event);
+    virtual bool eventFilter(QObject *obj, QEvent *event);
+    virtual void keyPressEvent(QKeyEvent *event);
+    virtual void closeEvent(QCloseEvent *event);
+    virtual void dragEnterEvent(QDragEnterEvent *event);
+    virtual void dropEvent(QDropEvent *event);
+    virtual void changeEvent(QEvent* event);
+    virtual void resizeEvent(QResizeEvent *event);
+
 
 private:
     // XXX Move to FilterUtils
@@ -116,8 +138,14 @@ private:
         CopySelectedValue
     };
 
+    enum FileCloseContext {
+        Default,
+        Quit,
+        Restart,
+        Reload
+    };
+
     Ui::MainWindow *main_ui_;
-    QMenu *open_recent_menu_;
     QSplitter master_split_;
     QSplitter extra_split_;
     QVector<unsigned> cur_layout_;
@@ -131,20 +159,29 @@ private:
     PacketList *packet_list_;
     ProtoTree *proto_tree_;
     QWidget *previous_focus_;
-    FileSetDialog file_set_dialog_;
+    FileSetDialog *file_set_dialog_;
     ByteViewTab *byte_view_tab_;
     QWidget empty_pane_;
     QActionGroup *show_hide_actions_;
     QActionGroup *time_display_actions_;
     QActionGroup *time_precision_actions_;
     FunnelStatistics *funnel_statistics_;
+    QList<QPair<QAction *, bool> > freeze_actions_;
+    QWidget *freeze_focus_;
+    QMap<QAction *, ts_type> td_actions;
+    QMap<QAction *, ts_precision> tp_actions;
+    DragDropToolBar *filter_expression_toolbar_;
+    bool was_maximized_;
 
     bool capture_stopping_;
     bool capture_filter_valid_;
 #ifdef HAVE_LIBPCAP
     capture_session cap_session_;
-    CaptureInterfacesDialog capture_interfaces_dialog_;
+    CaptureInterfacesDialog *capture_interfaces_dialog_;
+    info_data_t info_data_;
 #endif
+    FilterDialog *display_filter_dlg_;
+    FilterDialog *capture_filter_dlg_;
 
     // Pipe input
     gint                pipe_source_;
@@ -157,36 +194,50 @@ private:
     QSocketNotifier *pipe_notifier_;
 #endif
 
+#if defined(Q_OS_MAC) && QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
+    QMenu *dock_menu_;
+#endif
+
+#ifdef HAVE_SOFTWARE_UPDATE
+    QAction *update_action_;
+#endif
+
+    QPoint dragStartPosition;
+
     QWidget* getLayoutWidget(layout_pane_content_e type);
 
+    void freeze();
+    void thaw();
+
     void mergeCaptureFile();
     void importCaptureFile();
-    void saveCaptureFile(capture_file *cf, bool dont_reopen);
-    void saveAsCaptureFile(capture_file *cf, bool must_support_comments = false, bool dont_reopen = false);
+    bool saveCaptureFile(capture_file *cf, bool dont_reopen);
+    bool saveAsCaptureFile(capture_file *cf, bool must_support_comments = false, bool dont_reopen = false);
     void exportSelectedPackets();
     void exportDissections(export_type_e export_type);
 
     void fileAddExtension(QString &file_name, int file_type, bool compressed);
-    bool testCaptureFileClose(bool from_quit = false, QString& before_what = *new QString());
+    bool testCaptureFileClose(QString before_what, FileCloseContext context = Default);
     void captureStop();
 
     void initMainToolbarIcons();
     void initShowHideMainWidgets();
     void initTimeDisplayFormatMenu();
     void initTimePrecisionFormatMenu();
+    void initFreezeActions();
 
-    void setTitlebarForSelectedTreeRow();
-    void setTitlebarForCaptureFile();
     void setTitlebarForCaptureInProgress();
     void setMenusForCaptureFile(bool force_disable = false);
     void setMenusForCaptureInProgress(bool capture_in_progress = false);
     void setMenusForCaptureStopping();
     void setForCapturedPackets(bool have_captured_packets);
     void setMenusForFileSet(bool enable_list_files);
+    void setWindowIcon(const QIcon &icon);
+    QString replaceWindowTitleVariables(QString title);
 
     void externalMenuHelper(ext_menu_t * menu, QMenu  * subMenu, gint depth);
 
-    void setForCaptureInProgress(gboolean capture_in_progress = false);
+    void setForCaptureInProgress(bool capture_in_progress = false, GArray *ifaces = NULL);
     QMenu* findOrAddMenu(QMenu *parent_menu, QString& menu_text);
 
     void recursiveCopyProtoTreeItems(QTreeWidgetItem *item, QString &clip, int ident_level);
@@ -194,6 +245,8 @@ private:
 
     void addMenuActions(QList<QAction *> &actions, int menu_group);
     void removeMenuActions(QList<QAction *> &actions, int menu_group);
+    void goToConversationFrame(bool go_next);
+    void colorizeWithFilter(QByteArray filter, int color_number = -1);
 
 signals:
     void setCaptureFile(capture_file *cf);
@@ -202,6 +255,9 @@ signals:
     void monospaceFontChanged(const QFont &mono_font);
     void closePacketDialogs();
     void reloadFields();
+    void packetInfoChanged(struct _packet_info *pinfo);
+    void fieldFilterChanged(const QByteArray field_filter);
+    void filterAction(QString filter, FilterAction::Action action, FilterAction::ActionType type);
 
 public slots:
     // in main_window_slots.cpp
@@ -213,14 +269,18 @@ public slots:
      * @return True on success, false on failure.
      */
     // XXX We might want to return a cf_read_status_t or a CaptureFile.
-    bool openCaptureFile(QString& cf_path, QString& display_filter, unsigned int type);
-    bool openCaptureFile(QString& cf_path = *new QString(), QString& display_filter = *new QString()) { return openCaptureFile(cf_path, display_filter, WTAP_TYPE_AUTO); }
-    void filterPackets(QString& new_filter = *new QString(), bool force = false);
+    bool openCaptureFile(QString cf_path, QString display_filter, unsigned int type, gboolean is_tempfile = FALSE);
+    bool openCaptureFile(QString cf_path = QString(), QString display_filter = QString()) { return openCaptureFile(cf_path, display_filter, WTAP_TYPE_AUTO); }
+    void filterPackets(QString new_filter = QString(), bool force = false);
     void updateForUnsavedChanges();
     void layoutPanes();
     void applyRecentPaneGeometry();
     void layoutToolbars();
     void updatePreferenceActions();
+    void updateRecentActions();
+
+    void setTitlebarForCaptureFile();
+    void setWSWindowTitle(QString title = QString());
 
     void captureCapturePrepared(capture_session *);
     void captureCaptureUpdateStarted(capture_session *);
@@ -234,21 +294,37 @@ public slots:
     void captureFileReadStarted() { captureFileReadStarted(tr("Loading")); }
     void captureFileReadFinished();
     void captureFileReloadStarted() { captureFileReadStarted(tr("Reloading")); }
-    void captureFileRescanStarted() { captureFileReadStarted(tr("Rescanning")); }
+    void captureFileRescanStarted() { setMenusForCaptureFile(true); captureFileReadStarted(tr("Rescanning")); }
     void captureFileRetapStarted();
     void captureFileRetapFinished();
+    void captureFileMergeStarted();
+    void captureFileMergeFinished();
+    void captureFileFlushTapsData();
     void captureFileClosing();
     void captureFileClosed();
     void captureFileSaveStarted(const QString &file_path);
 
     void filterExpressionsChanged();
+    static gboolean filter_expression_add_action(const void *key, void *value, void *user_data);
 
+    void launchRLCGraph(bool channelKnown, guint16 ueid, guint8 rlcMode,
+                        guint16 channelType, guint16 channelId, guint8 direction);
+
+    void on_actionViewFullScreen_triggered(bool checked);
 private slots:
     // Manually connected slots (no "on_<object>_<signal>").
 
     void initViewColorizeMenu();
+    void initConversationMenus();
+    static gboolean addExportObjectsMenuItem(const void *key, void *value, void *userdata);
+    void initExportObjectsMenus();
 
     // in main_window_slots.cpp
+    /**
+     * @brief startCapture
+     * Start capturing from the selected interfaces using the capture filter
+     * shown in the main welcome screen.
+     */
     void startCapture();
     void pipeTimeout();
     void pipeActivated(int source);
@@ -257,32 +333,45 @@ private slots:
 
     void loadWindowGeometry();
     void saveWindowGeometry();
-    void updateRecentFiles();
+    void mainStackChanged(int);
+    void updateRecentCaptures();
     void recentActionTriggered();
     void setMenusForSelectedPacket();
     void setMenusForSelectedTreeRow(field_info *fi = NULL);
     void interfaceSelectionChanged();
     void captureFilterSyntaxChanged(bool valid);
     void redissectPackets();
+    void checkDisplayFilter();
     void fieldsChanged();
+    void reloadLuaPlugins();
     void showAccordionFrame(AccordionFrame *show_frame, bool toggle = false);
     void showColumnEditor(int column);
     void showPreferenceEditor(); // module_t *, pref *
     void addStatsPluginsToMenu();
     void addDynamicMenus();
     void reloadDynamicMenus();
-    void addExternalMenus();
+    void addPluginIFStructures();
+    QMenu * searchSubMenu(QString objectName);
+    void activatePluginIFToolbar(bool);
 
-    void startInterfaceCapture(bool valid);
+    void filterToolbarCustomMenuHandler(const QPoint& globalPos);
+    void filterToolbarShowPreferences();
+    void filterToolbarEditFilter();
+    void filterToolbarDisableFilter();
+    void filterToolbarRemoveFilter();
+    void filterToolbarActionMoved(QAction * action, int oldPos, int newPos);
 
+    void startInterfaceCapture(bool valid, const QString capture_filter);
+
+    void applyGlobalCommandLineOptions();
     void setFeaturesEnabled(bool enabled = true);
 
     void on_actionDisplayFilterExpression_triggered();
-    void addDisplayFilterButton(QString df_text);
+    void on_actionNewDisplayFilterExpression_triggered();
     void displayFilterButtonClicked();
 
     // Handle FilterAction signals
-    void filterAction(QString& filter, FilterAction::Action action, FilterAction::ActionType type);
+    void queuedFilterAction(QString filter, FilterAction::Action action, FilterAction::ActionType type);
 
     /** Pass stat cmd arguments to a slot.
      * @param menu_path slot Partial slot name, e.g. "StatisticsIOGraph".
@@ -299,6 +388,12 @@ private slots:
     void openTapParameterDialog(const QString cfg_str, const QString arg, void *userdata);
     void openTapParameterDialog();
 
+    void byteViewTabChanged(int tab_index);
+
+#ifdef HAVE_SOFTWARE_UPDATE
+    void softwareUpdateRequested();
+#endif
+
     // Automatically connected slots ("on_<object>_<signal>").
     //
     // The slots below follow the naming conventaion described in
@@ -328,11 +423,8 @@ private slots:
     void on_actionFileExportAsCArrays_triggered();
     void on_actionFileExportAsPSML_triggered();
     void on_actionFileExportAsPDML_triggered();
+    void on_actionFileExportAsJSON_triggered();
     void on_actionFileExportPacketBytes_triggered();
-    void on_actionFileExportObjectsDICOM_triggered();
-    void on_actionFileExportObjectsHTTP_triggered();
-    void on_actionFileExportObjectsSMB_triggered();
-    void on_actionFileExportObjectsTFTP_triggered();
     void on_actionFilePrint_triggered();
 
     void on_actionFileExportPDU_triggered();
@@ -384,23 +476,31 @@ private slots:
     void on_actionViewColorizePacketList_triggered(bool checked);
     void on_actionViewColoringRules_triggered();
     void colorizeConversation(bool create_rule = false);
-    void colorizeWithFilter();
+    void colorizeActionTriggered();
     void on_actionViewColorizeResetColorization_triggered();
-    void on_actionViewColorizeNewConversationRule_triggered();
+    void on_actionViewColorizeNewColoringRule_triggered();
+    void on_actionViewResetLayout_triggered();
     void on_actionViewResizeColumns_triggered();
 
+    void on_actionViewInternalsConversationHashTables_triggered();
+    void on_actionViewInternalsDissectorTables_triggered();
+    void on_actionViewInternalsSupportedProtocols_triggered();
+
     void openPacketDialog(bool from_reference = false);
     void on_actionViewShowPacketInNewWindow_triggered();
     void on_actionContextShowLinkedPacketInNewWindow_triggered();
     void on_actionViewReload_triggered();
+    void on_actionViewReload_as_File_Format_or_Capture_triggered();
 
     void on_actionGoGoToPacket_triggered();
     void on_actionGoGoToLinkedPacket_triggered();
+    void on_actionGoNextConversationPacket_triggered();
+    void on_actionGoPreviousConversationPacket_triggered();
     void on_actionGoAutoScroll_toggled(bool checked);
     void resetPreviousFocus();
 
-#ifdef HAVE_LIBPCAP
     void on_actionCaptureOptions_triggered();
+#ifdef HAVE_LIBPCAP
     void on_actionCaptureRefreshInterfaces_triggered();
 #endif
     void on_actionCaptureCaptureFilters_triggered();
@@ -423,17 +523,17 @@ private slots:
     void on_actionAnalyzePAFOrNotSelected_triggered();
 
     void applyConversationFilter();
+    void applyExportObject();
 
     void on_actionAnalyzeEnabledProtocols_triggered();
     void on_actionAnalyzeDecodeAs_triggered();
-#ifdef HAVE_LUA
     void on_actionAnalyzeReloadLuaPlugins_triggered();
-#endif
 
     void openFollowStreamDialog(follow_type_t type);
     void on_actionAnalyzeFollowTCPStream_triggered();
     void on_actionAnalyzeFollowUDPStream_triggered();
     void on_actionAnalyzeFollowSSLStream_triggered();
+    void on_actionAnalyzeFollowHTTPStream_triggered();
     void statCommandExpertInfo(const char *, void *);
     void on_actionAnalyzeExpertInfo_triggered();
 
@@ -500,7 +600,6 @@ private slots:
     void on_actionStatistics29WestQueues_Queries_by_Queue_triggered();
     void on_actionStatistics29WestQueues_Queries_by_Receiver_triggered();
     void on_actionStatistics29WestUIM_Streams_triggered();
-    void on_actionStatistics29WestUIM_Stream_Flow_Graph_triggered();
     void on_actionStatistics29WestLBTRM_triggered();
     void on_actionStatistics29WestLBTRU_triggered();
     void on_actionStatisticsANCP_triggered();
@@ -529,8 +628,15 @@ private slots:
     void openVoipCallsDialog(bool all_flows = false);
     void on_actionTelephonyVoipCalls_triggered();
     void on_actionTelephonyGsmMapSummary_triggered();
-    void on_actionTelephonyMtp3Summary_triggered();
+    void statCommandLteMacStatistics(const char *arg, void *);
+    void on_actionTelephonyLteRlcStatistics_triggered();
+    void statCommandLteRlcStatistics(const char *arg, void *);
+    void on_actionTelephonyLteMacStatistics_triggered();
+    void on_actionTelephonyLteRlcGraph_triggered();
+    void on_actionTelephonyIax2StreamAnalysis_triggered();
     void on_actionTelephonyISUPMessages_triggered();
+    void on_actionTelephonyMtp3Summary_triggered();
+    void on_actionTelephonyOsmuxPacketCounter_triggered();
     void on_actionTelephonyRTPStreams_triggered();
     void on_actionTelephonyRTPStreamAnalysis_triggered();
     void on_actionTelephonyRTSPPacketCounter_triggered();
@@ -538,9 +644,11 @@ private slots:
     void on_actionTelephonyUCPMessages_triggered();
     void on_actionTelephonySipFlows_triggered();
 
-    void on_actionATT_Server_Attributes_triggered();
-    void on_actionDevices_triggered();
-    void on_actionHCI_Summary_triggered();
+    void on_actionBluetoothATT_Server_Attributes_triggered();
+    void on_actionBluetoothDevices_triggered();
+    void on_actionBluetoothHCI_Summary_triggered();
+
+    void on_actionToolsFirewallAclRules_triggered();
 
     void externalMenuItem_triggered();
 
@@ -549,13 +657,14 @@ private slots:
     void on_actionContextCopyBytesPrintableText_triggered();
     void on_actionContextCopyBytesHexStream_triggered();
     void on_actionContextCopyBytesBinary_triggered();
+    void on_actionContextCopyBytesEscapedString_triggered();
+
+    void on_actionContextShowPacketBytes_triggered();
 
     void on_actionContextWikiProtocolPage_triggered();
     void on_actionContextFilterFieldReference_triggered();
 
-    void changeEvent(QEvent* event);
-
-#if HAVE_EXTCAP
+#ifdef HAVE_EXTCAP
     void extcap_options_finished(int result);
     void showExtcapOptionsDialog(QString & device_name);
 #endif