Add the RTP Stream Analysis dialog.
[gd/wireshark/.git] / ui / qt / main_window.h
1 /* main_window.h
2  *
3  * Wireshark - Network traffic analyzer
4  * By Gerald Combs <gerald@wireshark.org>
5  * Copyright 1998 Gerald Combs
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #ifndef MAINWINDOW_H
23 #define MAINWINDOW_H
24
25 #include <stdio.h>
26
27 #include <config.h>
28
29 #include <glib.h>
30
31 #include "file.h"
32
33 #include "ui/ui_util.h"
34
35 #include <epan/prefs.h>
36 #include <epan/plugin_if.h>
37
38 #ifdef HAVE_LIBPCAP
39 #include "capture_opts.h"
40 #endif
41 #include <capchild/capture_session.h>
42
43 #include <QMainWindow>
44 #include <QSplitter>
45
46 #ifdef _WIN32
47 # include <QTimer>
48 #else
49 # include <QSocketNotifier>
50 #endif
51
52 #include "capture_file.h"
53 #include "capture_file_dialog.h"
54 #include "capture_file_properties_dialog.h"
55 #include "capture_interfaces_dialog.h"
56 #include "display_filter_combo.h"
57 #include "file_set_dialog.h"
58 #include "filter_action.h"
59 #include "follow_stream_dialog.h"
60 #include "preferences_dialog.h"
61
62 class AccordionFrame;
63 class ByteViewTab;
64 class FunnelStatistics;
65 class MainWelcome;
66 class PacketList;
67 class ProtoTree;
68 class WirelessFrame;
69
70 class QAction;
71 class QActionGroup;
72
73 namespace Ui {
74     class MainWindow;
75 }
76
77 class MainWindow : public QMainWindow
78 {
79     Q_OBJECT
80
81 public:
82     explicit MainWindow(QWidget *parent = 0);
83     ~MainWindow();
84     void setPipeInputHandler(gint source, gpointer user_data, ws_process_id *child_process, pipe_input_cb_t input_cb);
85
86     QString getFilter();
87 #ifdef HAVE_LIBPCAP
88     capture_session *captureSession() { return &cap_session_; }
89 #endif
90
91     virtual QMenu *createPopupMenu();
92
93 protected:
94     bool eventFilter(QObject *obj, QEvent *event);
95     void keyPressEvent(QKeyEvent *event);
96     void closeEvent(QCloseEvent *event);
97     void dragEnterEvent(QDragEnterEvent *event);
98     void dropEvent(QDropEvent *event);
99
100 private:
101     // XXX Move to FilterUtils
102     enum MatchSelected {
103         MatchSelectedReplace,
104         MatchSelectedAnd,
105         MatchSelectedOr,
106         MatchSelectedNot,
107         MatchSelectedAndNot,
108         MatchSelectedOrNot
109     };
110
111     enum CopySelected {
112         CopyAllVisibleItems,
113         CopyAllVisibleSelectedTreeItems,
114         CopySelectedDescription,
115         CopySelectedFieldName,
116         CopySelectedValue
117     };
118
119     Ui::MainWindow *main_ui_;
120     QMenu *open_recent_menu_;
121     QSplitter master_split_;
122     QSplitter extra_split_;
123     QVector<unsigned> cur_layout_;
124     MainWelcome *main_welcome_;
125     DisplayFilterCombo *df_combo_box_;
126     CaptureFile capture_file_;
127     QFont mono_font_;
128     WirelessFrame *wireless_frame_;
129     // XXX - packet_list_, proto_tree_, and byte_view_tab_ should
130     // probably be full-on values instead of pointers.
131     PacketList *packet_list_;
132     ProtoTree *proto_tree_;
133     QWidget *previous_focus_;
134     FileSetDialog file_set_dialog_;
135     ByteViewTab *byte_view_tab_;
136     QWidget empty_pane_;
137     QActionGroup *show_hide_actions_;
138     QActionGroup *time_display_actions_;
139     QActionGroup *time_precision_actions_;
140     FunnelStatistics *funnel_statistics_;
141
142     bool capture_stopping_;
143     bool capture_filter_valid_;
144 #ifdef HAVE_LIBPCAP
145     capture_session cap_session_;
146     CaptureInterfacesDialog capture_interfaces_dialog_;
147 #endif
148
149     // Pipe input
150     gint                pipe_source_;
151     gpointer            pipe_user_data_;
152     ws_process_id      *pipe_child_process_;
153     pipe_input_cb_t     pipe_input_cb_;
154 #ifdef _WIN32
155     QTimer *pipe_timer_;
156 #else
157     QSocketNotifier *pipe_notifier_;
158 #endif
159
160     QWidget* getLayoutWidget(layout_pane_content_e type);
161
162     void mergeCaptureFile();
163     void importCaptureFile();
164     void saveCaptureFile(capture_file *cf, bool dont_reopen);
165     void saveAsCaptureFile(capture_file *cf, bool must_support_comments = false, bool dont_reopen = false);
166     void exportSelectedPackets();
167     void exportDissections(export_type_e export_type);
168
169     void fileAddExtension(QString &file_name, int file_type, bool compressed);
170     bool testCaptureFileClose(bool from_quit = false, QString& before_what = *new QString());
171     void captureStop();
172
173     void initMainToolbarIcons();
174     void initShowHideMainWidgets();
175     void initTimeDisplayFormatMenu();
176     void initTimePrecisionFormatMenu();
177
178     void setTitlebarForSelectedTreeRow();
179     void setTitlebarForCaptureFile();
180     void setTitlebarForCaptureInProgress();
181     void setMenusForCaptureFile(bool force_disable = false);
182     void setMenusForCaptureInProgress(bool capture_in_progress = false);
183     void setMenusForCaptureStopping();
184     void setForCapturedPackets(bool have_captured_packets);
185     void setMenusForFileSet(bool enable_list_files);
186
187     void externalMenuHelper(ext_menu_t * menu, QMenu  * subMenu, gint depth);
188
189     void setForCaptureInProgress(gboolean capture_in_progress = false);
190     QMenu* findOrAddMenu(QMenu *parent_menu, QString& menu_text);
191
192     void recursiveCopyProtoTreeItems(QTreeWidgetItem *item, QString &clip, int ident_level);
193     void captureFileReadStarted(const QString &action);
194
195 signals:
196     void showProgress(struct progdlg **dlg_p, bool animate, const QString message, bool terminate_is_stop, bool *stop_flag, float pct);
197     void setCaptureFile(capture_file *cf);
198     void setDissectedCaptureFile(capture_file *cf);
199     void displayFilterSuccess(bool success);
200     void monospaceFontChanged(const QFont &mono_font);
201
202 public slots:
203     // in main_window_slots.cpp
204     /**
205      * Open a capture file.
206      * @param cf_path Path to the file.
207      * @param display_filter Display filter to apply. May be empty.
208      * @param type File type.
209      * @return True on success, false on failure.
210      */
211     // XXX We might want to return a cf_read_status_t or a CaptureFile.
212     bool openCaptureFile(QString& cf_path, QString& display_filter, unsigned int type);
213     bool openCaptureFile(QString& cf_path = *new QString(), QString& display_filter = *new QString()) { return openCaptureFile(cf_path, display_filter, WTAP_TYPE_AUTO); }
214     void filterPackets(QString& new_filter = *new QString(), bool force = false);
215     void updateForUnsavedChanges();
216     void layoutPanes();
217     void applyRecentPaneGeometry();
218     void layoutToolbars();
219     void updatePreferenceActions();
220
221     void captureCapturePrepared(capture_session *);
222     void captureCaptureUpdateStarted(capture_session *);
223     void captureCaptureUpdateFinished(capture_session *);
224     void captureCaptureFixedStarted(capture_session *);
225     void captureCaptureFixedFinished(capture_session *cap_session);
226     void captureCaptureStopping(capture_session *);
227     void captureCaptureFailed(capture_session *);
228
229     void captureFileOpened();
230     void captureFileReadStarted() { captureFileReadStarted(tr("Loading")); }
231     void captureFileReadFinished();
232     void captureFileReloadStarted() { captureFileReadStarted(tr("Reloading")); }
233     void captureFileRescanStarted() { captureFileReadStarted(tr("Rescanning")); }
234     void captureFileClosing();
235     void captureFileClosed();
236     void captureFileSaveStarted(const QString &file_path);
237
238     void filterExpressionsChanged();
239
240 private slots:
241     // Manually connected slots (no "on_<object>_<signal>").
242
243     void initViewColorizeMenu();
244
245     // in main_window_slots.cpp
246     void startCapture();
247     void pipeTimeout();
248     void pipeActivated(int source);
249     void pipeNotifierDestroyed();
250     void stopCapture();
251
252     void loadWindowGeometry();
253     void saveWindowGeometry();
254     void updateRecentFiles();
255     void recentActionTriggered();
256     void setMenusForFollowStream();
257     void setMenusForSelectedPacket();
258     void setMenusForSelectedTreeRow(field_info *fi = NULL);
259     void interfaceSelectionChanged();
260     void captureFilterSyntaxChanged(bool valid);
261     void redissectPackets();
262     void fieldsChanged();
263     void showAccordionFrame(AccordionFrame *show_frame, bool toggle = false);
264     void showColumnEditor(int column);
265     void showPreferenceEditor(); // module_t *, pref *
266     void addStatsPluginsToMenu();
267     void addDynamicMenus();
268     void addExternalMenus();
269
270     void startInterfaceCapture(bool valid);
271
272     void setFeaturesEnabled(bool enabled = true);
273
274     void on_actionDisplayFilterExpression_triggered();
275     void addDisplayFilterButton(QString df_text);
276     void displayFilterButtonClicked();
277
278     // Handle FilterAction signals
279     void filterAction(QString& filter, FilterAction::Action action, FilterAction::ActionType type);
280
281     /** Pass stat cmd arguments to a slot.
282      * @param menu_path slot Partial slot name, e.g. "StatisticsIOGraph".
283      * @param arg "-z" argument, e.g. "io,stat".
284      * @param userdata Optional user data.
285      */
286     void openStatCommandDialog(const QString &menu_path, const char *arg, void *userdata);
287
288     /** Pass tap parameter arguments to a slot.
289      * @param cfg_str slot Partial slot name, e.g. "StatisticsAFPSrt".
290      * @param arg "-z" argument, e.g. "afp,srt".
291      * @param userdata Optional user data.
292      */
293     void openTapParameterDialog(const QString cfg_str, const QString arg, void *userdata);
294     void openTapParameterDialog();
295
296     // Automatically connected slots ("on_<object>_<signal>").
297     //
298     // The slots below follow the naming conventaion described in
299     // http://doc.qt.io/qt-4.8/qmetaobject.html#connectSlotsByName and are
300     // automatically connected at initialization time via main_ui_->setupUi,
301     // which in turn calls connectSlotsByName.
302     //
303     // If you're manually connecting a signal to a slot, don't prefix its name
304     // with "on_". Otherwise you'll get runtime warnings.
305
306     // We might want move these to main_window_actions.cpp similar to
307     // gtk/main_menubar.c
308
309     void on_actionFileOpen_triggered();
310     void on_actionFileMerge_triggered();
311     void on_actionFileImportFromHexDump_triggered();
312     void on_actionFileClose_triggered();
313     void on_actionFileSave_triggered();
314     void on_actionFileSaveAs_triggered();
315     void on_actionFileSetListFiles_triggered();
316     void on_actionFileSetNextFile_triggered();
317     void on_actionFileSetPreviousFile_triggered();
318     void on_actionFileExportPackets_triggered();
319     void on_actionFileExportAsPlainText_triggered();
320     // We're dropping PostScript exports
321     void on_actionFileExportAsCSV_triggered();
322     void on_actionFileExportAsCArrays_triggered();
323     void on_actionFileExportAsPSML_triggered();
324     void on_actionFileExportAsPDML_triggered();
325     void on_actionFileExportPacketBytes_triggered();
326     void on_actionFileExportObjectsDICOM_triggered();
327     void on_actionFileExportObjectsHTTP_triggered();
328     void on_actionFileExportObjectsSMB_triggered();
329     void on_actionFileExportObjectsTFTP_triggered();
330     void on_actionFilePrint_triggered();
331
332     void on_actionFileExportPDU_triggered();
333     void on_actionFileExportSSLSessionKeys_triggered();
334
335     void actionEditCopyTriggered(MainWindow::CopySelected selection_type);
336     void on_actionCopyAllVisibleItems_triggered();
337     void on_actionCopyAllVisibleSelectedTreeItems_triggered();
338     void on_actionEditCopyDescription_triggered();
339     void on_actionEditCopyFieldName_triggered();
340     void on_actionEditCopyValue_triggered();
341     void on_actionEditCopyAsFilter_triggered();
342     void on_actionEditFindPacket_triggered();
343     void on_actionEditFindNext_triggered();
344     void on_actionEditFindPrevious_triggered();
345     void on_actionEditMarkPacket_triggered();
346     void on_actionEditMarkAllDisplayed_triggered();
347     void on_actionEditUnmarkAllDisplayed_triggered();
348     void on_actionEditNextMark_triggered();
349     void on_actionEditPreviousMark_triggered();
350     void on_actionEditIgnorePacket_triggered();
351     void on_actionEditIgnoreAllDisplayed_triggered();
352     void on_actionEditUnignoreAllDisplayed_triggered();
353     void on_actionEditSetTimeReference_triggered();
354     void on_actionEditUnsetAllTimeReferences_triggered();
355     void on_actionEditNextTimeReference_triggered();
356     void on_actionEditPreviousTimeReference_triggered();
357     void on_actionEditTimeShift_triggered();
358     void on_actionEditPacketComment_triggered();
359     void on_actionEditConfigurationProfiles_triggered();
360     void showPreferencesDialog(PreferencesDialog::PreferencesPane start_pane = PreferencesDialog::ppAppearance);
361     void showPreferencesDialog(QString module_name);
362     void on_actionEditPreferences_triggered();
363
364     void showHideMainWidgets(QAction *action);
365     void setTimestampFormat(QAction *action);
366     void setTimestampPrecision(QAction *action);
367     void on_actionViewTimeDisplaySecondsWithHoursAndMinutes_triggered(bool checked);
368     void setNameResolution();
369     void on_actionViewNameResolutionPhysical_triggered();
370     void on_actionViewNameResolutionNetwork_triggered();
371     void on_actionViewNameResolutionTransport_triggered();
372     // XXX We're not porting the concurrency action from GTK+ on purpose.
373     void zoomText();
374     void on_actionViewZoomIn_triggered();
375     void on_actionViewZoomOut_triggered();
376     void on_actionViewNormalSize_triggered();
377     void on_actionViewColorizePacketList_triggered(bool checked);
378     void on_actionViewColoringRules_triggered();
379     void colorizeConversation(bool create_rule = false);
380     void on_actionViewColorizeResetColorization_triggered();
381     void on_actionViewColorizeNewConversationRule_triggered();
382     void on_actionViewResizeColumns_triggered();
383
384     void openPacketDialog(bool from_reference = false);
385     void on_actionViewShowPacketInNewWindow_triggered();
386     void on_actionViewShowPacketReferenceInNewWindow_triggered();
387     void on_actionViewReload_triggered();
388
389     void on_actionGoGoToPacket_triggered();
390     void on_actionGoAutoScroll_toggled(bool checked);
391     void resetPreviousFocus();
392
393 #ifdef HAVE_LIBPCAP
394     void on_actionCaptureOptions_triggered();
395     void on_actionCaptureRefreshInterfaces_triggered();
396 #endif
397     void on_actionCaptureCaptureFilters_triggered();
398
399     void on_actionAnalyzeDisplayFilters_triggered();
400     void matchFieldFilter(FilterAction::Action action, FilterAction::ActionType filter_type);
401     void on_actionAnalyzeCreateAColumn_triggered();
402     void on_actionAnalyzeAAFSelected_triggered();
403     void on_actionAnalyzeAAFNotSelected_triggered();
404     void on_actionAnalyzeAAFAndSelected_triggered();
405     void on_actionAnalyzeAAFOrSelected_triggered();
406     void on_actionAnalyzeAAFAndNotSelected_triggered();
407     void on_actionAnalyzeAAFOrNotSelected_triggered();
408     void on_actionAnalyzePAFSelected_triggered();
409     void on_actionAnalyzePAFNotSelected_triggered();
410     void on_actionAnalyzePAFAndSelected_triggered();
411     void on_actionAnalyzePAFOrSelected_triggered();
412     void on_actionAnalyzePAFAndNotSelected_triggered();
413     void on_actionAnalyzePAFOrNotSelected_triggered();
414
415     void applyConversationFilter();
416
417     void on_actionAnalyzeDecodeAs_triggered();
418
419     void openFollowStreamDialog(follow_type_t type);
420     void on_actionAnalyzeFollowTCPStream_triggered();
421     void on_actionAnalyzeFollowUDPStream_triggered();
422     void on_actionAnalyzeFollowSSLStream_triggered();
423     void statCommandExpertInfo(const char *, void *);
424     void on_actionAnalyzeExpertInfo_triggered();
425
426     void on_actionHelpContents_triggered();
427     void on_actionHelpMPWireshark_triggered();
428     void on_actionHelpMPWireshark_Filter_triggered();
429     void on_actionHelpMPCapinfos_triggered();
430     void on_actionHelpMPDumpcap_triggered();
431     void on_actionHelpMPEditcap_triggered();
432     void on_actionHelpMPMergecap_triggered();
433     void on_actionHelpMPRawShark_triggered();
434     void on_actionHelpMPReordercap_triggered();
435     void on_actionHelpMPText2cap_triggered();
436     void on_actionHelpMPTShark_triggered();
437     void on_actionHelpWebsite_triggered();
438     void on_actionHelpFAQ_triggered();
439     void on_actionHelpAsk_triggered();
440     void on_actionHelpDownloads_triggered();
441     void on_actionHelpWiki_triggered();
442     void on_actionHelpSampleCaptures_triggered();
443     void on_actionHelpAbout_triggered();
444
445 #ifdef HAVE_SOFTWARE_UPDATE
446     void checkForUpdates();
447 #endif
448
449     void on_goToCancel_clicked();
450     void on_goToGo_clicked();
451     void on_goToLineEdit_returnPressed();
452     void on_actionCaptureStart_triggered();
453     void on_actionCaptureStop_triggered();
454     void on_actionCaptureRestart_triggered();
455
456     void on_actionStatisticsCaptureFileProperties_triggered();
457     void on_actionStatisticsResolvedAddresses_triggered();
458     void on_actionStatisticsProtocolHierarchy_triggered();
459     void on_actionStatisticsFlowGraph_triggered();
460     void openTcpStreamDialog(int graph_type);
461     void on_actionStatisticsTcpStreamStevens_triggered();
462     void on_actionStatisticsTcpStreamTcptrace_triggered();
463     void on_actionStatisticsTcpStreamThroughput_triggered();
464     void on_actionStatisticsTcpStreamRoundTripTime_triggered();
465     void on_actionStatisticsTcpStreamWindowScaling_triggered();
466     void openSCTPAllAssocsDialog();
467     void on_actionSCTPShowAllAssociations_triggered();
468     void on_actionSCTPAnalyseThisAssociation_triggered();
469     void on_actionSCTPFilterThisAssociation_triggered();
470
471     void openStatisticsTreeDialog(const gchar *abbr);
472     void on_actionStatistics29WestTopics_Advertisements_by_Topic_triggered();
473     void on_actionStatistics29WestTopics_Advertisements_by_Source_triggered();
474     void on_actionStatistics29WestTopics_Advertisements_by_Transport_triggered();
475     void on_actionStatistics29WestTopics_Queries_by_Topic_triggered();
476     void on_actionStatistics29WestTopics_Queries_by_Receiver_triggered();
477     void on_actionStatistics29WestTopics_Wildcard_Queries_by_Pattern_triggered();
478     void on_actionStatistics29WestTopics_Wildcard_Queries_by_Receiver_triggered();
479     void on_actionStatistics29WestQueues_Advertisements_by_Queue_triggered();
480     void on_actionStatistics29WestQueues_Advertisements_by_Source_triggered();
481     void on_actionStatistics29WestQueues_Queries_by_Queue_triggered();
482     void on_actionStatistics29WestQueues_Queries_by_Receiver_triggered();
483     void on_actionStatistics29WestUIM_Streams_triggered();
484     void on_actionStatistics29WestUIM_Stream_Flow_Graph_triggered();
485     void on_actionStatistics29WestLBTRM_triggered();
486     void on_actionStatistics29WestLBTRU_triggered();
487     void on_actionStatisticsANCP_triggered();
488     void on_actionStatisticsBACappInstanceId_triggered();
489     void on_actionStatisticsBACappIP_triggered();
490     void on_actionStatisticsBACappObjectId_triggered();
491     void on_actionStatisticsBACappService_triggered();
492     void on_actionStatisticsCollectd_triggered();
493     void statCommandConversations(const char *arg = NULL, void *userdata = NULL);
494     void on_actionStatisticsConversations_triggered();
495     void statCommandEndpoints(const char *arg = NULL, void *userdata = NULL);
496     void on_actionStatisticsEndpoints_triggered();
497     void on_actionStatisticsHART_IP_triggered();
498     void on_actionStatisticsHTTPPacketCounter_triggered();
499     void on_actionStatisticsHTTPRequests_triggered();
500     void on_actionStatisticsHTTPLoadDistribution_triggered();
501     void on_actionStatisticsPacketLengths_triggered();
502     void statCommandIOGraph(const char *, void *);
503     void on_actionStatisticsIOGraph_triggered();
504     void on_actionStatisticsSametime_triggered();
505     void on_actionStatisticsDNS_triggered();
506     void actionStatisticsPlugin_triggered();
507     void on_actionStatisticsHpfeeds_triggered();
508     void on_actionStatisticsHTTP2_triggered();
509
510     void openVoipCallsDialog(bool all_flows = false);
511     void on_actionTelephonyVoipCalls_triggered();
512     void on_actionTelephonyISUPMessages_triggered();
513     void on_actionTelephonyRTPStreams_triggered();
514     void on_actionTelephonyRTPStreamAnalysis_triggered();
515     void on_actionTelephonyRTSPPacketCounter_triggered();
516     void on_actionTelephonySMPPOperations_triggered();
517     void on_actionTelephonyUCPMessages_triggered();
518     void on_actionTelephonySipFlows_triggered();
519
520     void on_actionATT_Server_Attributes_triggered();
521     void on_actionDevices_triggered();
522
523     void externalMenuItem_triggered();
524
525     void changeEvent(QEvent* event);
526
527 #if HAVE_EXTCAP
528     void extcap_options_finished(int result);
529     void showExtcapOptionsDialog(QString & device_name);
530 #endif
531 };
532
533 #endif // MAINWINDOW_H
534
535 /*
536  * Editor modelines
537  *
538  * Local Variables:
539  * c-basic-offset: 4
540  * tab-width: 8
541  * indent-tabs-mode: nil
542  * End:
543  *
544  * ex: set shiftwidth=4 tabstop=8 expandtab:
545  * :indentSize=4:tabSize=8:noTabs=true:
546  */