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>
39 #include "capture_opts.h"
41 #include <capchild/capture_session.h>
43 #include <QMainWindow>
49 # include <QSocketNotifier>
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"
64 class FunnelStatistics;
77 class MainWindow : public QMainWindow
82 explicit MainWindow(QWidget *parent = 0);
84 void setPipeInputHandler(gint source, gpointer user_data, ws_process_id *child_process, pipe_input_cb_t input_cb);
88 capture_session *captureSession() { return &cap_session_; }
91 virtual QMenu *createPopupMenu();
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);
101 // XXX Move to FilterUtils
103 MatchSelectedReplace,
113 CopyAllVisibleSelectedTreeItems,
114 CopySelectedDescription,
115 CopySelectedFieldName,
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_;
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_;
137 QActionGroup *show_hide_actions_;
138 QActionGroup *time_display_actions_;
139 QActionGroup *time_precision_actions_;
140 FunnelStatistics *funnel_statistics_;
142 bool capture_stopping_;
143 bool capture_filter_valid_;
145 capture_session cap_session_;
146 CaptureInterfacesDialog capture_interfaces_dialog_;
151 gpointer pipe_user_data_;
152 ws_process_id *pipe_child_process_;
153 pipe_input_cb_t pipe_input_cb_;
157 QSocketNotifier *pipe_notifier_;
160 QWidget* getLayoutWidget(layout_pane_content_e type);
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);
169 void fileAddExtension(QString &file_name, int file_type, bool compressed);
170 bool testCaptureFileClose(bool from_quit = false, QString& before_what = *new QString());
173 void initMainToolbarIcons();
174 void initShowHideMainWidgets();
175 void initTimeDisplayFormatMenu();
176 void initTimePrecisionFormatMenu();
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);
187 void externalMenuHelper(ext_menu_t * menu, QMenu * subMenu, gint depth);
189 void setForCaptureInProgress(gboolean capture_in_progress = false);
190 QMenu* findOrAddMenu(QMenu *parent_menu, QString& menu_text);
192 void recursiveCopyProtoTreeItems(QTreeWidgetItem *item, QString &clip, int ident_level);
193 void captureFileReadStarted(const QString &action);
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);
203 // in main_window_slots.cpp
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.
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();
217 void applyRecentPaneGeometry();
218 void layoutToolbars();
219 void updatePreferenceActions();
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 *);
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);
238 void filterExpressionsChanged();
241 // Manually connected slots (no "on_<object>_<signal>").
243 void initViewColorizeMenu();
245 // in main_window_slots.cpp
248 void pipeActivated(int source);
249 void pipeNotifierDestroyed();
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();
270 void startInterfaceCapture(bool valid);
272 void setFeaturesEnabled(bool enabled = true);
274 void on_actionDisplayFilterExpression_triggered();
275 void addDisplayFilterButton(QString df_text);
276 void displayFilterButtonClicked();
278 // Handle FilterAction signals
279 void filterAction(QString& filter, FilterAction::Action action, FilterAction::ActionType type);
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.
286 void openStatCommandDialog(const QString &menu_path, const char *arg, void *userdata);
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.
293 void openTapParameterDialog(const QString cfg_str, const QString arg, void *userdata);
294 void openTapParameterDialog();
296 // Automatically connected slots ("on_<object>_<signal>").
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.
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.
306 // We might want move these to main_window_actions.cpp similar to
307 // gtk/main_menubar.c
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();
332 void on_actionFileExportPDU_triggered();
333 void on_actionFileExportSSLSessionKeys_triggered();
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();
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.
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();
384 void openPacketDialog(bool from_reference = false);
385 void on_actionViewShowPacketInNewWindow_triggered();
386 void on_actionViewShowPacketReferenceInNewWindow_triggered();
387 void on_actionViewReload_triggered();
389 void on_actionGoGoToPacket_triggered();
390 void on_actionGoAutoScroll_toggled(bool checked);
391 void resetPreviousFocus();
394 void on_actionCaptureOptions_triggered();
395 void on_actionCaptureRefreshInterfaces_triggered();
397 void on_actionCaptureCaptureFilters_triggered();
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();
415 void applyConversationFilter();
417 void on_actionAnalyzeDecodeAs_triggered();
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();
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();
445 #ifdef HAVE_SOFTWARE_UPDATE
446 void checkForUpdates();
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();
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();
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();
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();
520 void on_actionATT_Server_Attributes_triggered();
521 void on_actionDevices_triggered();
523 void externalMenuItem_triggered();
525 void changeEvent(QEvent* event);
528 void extcap_options_finished(int result);
529 void showExtcapOptionsDialog(QString & device_name);
533 #endif // MAINWINDOW_H
541 * indent-tabs-mode: nil
544 * ex: set shiftwidth=4 tabstop=8 expandtab:
545 * :indentSize=4:tabSize=8:noTabs=true: