1 /* sequence_dialog.h
2  *
3  * Wireshark - Network traffic analyzer
4  * By Gerald Combs <gerald@wireshark.org>
5  * Copyright 1998 Gerald Combs
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  */
9 
10 #ifndef SEQUENCE_DIALOG_H
11 #define SEQUENCE_DIALOG_H
12 
13 #include <config.h>
14 
15 #include <glib.h>
16 
17 #include "cfile.h"
18 
19 #include "epan/packet.h"
20 #include "epan/sequence_analysis.h"
21 
22 #include <ui/qt/widgets/qcustomplot.h>
23 #include "wireshark_dialog.h"
24 #include "rtp_stream_dialog.h"
25 
26 #include <QMenu>
27 
28 namespace Ui {
29 class SequenceDialog;
30 }
31 
32 class SequenceDiagram;
33 
34 class SequenceInfo
35 {
36 public:
37     SequenceInfo(seq_analysis_info_t *sainfo = NULL);
sainfo()38     seq_analysis_info_t * sainfo() { return sainfo_;}
ref()39     void ref() { count_++; }
unref()40     void unref() { if (--count_ == 0) delete this; }
41 private:
42     ~SequenceInfo();
43     seq_analysis_info_t *sainfo_;
44     unsigned int count_;
45 };
46 
47 class SequenceDialog : public WiresharkDialog
48 {
49     Q_OBJECT
50 
51 public:
52     explicit SequenceDialog(QWidget &parent, CaptureFile &cf, SequenceInfo *info = NULL);
53     ~SequenceDialog();
54     void enableVoIPFeatures();
55 
56 protected:
57     void showEvent(QShowEvent *event);
58     void resizeEvent(QResizeEvent *event);
59     void keyPressEvent(QKeyEvent *event);
60 
61 signals:
62     void rtpStreamsDialogSelectRtpStreams(QVector<rtpstream_id_t *> stream_infos);
63     void rtpStreamsDialogDeselectRtpStreams(QVector<rtpstream_id_t *> stream_infos);
64     void rtpPlayerDialogReplaceRtpStreams(QVector<rtpstream_id_t *> stream_ids);
65     void rtpPlayerDialogAddRtpStreams(QVector<rtpstream_id_t *> stream_ids);
66     void rtpPlayerDialogRemoveRtpStreams(QVector<rtpstream_id_t *> stream_ids);
67 
68 private slots:
69     void updateWidgets();
70     void hScrollBarChanged(int value);
71     void vScrollBarChanged(int value);
72     void xAxisChanged(QCPRange range);
73     void yAxisChanged(QCPRange range);
74     void diagramClicked(QMouseEvent *event);
75     void mouseMoved(QMouseEvent *event);
76     void mouseWheeled(QWheelEvent *event);
77 
78     void fillDiagram();
79     void resetView();
80     void exportDiagram();
81 
82     void on_buttonBox_clicked(QAbstractButton *button);
83     void on_actionGoToPacket_triggered();
on_actionGoToNextPacket_triggered()84     void on_actionGoToNextPacket_triggered() { goToAdjacentPacket(true); }
on_actionGoToPreviousPacket_triggered()85     void on_actionGoToPreviousPacket_triggered() { goToAdjacentPacket(false); }
86     void on_displayFilterCheckBox_toggled(bool checked);
87     void on_flowComboBox_activated(int index);
88     void on_addressComboBox_activated(int index);
89     void on_actionMoveRight10_triggered();
90     void on_actionMoveLeft10_triggered();
91     void on_actionMoveUp10_triggered();
92     void on_actionMoveDown10_triggered();
93     void on_actionMoveRight1_triggered();
94     void on_actionMoveLeft1_triggered();
95     void on_actionMoveUp1_triggered();
96     void on_actionMoveDown1_triggered();
97     void on_actionZoomIn_triggered();
98     void on_actionZoomOut_triggered();
99     void on_actionSelectRtpStreams_triggered();
100     void on_actionDeselectRtpStreams_triggered();
101     void on_buttonBox_helpRequested();
102 
103     void rtpPlayerReplace();
104     void rtpPlayerAdd();
105     void rtpPlayerRemove();
106 
107 private:
108     Ui::SequenceDialog *ui;
109     SequenceDiagram *seq_diagram_;
110     SequenceInfo *info_;
111     int num_items_;
112     guint32 packet_num_;
113     double one_em_;
114     int sequence_w_;
115     QPushButton *reset_button_;
116     QToolButton *player_button_;
117     QPushButton *export_button_;
118     QMenu ctx_menu_;
119     QCPItemText *key_text_;
120     QCPItemText *comment_text_;
121     seq_analysis_item_t *current_rtp_sai_selected_;     // Used for passing current sai to rtp processing
122     seq_analysis_item_t *current_rtp_sai_hovered_;     // Used for passing current sai to rtp processing
123     QPointer<RtpStreamDialog> rtp_stream_dialog_;       // Singleton pattern used
124     bool voipFeaturesEnabled;
125 
126     void zoomXAxis(bool in);
127     void panAxes(int x_pixels, int y_pixels);
128     void resetAxes(bool keep_lower = false);
129     void goToAdjacentPacket(bool next);
130 
131     static gboolean addFlowSequenceItem(const void *key, void *value, void *userdata);
132 
133     void processRtpStream(bool select);
134     QVector<rtpstream_id_t *>getSelectedRtpIds();
135 };
136 
137 #endif // SEQUENCE_DIALOG_H
138