2255fd5ace8f20877dc467c00d46e33af4e12f40
[metze/wireshark/wip.git] / ui / qt / wireshark_application.h
1 /* wireshark_application.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 WIRESHARK_APPLICATION_H
23 #define WIRESHARK_APPLICATION_H
24
25 #include <config.h>
26
27 #include <glib.h>
28
29 #include "register.h"
30
31 #include "ui/help_url.h"
32
33 #include <QApplication>
34 #include <QDir>
35 #include <QFont>
36 #include <QIcon>
37 #include <QTimer>
38 #include <QTranslator>
39
40 struct _e_prefs;
41
42 class QSocketNotifier;
43
44 // Recent items:
45 // - Read from prefs
46 // - Add from open file
47 // - Check current list
48 // - Signal updated item
49 // -
50 typedef struct _recent_item_status {
51     QString filename;
52     qint64 size;
53     bool accessible;
54     bool in_thread;
55 } recent_item_status;
56
57 class WiresharkApplication : public QApplication
58 {
59     Q_OBJECT
60 public:
61     explicit WiresharkApplication(int &argc,  char **argv);
62
63     enum AppSignal {
64         ColumnsChanged,
65         FilterExpressionsChanged,
66         PacketDissectionChanged,
67         PreferencesChanged,
68         RecentFilesRead,
69         FieldsChanged
70     };
71
72     void registerUpdate(register_action_e action, const char *message);
73     void emitAppSignal(AppSignal signal);
74     void emitStatCommandSignal(const QString &menu_path, const char *arg, void *userdata);
75     void allSystemsGo();
76     void refreshLocalInterfaces();
77     struct _e_prefs * readConfigurationFiles(char **gdp_path, char **dp_path);
78     QList<recent_item_status *> recentItems() const;
79     void addRecentItem(const QString &filename, qint64 size, bool accessible);
80     QDir lastOpenDir();
81     void setLastOpenDir(const char *dir_name);
82     void setLastOpenDir(QString *dir_str);
83     void helpTopicAction(topic_action_e action);
84     const QFont monospaceFont() const { return mono_font_; }
85     void setMonospaceFont(const char *font_string);
86     int monospaceTextSize(const char *str);
87     void setConfigurationProfile(const gchar *profile_name);
88     bool isInitialized() { return initialized_; }
89     const QIcon &normalIcon() const { return normal_icon_; }
90     const QIcon &captureIcon() const { return capture_icon_; }
91     const QString &windowTitleSeparator() const { return window_title_separator_; }
92     const QString windowTitleString(QStringList title_parts);
93     const QString windowTitleString(QString title_part) { return windowTitleString(QStringList() << title_part); }
94
95     QTranslator translator;
96     QTranslator translatorQt;
97     void loadLanguage(const QString& language);
98
99 private:
100     bool initialized_;
101     QFont mono_font_;
102     QTimer recent_timer_;
103     QTimer addr_resolv_timer_;
104     QTimer tap_update_timer_;
105     QList<QString> pending_open_files_;
106     QSocketNotifier *if_notifier_;
107     QIcon normal_icon_;
108     QIcon capture_icon_;
109     static QString window_title_separator_;
110
111 protected:
112     bool event(QEvent *event);
113
114 signals:
115     void appInitialized();
116     void localInterfaceListChanged();
117     void openCaptureFile(QString &cf_path, QString &display_filter, unsigned int type);
118     void recentFilesRead();
119     void updateRecentItemStatus(const QString &filename, qint64 size, bool accessible);
120     void splashUpdate(register_action_e action, const char *message);
121     void profileChanging();
122     void profileNameChanged(const gchar *profile_name);
123
124     void columnsChanged(); // XXX This recreates the packet list. We might want to rename it accordingly.
125     void filterExpressionsChanged();
126     void packetDissectionChanged();
127     void preferencesChanged();
128     void addressResolutionChanged();
129     void fieldsChanged();
130
131     void openStatCommandDialog(const QString &menu_path, const char *arg, void *userdata);
132
133 public slots:
134     void clearRecentItems();
135     void captureFileReadStarted();
136     void updateTaps();
137
138 private slots:
139     void cleanup();
140     void ifChangeEventsAvailable();
141     void itemStatusFinished(const QString filename = "", qint64 size = 0, bool accessible = false);
142     void refreshRecentFiles(void);
143     void refreshAddressResolution(void);
144 };
145
146 extern WiresharkApplication *wsApp;
147
148 /** Global compile time version string */
149 extern GString *comp_info_str;
150 /** Global runtime version string */
151 extern GString *runtime_info_str;
152
153 #endif // WIRESHARK_APPLICATION_H
154
155 /*
156  * Editor modelines
157  *
158  * Local Variables:
159  * c-basic-offset: 4
160  * tab-width: 8
161  * indent-tabs-mode: nil
162  * End:
163  *
164  * ex: set shiftwidth=4 tabstop=8 expandtab:
165  * :indentSize=4:tabSize=8:noTabs=true:
166  */