1 /* interface_frame.h
2  * Display of interfaces, including their respective data, and the
3  * capability to filter interfaces by type
4  *
5  * Wireshark - Network traffic analyzer
6  * By Gerald Combs <gerald@wireshark.org>
7  * Copyright 1998 Gerald Combs
8  *
9  * SPDX-License-Identifier: GPL-2.0-or-later
10  */
11 
12 #ifndef INTERFACE_FRAME_H
13 #define INTERFACE_FRAME_H
14 
15 #include <config.h>
16 
17 #include <glib.h>
18 
19 #include <ui/qt/models/info_proxy_model.h>
20 #include <ui/qt/models/interface_tree_model.h>
21 #include <ui/qt/models/interface_sort_filter_model.h>
22 
23 #include <QFrame>
24 #include <QHBoxLayout>
25 #include <QAbstractButton>
26 #include <QTimer>
27 #include <QMenu>
28 #include <QPushButton>
29 
30 namespace Ui {
31 class InterfaceFrame;
32 }
33 
34 class InterfaceFrame : public QFrame
35 {
36     Q_OBJECT
37 public:
38     explicit InterfaceFrame(QWidget *parent = 0);
39     ~InterfaceFrame();
40 
41     int interfacesHidden();
42 
43     QMenu * getSelectionMenu();
44     int interfacesPresent();
45     void ensureSelectedInterface();
46 
47 Q_SIGNALS:
48     void showExtcapOptions(QString device_name);
49     void startCapture();
50     void itemSelectionChanged();
51     void typeSelectionChanged();
52 
53 public slots:
54     void updateSelectedInterfaces();
55     void interfaceListChanged();
56     void toggleHiddenInterfaces();
57 #ifdef HAVE_PCAP_REMOTE
58     void toggleRemoteInterfaces();
59 #endif
60     void getPoints(int idx, PointList *pts);
61     void showRunOnFile();
62     void showContextMenu(QPoint pos);
63 
64 protected:
65     void hideEvent(QHideEvent *evt);
66     void showEvent(QShowEvent *evt);
67 
68 private:
69 
70     void resetInterfaceTreeDisplay();
71     bool haveLocalCapturePermissions() const;
72 
73     Ui::InterfaceFrame *ui;
74 
75     InterfaceSortFilterModel proxy_model_;
76     InterfaceTreeModel source_model_;
77     InfoProxyModel info_model_;
78 
79     QMap<int, QString> ifTypeDescription;
80 
81 #ifdef HAVE_LIBPCAP
82     QTimer *stat_timer_;
83 #endif // HAVE_LIBPCAP
84 
85 private slots:
86     void interfaceTreeSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected);
87 
88     void on_interfaceTree_doubleClicked(const QModelIndex &index);
89 #ifdef HAVE_LIBPCAP
90     void on_interfaceTree_clicked(const QModelIndex &index);
91 #endif
92 
93     void updateStatistics(void);
94     void actionButton_toggled(bool checked);
95     void triggeredIfTypeButton();
96     void on_warningLabel_linkActivated(const QString &link);
97 };
98 
99 #endif // INTERFACE_FRAME_H
100