3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
33 #include "ui/ui_util.h"
35 #include <epan/prefs.h>
36 #include <epan/plugin_if.h>
37 #include <epan/timestamp.h>
40 #include "capture_opts.h"
42 #include <capchild/capture_session.h>
44 #include <QMainWindow>
50 # include <QSocketNotifier>
53 #include "capture_file.h"
54 #include "capture_file_dialog.h"
55 #include "capture_file_properties_dialog.h"
56 #include "capture_interfaces_dialog.h"
57 #include "display_filter_combo.h"
58 #include "file_set_dialog.h"
59 #include "filter_action.h"
60 #include "follow_stream_dialog.h"
61 #include "preferences_dialog.h"
65 class FunnelStatistics;
78 class MainWindow : public QMainWindow
83 explicit MainWindow(QWidget *parent = 0);
85 void setPipeInputHandler(gint source, gpointer user_data, ws_process_id *child_process, pipe_input_cb_t input_cb);
89 capture_session *captureSession() { return &cap_session_; }
92 virtual QMenu *createPopupMenu();
94 void gotoFrame(int packet_num);
97 bool eventFilter(QObject *obj, QEvent *event);
98 void keyPressEvent(QKeyEvent *event);
99 void closeEvent(QCloseEvent *event);
100 void dragEnterEvent(QDragEnterEvent *event);
101 void dropEvent(QDropEvent *event);
104 // XXX Move to FilterUtils
106 MatchSelectedReplace,
116 CopyAllVisibleSelectedTreeItems,
117 CopySelectedDescription,
118 CopySelectedFieldName,
122 Ui::MainWindow *main_ui_;
123 QMenu *open_recent_menu_;
124 QSplitter master_split_;
125 QSplitter extra_split_;
126 QVector<unsigned> cur_layout_;
127 MainWelcome *main_welcome_;
128 DisplayFilterCombo *df_combo_box_;
129 CaptureFile capture_file_;
131 WirelessFrame *wireless_frame_;
132 // XXX - packet_list_, proto_tree_, and byte_view_tab_ should
133 // probably be full-on values instead of pointers.
134 PacketList *packet_list_;
135 ProtoTree *proto_tree_;
136 QWidget *previous_focus_;
137 FileSetDialog file_set_dialog_;
138 ByteViewTab *byte_view_tab_;
140 QActionGroup *show_hide_actions_;
141 QActionGroup *time_display_actions_;
142 QActionGroup *time_precision_actions_;
143 FunnelStatistics *funnel_statistics_;
144 QList<QPair<QAction *, bool> > freeze_actions_;
145 QWidget *freeze_focus_;
146 QMap<QAction *, ts_type> td_actions;
147 QMap<QAction *, ts_precision> tp_actions;
149 bool capture_stopping_;
150 bool capture_filter_valid_;
152 capture_session cap_session_;
153 CaptureInterfacesDialog capture_interfaces_dialog_;
158 gpointer pipe_user_data_;
159 ws_process_id *pipe_child_process_;
160 pipe_input_cb_t pipe_input_cb_;
164 QSocketNotifier *pipe_notifier_;
167 QWidget* getLayoutWidget(layout_pane_content_e type);
172 void mergeCaptureFile();
173 void importCaptureFile();
174 void saveCaptureFile(capture_file *cf, bool dont_reopen);
175 void saveAsCaptureFile(capture_file *cf, bool must_support_comments = false, bool dont_reopen = false);
176 void exportSelectedPackets();
177 void exportDissections(export_type_e export_type);
179 void fileAddExtension(QString &file_name, int file_type, bool compressed);
180 bool testCaptureFileClose(bool from_quit = false, QString before_what = QString());
183 void initMainToolbarIcons();
184 void initShowHideMainWidgets();
185 void initTimeDisplayFormatMenu();
186 void initTimePrecisionFormatMenu();
187 void initFreezeActions();
189 void setDefaultWindowTitle();
190 void setTitlebarForCaptureFile();
191 void setTitlebarForCaptureInProgress();
192 void setMenusForCaptureFile(bool force_disable = false);
193 void setMenusForCaptureInProgress(bool capture_in_progress = false);
194 void setMenusForCaptureStopping();
195 void setForCapturedPackets(bool have_captured_packets);
196 void setMenusForFileSet(bool enable_list_files);
197 void setWindowIcon(const QIcon &icon);
199 void externalMenuHelper(ext_menu_t * menu, QMenu * subMenu, gint depth);
201 void setForCaptureInProgress(gboolean capture_in_progress = false);
202 QMenu* findOrAddMenu(QMenu *parent_menu, QString& menu_text);
204 void recursiveCopyProtoTreeItems(QTreeWidgetItem *item, QString &clip, int ident_level);
205 void captureFileReadStarted(const QString &action);
207 void addMenuActions(QList<QAction *> &actions, int menu_group);
208 void removeMenuActions(QList<QAction *> &actions, int menu_group);
209 void goToConversationFrame(bool go_next);
212 void setCaptureFile(capture_file *cf);
213 void setDissectedCaptureFile(capture_file *cf);
214 void displayFilterSuccess(bool success);
215 void monospaceFontChanged(const QFont &mono_font);
216 void closePacketDialogs();
220 // in main_window_slots.cpp
222 * Open a capture file.
223 * @param cf_path Path to the file.
224 * @param display_filter Display filter to apply. May be empty.
225 * @param type File type.
226 * @return True on success, false on failure.
228 // XXX We might want to return a cf_read_status_t or a CaptureFile.
229 bool openCaptureFile(QString cf_path, QString display_filter, unsigned int type);
230 bool openCaptureFile(QString cf_path = QString(), QString display_filter = QString()) { return openCaptureFile(cf_path, display_filter, WTAP_TYPE_AUTO); }
231 void filterPackets(QString new_filter = QString(), bool force = false);
232 void updateForUnsavedChanges();
234 void applyRecentPaneGeometry();
235 void layoutToolbars();
236 void updatePreferenceActions();
237 void updateRecentActions();
239 void captureCapturePrepared(capture_session *);
240 void captureCaptureUpdateStarted(capture_session *);
241 void captureCaptureUpdateFinished(capture_session *);
242 void captureCaptureFixedStarted(capture_session *);
243 void captureCaptureFixedFinished(capture_session *cap_session);
244 void captureCaptureStopping(capture_session *);
245 void captureCaptureFailed(capture_session *);
247 void captureFileOpened();
248 void captureFileReadStarted() { captureFileReadStarted(tr("Loading")); }
249 void captureFileReadFinished();
250 void captureFileReloadStarted() { captureFileReadStarted(tr("Reloading")); }
251 void captureFileRescanStarted() { setMenusForCaptureFile(true); captureFileReadStarted(tr("Rescanning")); }
252 void captureFileRetapStarted();
253 void captureFileRetapFinished();
254 void captureFileClosing();
255 void captureFileClosed();
256 void captureFileSaveStarted(const QString &file_path);
258 void filterExpressionsChanged();
260 void launchRLCGraph(bool channelKnown, guint16 ueid, guint8 rlcMode,
261 guint16 channelType, guint16 channelId, guint8 direction);
264 // Manually connected slots (no "on_<object>_<signal>").
266 void initViewColorizeMenu();
268 // in main_window_slots.cpp
271 void pipeActivated(int source);
272 void pipeNotifierDestroyed();
275 void loadWindowGeometry();
276 void saveWindowGeometry();
277 void mainStackChanged(int);
278 void updateRecentFiles();
279 void recentActionTriggered();
280 void setMenusForSelectedPacket();
281 void setMenusForSelectedTreeRow(field_info *fi = NULL);
282 void interfaceSelectionChanged();
283 void captureFilterSyntaxChanged(bool valid);
284 void redissectPackets();
285 void checkDisplayFilter();
286 void fieldsChanged();
287 void showAccordionFrame(AccordionFrame *show_frame, bool toggle = false);
288 void showColumnEditor(int column);
289 void showPreferenceEditor(); // module_t *, pref *
290 void addStatsPluginsToMenu();
291 void addDynamicMenus();
292 void reloadDynamicMenus();
293 void addExternalMenus();
294 QMenu * searchSubMenu(QString objectName);
296 void startInterfaceCapture(bool valid);
298 void setFeaturesEnabled(bool enabled = true);
300 void on_actionDisplayFilterExpression_triggered();
301 void on_actionNewDisplayFilterExpression_triggered();
302 void displayFilterButtonClicked();
304 // Handle FilterAction signals
305 void filterAction(QString& filter, FilterAction::Action action, FilterAction::ActionType type);
307 /** Pass stat cmd arguments to a slot.
308 * @param menu_path slot Partial slot name, e.g. "StatisticsIOGraph".
309 * @param arg "-z" argument, e.g. "io,stat".
310 * @param userdata Optional user data.
312 void openStatCommandDialog(const QString &menu_path, const char *arg, void *userdata);
314 /** Pass tap parameter arguments to a slot.
315 * @param cfg_str slot Partial slot name, e.g. "StatisticsAFPSrt".
316 * @param arg "-z" argument, e.g. "afp,srt".
317 * @param userdata Optional user data.
319 void openTapParameterDialog(const QString cfg_str, const QString arg, void *userdata);
320 void openTapParameterDialog();
322 // Automatically connected slots ("on_<object>_<signal>").
324 // The slots below follow the naming conventaion described in
325 // http://doc.qt.io/qt-4.8/qmetaobject.html#connectSlotsByName and are
326 // automatically connected at initialization time via main_ui_->setupUi,
327 // which in turn calls connectSlotsByName.
329 // If you're manually connecting a signal to a slot, don't prefix its name
330 // with "on_". Otherwise you'll get runtime warnings.
332 // We might want move these to main_window_actions.cpp similar to
333 // gtk/main_menubar.c
335 void on_actionFileOpen_triggered();
336 void on_actionFileMerge_triggered();
337 void on_actionFileImportFromHexDump_triggered();
338 void on_actionFileClose_triggered();
339 void on_actionFileSave_triggered();
340 void on_actionFileSaveAs_triggered();
341 void on_actionFileSetListFiles_triggered();
342 void on_actionFileSetNextFile_triggered();
343 void on_actionFileSetPreviousFile_triggered();
344 void on_actionFileExportPackets_triggered();
345 void on_actionFileExportAsPlainText_triggered();
346 // We're dropping PostScript exports
347 void on_actionFileExportAsCSV_triggered();
348 void on_actionFileExportAsCArrays_triggered();
349 void on_actionFileExportAsPSML_triggered();
350 void on_actionFileExportAsPDML_triggered();
351 void on_actionFileExportPacketBytes_triggered();
352 void on_actionFileExportObjectsDICOM_triggered();
353 void on_actionFileExportObjectsHTTP_triggered();
354 void on_actionFileExportObjectsSMB_triggered();
355 void on_actionFileExportObjectsTFTP_triggered();
356 void on_actionFilePrint_triggered();
358 void on_actionFileExportPDU_triggered();
359 void on_actionFileExportSSLSessionKeys_triggered();
361 void actionEditCopyTriggered(MainWindow::CopySelected selection_type);
362 void on_actionCopyAllVisibleItems_triggered();
363 void on_actionCopyAllVisibleSelectedTreeItems_triggered();
364 void on_actionEditCopyDescription_triggered();
365 void on_actionEditCopyFieldName_triggered();
366 void on_actionEditCopyValue_triggered();
367 void on_actionEditCopyAsFilter_triggered();
368 void on_actionEditFindPacket_triggered();
369 void on_actionEditFindNext_triggered();
370 void on_actionEditFindPrevious_triggered();
371 void on_actionEditMarkPacket_triggered();
372 void on_actionEditMarkAllDisplayed_triggered();
373 void on_actionEditUnmarkAllDisplayed_triggered();
374 void on_actionEditNextMark_triggered();
375 void on_actionEditPreviousMark_triggered();
376 void on_actionEditIgnorePacket_triggered();
377 void on_actionEditIgnoreAllDisplayed_triggered();
378 void on_actionEditUnignoreAllDisplayed_triggered();
379 void on_actionEditSetTimeReference_triggered();
380 void on_actionEditUnsetAllTimeReferences_triggered();
381 void on_actionEditNextTimeReference_triggered();
382 void on_actionEditPreviousTimeReference_triggered();
383 void on_actionEditTimeShift_triggered();
384 void on_actionEditPacketComment_triggered();
385 void on_actionEditConfigurationProfiles_triggered();
386 void showPreferencesDialog(PreferencesDialog::PreferencesPane start_pane = PreferencesDialog::ppAppearance);
387 void showPreferencesDialog(QString module_name);
388 void on_actionEditPreferences_triggered();
390 void showHideMainWidgets(QAction *action);
391 void setTimestampFormat(QAction *action);
392 void setTimestampPrecision(QAction *action);
393 void on_actionViewTimeDisplaySecondsWithHoursAndMinutes_triggered(bool checked);
394 void on_actionViewEditResolvedName_triggered();
395 void setNameResolution();
396 void on_actionViewNameResolutionPhysical_triggered();
397 void on_actionViewNameResolutionNetwork_triggered();
398 void on_actionViewNameResolutionTransport_triggered();
399 // XXX We're not porting the concurrency action from GTK+ on purpose.
401 void on_actionViewZoomIn_triggered();
402 void on_actionViewZoomOut_triggered();
403 void on_actionViewNormalSize_triggered();
404 void on_actionViewColorizePacketList_triggered(bool checked);
405 void on_actionViewColoringRules_triggered();
406 void colorizeConversation(bool create_rule = false);
407 void colorizeWithFilter();
408 void on_actionViewColorizeResetColorization_triggered();
409 void on_actionViewColorizeNewConversationRule_triggered();
410 void on_actionViewResizeColumns_triggered();
412 void on_actionViewInternalsConversationHashTables_triggered();
413 void on_actionViewInternalsDissectorTables_triggered();
414 void on_actionViewInternalsSupportedProtocols_triggered();
416 void openPacketDialog(bool from_reference = false);
417 void on_actionViewShowPacketInNewWindow_triggered();
418 void on_actionContextShowLinkedPacketInNewWindow_triggered();
419 void on_actionViewReload_triggered();
420 void on_actionViewReload_as_File_Format_or_Capture_triggered();
422 void on_actionGoGoToPacket_triggered();
423 void on_actionGoGoToLinkedPacket_triggered();
424 void on_actionGoNextConversationPacket_triggered();
425 void on_actionGoPreviousConversationPacket_triggered();
426 void on_actionGoAutoScroll_toggled(bool checked);
427 void resetPreviousFocus();
430 void on_actionCaptureOptions_triggered();
431 void on_actionCaptureRefreshInterfaces_triggered();
433 void on_actionCaptureCaptureFilters_triggered();
435 void on_actionAnalyzeDisplayFilters_triggered();
436 void on_actionAnalyzeDisplayFilterMacros_triggered();
437 void matchFieldFilter(FilterAction::Action action, FilterAction::ActionType filter_type);
438 void on_actionAnalyzeCreateAColumn_triggered();
439 void on_actionAnalyzeAAFSelected_triggered();
440 void on_actionAnalyzeAAFNotSelected_triggered();
441 void on_actionAnalyzeAAFAndSelected_triggered();
442 void on_actionAnalyzeAAFOrSelected_triggered();
443 void on_actionAnalyzeAAFAndNotSelected_triggered();
444 void on_actionAnalyzeAAFOrNotSelected_triggered();
445 void on_actionAnalyzePAFSelected_triggered();
446 void on_actionAnalyzePAFNotSelected_triggered();
447 void on_actionAnalyzePAFAndSelected_triggered();
448 void on_actionAnalyzePAFOrSelected_triggered();
449 void on_actionAnalyzePAFAndNotSelected_triggered();
450 void on_actionAnalyzePAFOrNotSelected_triggered();
452 void applyConversationFilter();
454 void on_actionAnalyzeEnabledProtocols_triggered();
455 void on_actionAnalyzeDecodeAs_triggered();
456 void on_actionAnalyzeReloadLuaPlugins_triggered();
458 void openFollowStreamDialog(follow_type_t type);
459 void on_actionAnalyzeFollowTCPStream_triggered();
460 void on_actionAnalyzeFollowUDPStream_triggered();
461 void on_actionAnalyzeFollowSSLStream_triggered();
462 void statCommandExpertInfo(const char *, void *);
463 void on_actionAnalyzeExpertInfo_triggered();
465 void on_actionHelpContents_triggered();
466 void on_actionHelpMPWireshark_triggered();
467 void on_actionHelpMPWireshark_Filter_triggered();
468 void on_actionHelpMPCapinfos_triggered();
469 void on_actionHelpMPDumpcap_triggered();
470 void on_actionHelpMPEditcap_triggered();
471 void on_actionHelpMPMergecap_triggered();
472 void on_actionHelpMPRawShark_triggered();
473 void on_actionHelpMPReordercap_triggered();
474 void on_actionHelpMPText2cap_triggered();
475 void on_actionHelpMPTShark_triggered();
476 void on_actionHelpWebsite_triggered();
477 void on_actionHelpFAQ_triggered();
478 void on_actionHelpAsk_triggered();
479 void on_actionHelpDownloads_triggered();
480 void on_actionHelpWiki_triggered();
481 void on_actionHelpSampleCaptures_triggered();
482 void on_actionHelpAbout_triggered();
484 #ifdef HAVE_SOFTWARE_UPDATE
485 void checkForUpdates();
488 void on_goToCancel_clicked();
489 void on_goToGo_clicked();
490 void on_goToLineEdit_returnPressed();
491 void on_actionCaptureStart_triggered();
492 void on_actionCaptureStop_triggered();
493 void on_actionCaptureRestart_triggered();
495 void on_actionStatisticsCaptureFileProperties_triggered();
496 void on_actionStatisticsResolvedAddresses_triggered();
497 void on_actionStatisticsProtocolHierarchy_triggered();
498 void on_actionStatisticsFlowGraph_triggered();
499 void openTcpStreamDialog(int graph_type);
500 void on_actionStatisticsTcpStreamStevens_triggered();
501 void on_actionStatisticsTcpStreamTcptrace_triggered();
502 void on_actionStatisticsTcpStreamThroughput_triggered();
503 void on_actionStatisticsTcpStreamRoundTripTime_triggered();
504 void on_actionStatisticsTcpStreamWindowScaling_triggered();
505 void openSCTPAllAssocsDialog();
506 void on_actionSCTPShowAllAssociations_triggered();
507 void on_actionSCTPAnalyseThisAssociation_triggered();
508 void on_actionSCTPFilterThisAssociation_triggered();
509 void statCommandMulticastStatistics(const char *arg, void *);
510 void on_actionStatisticsUdpMulticastStreams_triggered();
512 void statCommandWlanStatistics(const char *arg, void *);
513 void on_actionWirelessWlanStatistics_triggered();
515 void openStatisticsTreeDialog(const gchar *abbr);
516 void on_actionStatistics29WestTopics_Advertisements_by_Topic_triggered();
517 void on_actionStatistics29WestTopics_Advertisements_by_Source_triggered();
518 void on_actionStatistics29WestTopics_Advertisements_by_Transport_triggered();
519 void on_actionStatistics29WestTopics_Queries_by_Topic_triggered();
520 void on_actionStatistics29WestTopics_Queries_by_Receiver_triggered();
521 void on_actionStatistics29WestTopics_Wildcard_Queries_by_Pattern_triggered();
522 void on_actionStatistics29WestTopics_Wildcard_Queries_by_Receiver_triggered();
523 void on_actionStatistics29WestQueues_Advertisements_by_Queue_triggered();
524 void on_actionStatistics29WestQueues_Advertisements_by_Source_triggered();
525 void on_actionStatistics29WestQueues_Queries_by_Queue_triggered();
526 void on_actionStatistics29WestQueues_Queries_by_Receiver_triggered();
527 void on_actionStatistics29WestUIM_Streams_triggered();
528 void on_actionStatistics29WestUIM_Stream_Flow_Graph_triggered();
529 void on_actionStatistics29WestLBTRM_triggered();
530 void on_actionStatistics29WestLBTRU_triggered();
531 void on_actionStatisticsANCP_triggered();
532 void on_actionStatisticsBACappInstanceId_triggered();
533 void on_actionStatisticsBACappIP_triggered();
534 void on_actionStatisticsBACappObjectId_triggered();
535 void on_actionStatisticsBACappService_triggered();
536 void on_actionStatisticsCollectd_triggered();
537 void statCommandConversations(const char *arg = NULL, void *userdata = NULL);
538 void on_actionStatisticsConversations_triggered();
539 void statCommandEndpoints(const char *arg = NULL, void *userdata = NULL);
540 void on_actionStatisticsEndpoints_triggered();
541 void on_actionStatisticsHART_IP_triggered();
542 void on_actionStatisticsHTTPPacketCounter_triggered();
543 void on_actionStatisticsHTTPRequests_triggered();
544 void on_actionStatisticsHTTPLoadDistribution_triggered();
545 void on_actionStatisticsPacketLengths_triggered();
546 void statCommandIOGraph(const char *, void *);
547 void on_actionStatisticsIOGraph_triggered();
548 void on_actionStatisticsSametime_triggered();
549 void on_actionStatisticsDNS_triggered();
550 void actionStatisticsPlugin_triggered();
551 void on_actionStatisticsHpfeeds_triggered();
552 void on_actionStatisticsHTTP2_triggered();
554 void openVoipCallsDialog(bool all_flows = false);
555 void on_actionTelephonyVoipCalls_triggered();
556 void on_actionTelephonyGsmMapSummary_triggered();
557 void statCommandLteMacStatistics(const char *arg, void *);
558 void on_actionTelephonyLteRlcStatistics_triggered();
559 void statCommandLteRlcStatistics(const char *arg, void *);
560 void on_actionTelephonyLteMacStatistics_triggered();
561 void on_actionTelephonyLteRlcGraph_triggered();
562 void on_actionTelephonyIax2StreamAnalysis_triggered();
563 void on_actionTelephonyISUPMessages_triggered();
564 void on_actionTelephonyMtp3Summary_triggered();
565 void on_actionTelephonyRTPStreams_triggered();
566 void on_actionTelephonyRTPStreamAnalysis_triggered();
567 void on_actionTelephonyRTSPPacketCounter_triggered();
568 void on_actionTelephonySMPPOperations_triggered();
569 void on_actionTelephonyUCPMessages_triggered();
570 void on_actionTelephonySipFlows_triggered();
572 void on_actionBluetoothATT_Server_Attributes_triggered();
573 void on_actionBluetoothDevices_triggered();
574 void on_actionBluetoothHCI_Summary_triggered();
576 void externalMenuItem_triggered();
578 void on_actionContextCopyBytesHexTextDump_triggered();
579 void on_actionContextCopyBytesHexDump_triggered();
580 void on_actionContextCopyBytesPrintableText_triggered();
581 void on_actionContextCopyBytesHexStream_triggered();
582 void on_actionContextCopyBytesBinary_triggered();
584 void on_actionContextWikiProtocolPage_triggered();
585 void on_actionContextFilterFieldReference_triggered();
587 void changeEvent(QEvent* event);
590 void extcap_options_finished(int result);
591 void showExtcapOptionsDialog(QString & device_name);
595 #endif // MAINWINDOW_H
603 * indent-tabs-mode: nil
606 * ex: set shiftwidth=4 tabstop=8 expandtab:
607 * :indentSize=4:tabSize=8:noTabs=true: