Qt: Start capture from the command line.
[metze/wireshark/wip.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
37 #ifdef HAVE_LIBPCAP
38 #include "capture_opts.h"
39 #endif
40 #include <capchild/capture_session.h>
41
42 #include <QMainWindow>
43 #include <QSplitter>
44
45 #ifdef _WIN32
46 # include <QTimer>
47 #else
48 # include <QSocketNotifier>
49 #endif
50
51 #include "main_welcome.h"
52 #include "packet_list.h"
53 #include "display_filter_combo.h"
54 #include "progress_bar.h"
55 #include "file_set_dialog.h"
56 #include "filter_action.h"
57 #include "capture_file_dialog.h"
58 #include "summary_dialog.h"
59 #include "follow_stream_dialog.h"
60 #include "capture_interfaces_dialog.h"
61 #include "about_dialog.h"
62
63 class QAction;
64
65 namespace Ui {
66     class MainWindow;
67 }
68
69 class MainWindow : public QMainWindow
70 {
71     Q_OBJECT
72
73 public:
74     explicit MainWindow(QWidget *parent = 0);
75     ~MainWindow();
76     void setPipeInputHandler(gint source, gpointer user_data, int *child_process, pipe_input_cb_t input_cb);
77
78     QString getFilter();
79     capture_session *captureSession() { return &cap_session_; }
80
81 protected:
82     bool eventFilter(QObject *obj, QEvent *event);
83     void keyPressEvent(QKeyEvent *event);
84     void closeEvent (QCloseEvent *event);
85
86 private:
87     // XXX Move to FilterUtils
88     enum MatchSelected {
89         MatchSelectedReplace,
90         MatchSelectedAnd,
91         MatchSelectedOr,
92         MatchSelectedNot,
93         MatchSelectedAndNot,
94         MatchSelectedOrNot
95     };
96
97     enum CopySelected {
98         CopySelectedDescription,
99         CopySelectedFieldName,
100         CopySelectedValue
101     };
102
103     Ui::MainWindow *main_ui_;
104     QMenu *open_recent_menu_;
105     QSplitter master_split_;
106     QSplitter extra_split_;
107     MainWelcome *main_welcome_;
108     DisplayFilterCombo *df_combo_box_;
109     capture_file *cap_file_;
110     capture_session cap_session_;
111     QFont mono_font_;
112     // XXX - packet_list_, proto_tree_, and byte_view_tab_ should
113     // probably be full-on values instead of pointers.
114     PacketList *packet_list_;
115     ProtoTree *proto_tree_;
116     QWidget *previous_focus_;
117     FileSetDialog file_set_dialog_;
118     SummaryDialog summary_dialog_;
119     ByteViewTab *byte_view_tab_;
120     QWidget empty_pane_;
121
122     bool capture_stopping_;
123     bool capture_filter_valid_;
124 #ifdef HAVE_LIBPCAP
125     CaptureInterfacesDialog capture_interfaces_dialog_;
126 #endif
127
128     // Pipe input
129     gint                pipe_source_;
130     gpointer            pipe_user_data_;
131     int                 *pipe_child_process_;
132     pipe_input_cb_t     pipe_input_cb_;
133 #ifdef _WIN32
134     QTimer *pipe_timer_;
135 #else
136     QSocketNotifier *pipe_notifier_;
137 #endif
138
139     void saveWindowGeometry();
140     QWidget* getLayoutWidget(layout_pane_content_e type);
141
142     void mergeCaptureFile();
143     void importCaptureFile();
144     void saveCaptureFile(capture_file *cf, bool stay_closed);
145     void saveAsCaptureFile(capture_file *cf, bool must_support_comments, bool stay_closed);
146     void exportSelectedPackets();
147     void exportDissections(export_type_e export_type);
148
149     void fileAddExtension(QString &file_name, int file_type, bool compressed);
150     bool testCaptureFileClose(bool from_quit = false, QString& before_what = *new QString());
151     void captureStop();
152
153     void setTitlebarForSelectedTreeRow();
154     void setTitlebarForCaptureFile();
155     void setTitlebarForCaptureInProgress();
156     void setMenusForCaptureFile(bool force_disable = false);
157     void setMenusForCaptureInProgress(bool capture_in_progress = false);
158     void setMenusForCaptureStopping();
159     void setForCapturedPackets(bool have_captured_packets);
160     void setMenusForFileSet(bool enable_list_files);
161
162     void setForCaptureInProgress(gboolean capture_in_progress = false);
163
164 signals:
165     void showProgress(progdlg_t **dlg_p, bool animate, const QString message, bool terminate_is_stop, bool *stop_flag, float pct);
166     void setCaptureFile(capture_file *cf);
167     void setDissectedCaptureFile(capture_file *cf);
168     void displayFilterSuccess(bool success);
169     void monospaceFontChanged(const QFont &mono_font);
170
171 public slots:
172     // in main_window_slots.cpp
173     void openCaptureFile(QString& cf_path = *new QString(), QString& display_filter = *new QString(), unsigned int type = WTAP_TYPE_AUTO);
174     void filterPackets(QString& new_filter = *new QString(), bool force = false);
175     void updateForUnsavedChanges();
176     void layoutPanes();
177
178     void captureCapturePrepared(capture_session *cap_session);
179     void captureCaptureUpdateStarted(capture_session *cap_session);
180     void captureCaptureUpdateFinished(capture_session *cap_session);
181     void captureCaptureFixedStarted(capture_session *cap_session);
182     void captureCaptureFixedFinished(capture_session *cap_session);
183     void captureCaptureStopping(capture_session *cap_session);
184     void captureCaptureFailed(capture_session *cap_session);
185
186     void captureFileOpened(const capture_file *cf);
187     void captureFileReadStarted(const capture_file *cf);
188     void captureFileReadFinished(const capture_file *cf);
189     void captureFileClosing(const capture_file *cf);
190     void captureFileClosed(const capture_file *cf);
191
192     void configurationProfileChanged(const gchar *profile_name);
193     void filterExpressionsChanged();
194
195 private slots:
196     // in main_window_slots.cpp
197     void startCapture();
198     void pipeTimeout();
199     void pipeActivated(int source);
200     void pipeNotifierDestroyed();
201     void stopCapture();
202
203     void loadWindowGeometry();
204     void updateRecentFiles();
205     void recentActionTriggered();
206     void setMenusForFollowStream();
207     void setMenusForSelectedPacket();
208     void setMenusForSelectedTreeRow(field_info *fi = NULL);
209     void interfaceSelectionChanged();
210     void captureFilterSyntaxChanged(bool valid);
211     void redissectPackets();
212     void recreatePacketList();
213
214     void startInterfaceCapture(bool valid);
215
216     void setFeaturesEnabled(bool enabled = true);
217
218     void addDisplayFilterButton(QString df_text);
219     void displayFilterButtonClicked();
220
221     // Handle FilterAction signals
222     void filterAction(QString& filter, FilterAction::Action action, FilterAction::ActionType type);
223
224     /** Pass stat cmd arguments to a slot.
225      * @param slot Partial slot name, e.g. "StatisticsIOGraph".
226      * @param "-z" argument, e.g. "io,stat".
227      * @param userdata Optional user data.
228      */
229     void openStatCommandDialog(const QString &menu_path, const char *arg, void *userdata);
230
231     // We should probably move these to main_window_actions.cpp similar to
232     // gtk/main_menubar.c
233     void on_actionFileOpen_triggered();
234     void on_actionFileMerge_triggered();
235     void on_actionFileImportFromHexDump_triggered();
236     void on_actionFileClose_triggered();
237     void on_actionFileSave_triggered();
238     void on_actionFileSaveAs_triggered();
239     void on_actionFileSetListFiles_triggered();
240     void on_actionFileSetNextFile_triggered();
241     void on_actionFileSetPreviousFile_triggered();
242     void on_actionFileExportPackets_triggered();
243     void on_actionFileExportAsPlainText_triggered();
244     // We're dropping PostScript exports
245     void on_actionFileExportAsCSV_triggered();
246     void on_actionFileExportAsCArrays_triggered();
247     void on_actionFileExportAsPSML_triggered();
248     void on_actionFileExportAsPDML_triggered();
249     void on_actionFileExportPacketBytes_triggered();
250     void on_actionFileExportObjectsDICOM_triggered();
251     void on_actionFileExportObjectsHTTP_triggered();
252     void on_actionFileExportObjectsSMB_triggered();
253     void on_actionFileExportObjectsTFTP_triggered();
254     void on_actionFilePrint_triggered();
255
256     void on_actionFileExportPDU_triggered();
257     void on_actionFileExportSSLSessionKeys_triggered();
258
259     void actionEditCopyTriggered(MainWindow::CopySelected selection_type);
260     void on_actionEditCopyDescription_triggered();
261     void on_actionEditCopyFieldName_triggered();
262     void on_actionEditCopyValue_triggered();
263     void on_actionEditCopyAsFilter_triggered();
264     void on_actionEditFindPacket_triggered();
265     void on_actionEditFindNext_triggered();
266     void on_actionEditFindPrevious_triggered();
267     void on_actionEditMarkPacket_triggered();
268     void on_actionEditMarkAllDisplayed_triggered();
269     void on_actionEditUnmarkAllDisplayed_triggered();
270     void on_actionEditNextMark_triggered();
271     void on_actionEditPreviousMark_triggered();
272     void on_actionEditIgnorePacket_triggered();
273     void on_actionEditIgnoreAllDisplayed_triggered();
274     void on_actionEditUnignoreAllDisplayed_triggered();
275     void on_actionEditSetTimeReference_triggered();
276     void on_actionEditUnsetAllTimeReferences_triggered();
277     void on_actionEditNextTimeReference_triggered();
278     void on_actionEditPreviousTimeReference_triggered();
279     void on_actionEditTimeShift_triggered();
280     void on_actionEditPacketComment_triggered();
281     void on_actionEditConfigurationProfiles_triggered();
282     void on_actionEditPreferences_triggered();
283
284     void zoomText();
285     void on_actionViewZoomIn_triggered();
286     void on_actionViewZoomOut_triggered();
287     void on_actionViewNormalSize_triggered();
288     void on_actionViewColorizePacketList_triggered(bool checked);
289     void on_actionViewResizeColumns_triggered();
290     void on_actionViewReload_triggered();
291     void on_actionViewToolbarMainToolbar_triggered();
292     void on_actionViewToolbarDisplayFilter_triggered();
293
294     void on_actionGoGoToPacket_triggered();
295     void resetPreviousFocus();
296
297 #ifdef HAVE_LIBPCAP
298     void on_actionCaptureOptions_triggered();
299     void on_actionCaptureRefreshInterfaces_triggered();
300 #endif
301
302     void matchFieldFilter(FilterAction::Action action, FilterAction::ActionType filter_type);
303     void on_actionAnalyzeAAFSelected_triggered();
304     void on_actionAnalyzeAAFNotSelected_triggered();
305     void on_actionAnalyzeAAFAndSelected_triggered();
306     void on_actionAnalyzeAAFOrSelected_triggered();
307     void on_actionAnalyzeAAFAndNotSelected_triggered();
308     void on_actionAnalyzeAAFOrNotSelected_triggered();
309     void on_actionAnalyzePAFSelected_triggered();
310     void on_actionAnalyzePAFNotSelected_triggered();
311     void on_actionAnalyzePAFAndSelected_triggered();
312     void on_actionAnalyzePAFOrSelected_triggered();
313     void on_actionAnalyzePAFAndNotSelected_triggered();
314     void on_actionAnalyzePAFOrNotSelected_triggered();
315
316     void on_actionAnalyzeDecodeAs_triggered();
317
318     void openFollowStreamDialog(follow_type_t type);
319     void on_actionAnalyzeFollowTCPStream_triggered();
320     void on_actionAnalyzeFollowUDPStream_triggered();
321     void on_actionAnalyzeFollowSSLStream_triggered();
322
323     void on_actionHelpContents_triggered();
324     void on_actionHelpMPWireshark_triggered();
325     void on_actionHelpMPWireshark_Filter_triggered();
326     void on_actionHelpMPCapinfos_triggered();
327     void on_actionHelpMPDumpcap_triggered();
328     void on_actionHelpMPEditcap_triggered();
329     void on_actionHelpMPMergecap_triggered();
330     void on_actionHelpMPRawShark_triggered();
331     void on_actionHelpMPReordercap_triggered();
332     void on_actionHelpMPText2cap_triggered();
333     void on_actionHelpMPTShark_triggered();
334     void on_actionHelpWebsite_triggered();
335     void on_actionHelpFAQ_triggered();
336     void on_actionHelpAsk_triggered();
337     void on_actionHelpDownloads_triggered();
338     void on_actionHelpWiki_triggered();
339     void on_actionHelpSampleCaptures_triggered();
340     void on_actionHelpAbout_triggered();
341
342 #ifdef HAVE_SOFTWARE_UPDATE
343     void on_actionHelpCheckForUpdates_triggered();
344 #endif
345
346     void on_goToCancel_clicked();
347     void on_goToGo_clicked();
348     void on_goToLineEdit_returnPressed();
349     void on_actionCaptureStart_triggered();
350     void on_actionCaptureStop_triggered();
351
352     void on_actionSummary_triggered();
353     void on_actionStatisticsFlowGraph_triggered();
354     void openTcpStreamDialog(int graph_type);
355     void on_actionStatisticsTcpStreamStevens_triggered();
356     void on_actionStatisticsTcpStreamTcptrace_triggered();
357     void on_actionStatisticsTcpStreamThroughput_triggered();
358     void on_actionStatisticsTcpStreamRoundTripTime_triggered();
359     void on_actionStatisticsTcpStreamWindowScaling_triggered();
360     void openSCTPAllAssocsDialog();
361     void on_actionSCTPShowAllAssociations_triggered();
362     void on_actionSCTPAnalyseThisAssociation_triggered();
363     void on_actionSCTPFilterThisAssociation_triggered();
364
365     void openStatisticsTreeDialog(const gchar *abbr);
366     void on_actionStatistics29WestTopics_Advertisements_by_Topic_triggered();
367     void on_actionStatistics29WestTopics_Advertisements_by_Source_triggered();
368     void on_actionStatistics29WestTopics_Advertisements_by_Transport_triggered();
369     void on_actionStatistics29WestTopics_Queries_by_Topic_triggered();
370     void on_actionStatistics29WestTopics_Queries_by_Receiver_triggered();
371     void on_actionStatistics29WestTopics_Wildcard_Queries_by_Pattern_triggered();
372     void on_actionStatistics29WestTopics_Wildcard_Queries_by_Receiver_triggered();
373     void on_actionStatistics29WestQueues_Advertisements_by_Queue_triggered();
374     void on_actionStatistics29WestQueues_Advertisements_by_Source_triggered();
375     void on_actionStatistics29WestQueues_Queries_by_Queue_triggered();
376     void on_actionStatistics29WestQueues_Queries_by_Receiver_triggered();
377     void on_actionStatistics29WestUIM_Streams_triggered();
378     void on_actionStatistics29WestUIM_Stream_Flow_Graph_triggered();
379     void on_actionStatistics29WestLBTRM_triggered();
380     void on_actionStatistics29WestLBTRU_triggered();
381     void on_actionStatisticsANCP_triggered();
382     void on_actionStatisticsBACappInstanceId_triggered();
383     void on_actionStatisticsBACappIP_triggered();
384     void on_actionStatisticsBACappObjectId_triggered();
385     void on_actionStatisticsBACappService_triggered();
386     void on_actionStatisticsCollectd_triggered();
387     void statCommandConversations(const char *arg = NULL, void *userdata = NULL);
388     void on_actionStatisticsConversations_triggered();
389     void statCommandEndpoints(const char *arg = NULL, void *userdata = NULL);
390     void on_actionStatisticsEndpoints_triggered();
391     void on_actionStatisticsHART_IP_triggered();
392     void on_actionStatisticsHTTPPacketCounter_triggered();
393     void on_actionStatisticsHTTPRequests_triggered();
394     void on_actionStatisticsHTTPLoadDistribution_triggered();
395     void on_actionStatisticsPacketLen_triggered();
396     void statCommandIOGraph(const char *arg = NULL, void *userdata = NULL);
397     void on_actionStatisticsIOGraph_triggered();
398     void on_actionStatisticsSametime_triggered();
399
400     void on_actionTelephonyISUPMessages_triggered();
401     void on_actionTelephonyRTSPPacketCounter_triggered();
402     void on_actionTelephonySMPPOperations_triggered();
403     void on_actionTelephonyUCPMessages_triggered();
404
405     void changeEvent(QEvent* event);
406 };
407
408 #endif // MAINWINDOW_H
409
410 /*
411  * Editor modelines
412  *
413  * Local Variables:
414  * c-basic-offset: 4
415  * tab-width: 8
416  * indent-tabs-mode: nil
417  * End:
418  *
419  * ex: set shiftwidth=4 tabstop=8 expandtab:
420  * :indentSize=4:tabSize=8:noTabs=true:
421  */