2013-07-25 23:49:47 +00:00
|
|
|
/* wireshark_application.h
|
2012-01-04 22:13:01 +00:00
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2012-01-04 22:13:01 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef WIRESHARK_APPLICATION_H
|
|
|
|
#define WIRESHARK_APPLICATION_H
|
|
|
|
|
2015-01-03 20:52:54 +00:00
|
|
|
#include <config.h>
|
2012-01-14 00:16:16 +00:00
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
2012-11-05 03:54:21 +00:00
|
|
|
#include "register.h"
|
2012-01-14 00:16:16 +00:00
|
|
|
|
2012-10-16 19:47:43 +00:00
|
|
|
#include "ui/help_url.h"
|
|
|
|
|
2012-01-04 22:13:01 +00:00
|
|
|
#include <QApplication>
|
2015-02-08 20:24:19 +00:00
|
|
|
#include <QDir>
|
2013-01-24 01:10:12 +00:00
|
|
|
#include <QFont>
|
2014-09-21 20:28:29 +00:00
|
|
|
#include <QIcon>
|
2013-11-21 01:28:17 +00:00
|
|
|
#include <QTimer>
|
2013-12-21 16:55:43 +00:00
|
|
|
#include <QTranslator>
|
|
|
|
|
2015-02-12 23:35:59 +00:00
|
|
|
struct _e_prefs;
|
|
|
|
|
2015-06-05 20:17:13 +00:00
|
|
|
class QAction;
|
2015-02-08 20:24:19 +00:00
|
|
|
class QSocketNotifier;
|
2012-01-04 22:13:01 +00:00
|
|
|
|
|
|
|
// Recent items:
|
|
|
|
// - Read from prefs
|
|
|
|
// - Add from open file
|
|
|
|
// - Check current list
|
|
|
|
// - Signal updated item
|
|
|
|
// -
|
|
|
|
typedef struct _recent_item_status {
|
|
|
|
QString filename;
|
|
|
|
qint64 size;
|
|
|
|
bool accessible;
|
|
|
|
bool in_thread;
|
|
|
|
} recent_item_status;
|
|
|
|
|
|
|
|
class WiresharkApplication : public QApplication
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit WiresharkApplication(int &argc, char **argv);
|
2012-11-03 22:48:29 +00:00
|
|
|
|
2013-01-18 00:50:14 +00:00
|
|
|
enum AppSignal {
|
2013-01-23 19:04:36 +00:00
|
|
|
ColumnsChanged,
|
2016-01-27 20:33:24 +00:00
|
|
|
CaptureFilterListChanged,
|
2016-01-27 20:30:52 +00:00
|
|
|
DisplayFilterListChanged,
|
2013-02-06 18:22:54 +00:00
|
|
|
FilterExpressionsChanged,
|
2016-10-18 13:00:39 +00:00
|
|
|
LocalInterfacesChanged,
|
2016-06-23 20:10:52 +00:00
|
|
|
NameResolutionChanged,
|
2013-01-18 00:50:14 +00:00
|
|
|
PacketDissectionChanged,
|
2013-10-30 23:54:46 +00:00
|
|
|
PreferencesChanged,
|
2015-02-19 01:18:27 +00:00
|
|
|
RecentFilesRead,
|
2014-11-06 10:19:25 +00:00
|
|
|
FieldsChanged
|
2013-01-18 00:50:14 +00:00
|
|
|
};
|
|
|
|
|
2016-10-19 08:19:28 +00:00
|
|
|
enum MainMenuItem {
|
|
|
|
FileOpenDialog,
|
|
|
|
CaptureOptionsDialog
|
|
|
|
};
|
|
|
|
|
2012-11-05 03:54:21 +00:00
|
|
|
void registerUpdate(register_action_e action, const char *message);
|
2013-01-18 00:50:14 +00:00
|
|
|
void emitAppSignal(AppSignal signal);
|
2015-08-26 18:24:29 +00:00
|
|
|
// Emitting app signals (PacketDissectionChanged in particular) from
|
|
|
|
// dialogs on OS X can be problematic. Dialogs should call queueAppSignal
|
|
|
|
// instead.
|
|
|
|
void queueAppSignal(AppSignal signal) { app_signals_ << signal; }
|
|
|
|
// Flush queued app signals. Should be called from the main window after
|
|
|
|
// each dialog that calls queueAppSignal closes.
|
|
|
|
void flushAppSignals();
|
2014-07-09 17:50:51 +00:00
|
|
|
void emitStatCommandSignal(const QString &menu_path, const char *arg, void *userdata);
|
2015-06-05 20:17:13 +00:00
|
|
|
void emitTapParameterSignal(const QString cfg_abbr, const QString arg, void *userdata);
|
2015-07-08 22:44:04 +00:00
|
|
|
void addDynamicMenuGroupItem(int group, QAction *sg_action);
|
2015-08-11 12:08:08 +00:00
|
|
|
void appendDynamicMenuGroupItem(int group, QAction *sg_action);
|
|
|
|
void removeDynamicMenuGroupItem(int group, QAction *sg_action);
|
2015-07-08 22:44:04 +00:00
|
|
|
QList<QAction *> dynamicMenuGroupItems(int group);
|
2015-08-11 12:08:08 +00:00
|
|
|
QList<QAction *> addedMenuGroupItems(int group);
|
|
|
|
QList<QAction *> removedMenuGroupItems(int group);
|
|
|
|
void clearAddedMenuGroupItems();
|
|
|
|
void clearRemovedMenuGroupItems();
|
2015-06-05 20:17:13 +00:00
|
|
|
|
2012-11-03 22:48:29 +00:00
|
|
|
void allSystemsGo();
|
2014-07-25 07:44:50 +00:00
|
|
|
void refreshLocalInterfaces();
|
2015-12-10 13:03:27 +00:00
|
|
|
struct _e_prefs * readConfigurationFiles(char **gdp_path, char **dp_path, bool reset);
|
2012-11-03 22:48:29 +00:00
|
|
|
QList<recent_item_status *> recentItems() const;
|
2015-09-11 18:13:23 +00:00
|
|
|
void addRecentItem(const QString filename, qint64 size, bool accessible);
|
2016-09-19 19:12:34 +00:00
|
|
|
void removeRecentItem(const QString &filename);
|
2012-09-17 23:40:53 +00:00
|
|
|
QDir lastOpenDir();
|
|
|
|
void setLastOpenDir(const char *dir_name);
|
|
|
|
void setLastOpenDir(QString *dir_str);
|
2012-10-16 19:47:43 +00:00
|
|
|
void helpTopicAction(topic_action_e action);
|
2014-09-23 20:35:10 +00:00
|
|
|
const QFont monospaceFont() const { return mono_font_; }
|
2013-01-24 01:10:12 +00:00
|
|
|
void setMonospaceFont(const char *font_string);
|
2014-09-23 20:35:10 +00:00
|
|
|
int monospaceTextSize(const char *str);
|
2012-12-29 01:39:02 +00:00
|
|
|
void setConfigurationProfile(const gchar *profile_name);
|
2016-01-03 12:48:39 +00:00
|
|
|
void reloadLuaPluginsDelayed();
|
2013-10-30 22:39:52 +00:00
|
|
|
bool isInitialized() { return initialized_; }
|
2015-08-11 12:08:08 +00:00
|
|
|
void setReloadingLua(bool is_reloading) { is_reloading_lua_ = is_reloading; }
|
|
|
|
bool isReloadingLua() { return is_reloading_lua_; }
|
2014-09-21 20:28:29 +00:00
|
|
|
const QIcon &normalIcon() const { return normal_icon_; }
|
|
|
|
const QIcon &captureIcon() const { return capture_icon_; }
|
2014-12-21 21:23:02 +00:00
|
|
|
const QString &windowTitleSeparator() const { return window_title_separator_; }
|
2014-12-22 23:51:36 +00:00
|
|
|
const QString windowTitleString(QStringList title_parts);
|
|
|
|
const QString windowTitleString(QString title_part) { return windowTitleString(QStringList() << title_part); }
|
2015-12-15 18:47:02 +00:00
|
|
|
void applyCustomColorsFromRecent();
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2013-12-21 16:55:43 +00:00
|
|
|
QTranslator translator;
|
|
|
|
QTranslator translatorQt;
|
2016-06-24 23:01:51 +00:00
|
|
|
void loadLanguage(const QString language);
|
2013-12-21 16:55:43 +00:00
|
|
|
|
2016-10-19 08:19:28 +00:00
|
|
|
void doTriggerMenuItem(MainMenuItem menuItem);
|
|
|
|
|
2012-01-04 22:13:01 +00:00
|
|
|
private:
|
2012-11-03 22:48:29 +00:00
|
|
|
bool initialized_;
|
2015-08-11 12:08:08 +00:00
|
|
|
bool is_reloading_lua_;
|
2014-09-23 20:35:10 +00:00
|
|
|
QFont mono_font_;
|
2013-11-21 01:28:17 +00:00
|
|
|
QTimer recent_timer_;
|
2014-04-29 15:10:27 +00:00
|
|
|
QTimer addr_resolv_timer_;
|
2013-11-21 01:28:17 +00:00
|
|
|
QTimer tap_update_timer_;
|
2012-11-03 22:48:29 +00:00
|
|
|
QList<QString> pending_open_files_;
|
2014-07-21 19:06:25 +00:00
|
|
|
QSocketNotifier *if_notifier_;
|
2014-09-21 20:28:29 +00:00
|
|
|
QIcon normal_icon_;
|
|
|
|
QIcon capture_icon_;
|
2014-12-21 21:23:02 +00:00
|
|
|
static QString window_title_separator_;
|
2015-08-26 18:24:29 +00:00
|
|
|
QList<AppSignal> app_signals_;
|
2015-10-03 16:45:16 +00:00
|
|
|
int active_captures_;
|
2015-12-15 18:47:02 +00:00
|
|
|
void storeCustomColorsInRecent();
|
2012-11-03 22:48:29 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
bool event(QEvent *event);
|
2012-01-04 22:13:01 +00:00
|
|
|
|
|
|
|
signals:
|
2012-11-05 03:54:21 +00:00
|
|
|
void appInitialized();
|
2014-07-21 23:30:31 +00:00
|
|
|
void localInterfaceListChanged();
|
2015-09-11 18:13:23 +00:00
|
|
|
void openCaptureFile(QString cf_path, QString display_filter, unsigned int type);
|
2016-10-19 08:19:28 +00:00
|
|
|
void openCaptureOptions();
|
2013-10-30 23:54:46 +00:00
|
|
|
void recentFilesRead();
|
2012-01-04 22:13:01 +00:00
|
|
|
void updateRecentItemStatus(const QString &filename, qint64 size, bool accessible);
|
2012-11-05 03:54:21 +00:00
|
|
|
void splashUpdate(register_action_e action, const char *message);
|
2015-02-19 01:18:27 +00:00
|
|
|
void profileChanging();
|
|
|
|
void profileNameChanged(const gchar *profile_name);
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2013-07-25 23:49:47 +00:00
|
|
|
void columnsChanged(); // XXX This recreates the packet list. We might want to rename it accordingly.
|
2016-01-27 20:33:24 +00:00
|
|
|
void captureFilterListChanged();
|
2016-01-27 20:30:52 +00:00
|
|
|
void displayFilterListChanged();
|
2013-02-06 18:22:54 +00:00
|
|
|
void filterExpressionsChanged();
|
2013-01-18 00:50:14 +00:00
|
|
|
void packetDissectionChanged();
|
|
|
|
void preferencesChanged();
|
2014-04-29 15:10:27 +00:00
|
|
|
void addressResolutionChanged();
|
2015-12-02 21:15:28 +00:00
|
|
|
void checkDisplayFilter();
|
2014-11-06 10:19:25 +00:00
|
|
|
void fieldsChanged();
|
2016-01-03 12:48:39 +00:00
|
|
|
void reloadLuaPlugins();
|
2013-01-18 00:50:14 +00:00
|
|
|
|
2014-07-09 17:50:51 +00:00
|
|
|
void openStatCommandDialog(const QString &menu_path, const char *arg, void *userdata);
|
2015-06-05 20:17:13 +00:00
|
|
|
void openTapParameterDialog(const QString cfg_str, const QString arg, void *userdata);
|
2014-07-09 17:50:51 +00:00
|
|
|
|
2012-01-04 22:13:01 +00:00
|
|
|
public slots:
|
|
|
|
void clearRecentItems();
|
2014-09-09 20:42:58 +00:00
|
|
|
void captureFileReadStarted();
|
2015-10-03 16:45:16 +00:00
|
|
|
void captureStarted() { active_captures_++; }
|
|
|
|
void captureFinished() { active_captures_--; }
|
2014-09-09 20:42:58 +00:00
|
|
|
void updateTaps();
|
2012-01-04 22:13:01 +00:00
|
|
|
|
|
|
|
private slots:
|
2013-03-06 22:04:17 +00:00
|
|
|
void cleanup();
|
2014-07-21 19:06:25 +00:00
|
|
|
void ifChangeEventsAvailable();
|
2014-07-09 21:31:44 +00:00
|
|
|
void itemStatusFinished(const QString filename = "", qint64 size = 0, bool accessible = false);
|
2012-01-04 22:13:01 +00:00
|
|
|
void refreshRecentFiles(void);
|
2014-04-29 15:10:27 +00:00
|
|
|
void refreshAddressResolution(void);
|
2012-01-04 22:13:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern WiresharkApplication *wsApp;
|
|
|
|
|
2014-01-11 12:16:56 +00:00
|
|
|
/** Global compile time version string */
|
2016-06-18 20:49:23 +00:00
|
|
|
extern void get_wireshark_qt_compiled_info(GString *str);
|
|
|
|
extern void get_gui_compiled_info(GString *str);
|
2014-01-11 12:16:56 +00:00
|
|
|
/** Global runtime version string */
|
2016-06-18 20:49:23 +00:00
|
|
|
extern void get_wireshark_runtime_info(GString *str);
|
2012-01-04 22:13:01 +00:00
|
|
|
#endif // WIRESHARK_APPLICATION_H
|
2012-09-04 08:18:31 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines
|
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* ex: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|