diff options
78 files changed, 8602 insertions, 1 deletions
diff --git a/config.h.win32 b/config.h.win32 index fa7e6bff18..d66faeb8be 100644 --- a/config.h.win32 +++ b/config.h.win32 @@ -272,4 +272,6 @@ #pragma warning ( disable : 6011 ) #endif +#if !defined(QT_VERSION) || !defined(_SSIZE_T_DEFINED) typedef int ssize_t; +#endif diff --git a/doc/README.qt b/doc/README.qt new file mode 100644 index 0000000000..de486f860c --- /dev/null +++ b/doc/README.qt @@ -0,0 +1,41 @@ +0. Abstract + +Wireshark's user interface is showing its age. While GTK+ is wonderful on Linux and BSD its low-tier status on Windows and even-lower-tier status on OS X makes it hard to deliver a good product to users on those platforms. + +The Qt port is an attempt at an updated UI which will better serve our users and let us add features more easily. + + +1. Getting up and running + +The Qt interface for Wireshark has been compiled and tested on Mac OS X 10.6 (XCode gcc), Windows 7 x86 (Visual C++ 2010), and Ubuntu 10.04 (gcc). Compilation via Qt Creator has been tested but command-line compilation using QMake and make or nmake should work. + +The ui/qt directory is loosely coupled with the rest of the codebase. The main Wireshark sources must be built beforehand using CMake on Linux and OS X and nmake on Windows. Autotools + QMake is a basket full of crazy that hasn't yet been sorted and folded. + +1.1 Prerequisites + +Before compiling you need the Qt SDK and Qt Creator. + +1.1.1 OS X + +Download the latest Qt SDK (currently 1.1.4) and install it. Build the top-level directory using CMake. + +1.1.2 Windows + +The default Qt SDK libraries are built using MinGW, which isn't supported for Wireshark. Instead of downloading the Qt SDK all-in-one package, download the Qt Libraries package that matches your compiler (VS 2008 or VS 2010) and Qt Creator for Windows. + +For the time being you must set win32:WIRESHARK_LIB_DIR in QtShark.pro to match the global build environment. The default location is c:/wireshark-win32-libs (yes, that's a forward slash). + +Before compiling select "Projects" in the left toolbar, select "Build Settings" and do the following: + +- In "Edit build configuration" make sure the "Release" build is selected. ("Debug" currently crashes.) +- Make sure "Qt version" matches your version of Visual Studio. +- Make sure "Tool chain" matches your Visual C++ version. + +1.1.3 Linux + +Install the Qt libraries and Qt Creator via your package manager or from http://qt.nokia.com/downloads/. On Debian and Ubuntu the "qt-sdk" meta-package should provide everything you need. Build the top-level directory using CMake. + + +2. Going forward + +DO NOT simply port things over. Every feature, window, and element should be re-thought. For example, should the user have to navigate two dialogs to get HTTP request statistics? diff --git a/gtk/recent.c b/gtk/recent.c index 43e6aedbde..fe9ce289fe 100644 --- a/gtk/recent.c +++ b/gtk/recent.c @@ -30,7 +30,9 @@ #include <string.h> #include <ctype.h> +#ifndef QT_GUI_LIB #include <gtk/gtk.h> +#endif #include <epan/epan.h> #include <epan/filesystem.h> @@ -44,6 +46,7 @@ #include <wsutil/file_util.h> #include "gtk/recent.h" +#ifndef QT_GUI_LIB #include "gtk/main.h" #include "gtk/menus.h" #include "gtk/gui_utils.h" @@ -54,6 +57,10 @@ #ifdef HAVE_PCAP_REMOTE #include "gtk/capture_dlg.h" #endif +#else /* QT_GUI_LIB */ +#include "qt_ui_utils.h" +#include "../file.h" +#endif /* QT_GUI_LIB */ #define RECENT_KEY_MAIN_TOOLBAR_SHOW "gui.toolbar_main_show" #define RECENT_KEY_FILTER_TOOLBAR_SHOW "gui.filter_toolbar_show" @@ -1096,4 +1103,3 @@ recent_set_column_xalign(gint col, gchar xalign) recent.col_width_list = g_list_append(recent.col_width_list, col_w); } } - diff --git a/ui/qt/QtShark.pro b/ui/qt/QtShark.pro new file mode 100644 index 0000000000..abd66040b9 --- /dev/null +++ b/ui/qt/QtShark.pro @@ -0,0 +1,217 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2010-12-21T11:38:10 +# +#------------------------------------------------- + +QT += core gui + +TARGET = Wireshark +TEMPLATE = app + +unix { + CONFIG += link_pkgconfig + PKGCONFIG += \ + glib-2.0 + + # Some versions of Ubuntu don't ship with zlib.pc + eval(PKGCONFIG += zlib) { + PKGCONFIG += zlib + } +} + +# XXX We need to figure out how to pull this in from config.nmake. +win32:WIRESHARK_LIB_DIR = c:/wireshark-win32-libs +win32:GLIB_DIR = $${WIRESHARK_LIB_DIR}/gtk2 +win32:C_ARES_DIR = $${WIRESHARK_LIB_DIR}/c-ares-1.7.1-win32ws +win32:ZLIB_DIR = $${WIRESHARK_LIB_DIR}/zlib125 +win32:GNUTLS_DIR = $${WIRESHARK_LIB_DIR}/gnutls-2.10.3-1.11-win32ws +win32:SMI_DIR = $${WIRESHARK_LIB_DIR}/libsmi-svn-40773-win32ws +win32:KFW_DIR = $${WIRESHARK_LIB_DIR}/kfw-3-2-2-i386-ws-vc6 +win32:LUA_DIR = $${WIRESHARK_LIB_DIR}/lua5.1.4 + +INCLUDEPATH += ../.. ../../wiretap +win32:INCLUDEPATH += \ + $${WIRESHARK_LIB_DIR}/gtk2/include/glib-2.0 $${WIRESHARK_LIB_DIR}/gtk2/lib/glib-2.0/include \ + $${WIRESHARK_LIB_DIR}/WpdPack/Include \ + $${WIRESHARK_LIB_DIR}/AirPcap_Devpack_4_1_0_1622/Airpcap_Devpack/include \ + $${WIRESHARK_LIB_DIR}/zlib125/include + +# XXX - If we add ../../gtk/recent.c to SOURCES, jom will try to compile everything +# in ../../gtk. Until we move the things we need in recent.c to a common file, simply +# copy it to our current directory. +recent.target = recent.c +!win32:recent.commands = $$QMAKE_COPY ../../gtk/$$recent.target . +win32:recent.commands = $$QMAKE_COPY ../..\\gtk\\$$recent.target . +recent.depends = ../../gtk/$$recent.target +QMAKE_EXTRA_TARGETS += recent + +SOURCES += \ + ../../airpcap_loader.c \ + ../../alert_box.c \ + ../../capture-pcap-util.c \ + ../../capture.c \ + ../../capture_ifinfo.c \ + ../../capture_info.c \ + ../../capture_opts.c \ + ../../capture_sync.c \ + ../../capture_ui_utils.c \ + ../../cfile.c \ + ../../clopts_common.c \ + ../../color_filters.c \ + ../../disabled_protos.c \ + ../../file.c \ + ../../fileset.c \ + ../../filters.c \ + ../../frame_data_sequence.c \ + ../../g711.c \ + ../../merge.c \ + ../../packet-range.c \ + ../../print.c \ + ../../proto_hier_stats.c \ + ../../ps.c \ + ../../summary.c \ + ../../sync_pipe_write.c \ + ../../tap-megaco-common.c \ + ../../tap-rtp-common.c \ + ../../tempfile.c \ + ../../timestats.c \ + ../../u3.c \ + ../../util.c \ + ../../version_info.c \ + byte_view_tab.cpp \ + byte_view_text.cpp \ + capture_file_dialog.cpp \ + capture_info_dialog.cpp \ + capture_interface_dialog.cpp \ + color_dialog.cpp \ + color_utils.cpp \ + display_filter_combo.cpp \ + display_filter_edit.cpp \ + fileset_dialog.cpp \ + interface_tree.cpp \ + main.cpp \ + main_status_bar.cpp \ + main_welcome.cpp \ + main_window.cpp \ + monospace_font.cpp \ + packet_list.cpp \ + packet_list_model.cpp \ + packet_list_record.cpp \ + progress_dialog.cpp \ + proto_tree.cpp \ + qt_ui_utils.cpp \ + recent.c \ + recent_file_status.cpp \ + simple_dialog_qt.cpp \ + wireshark_application.cpp \ + + +unix:SOURCES += ../../capture-pcap-util-unix.c +win32:SOURCES += ../../capture-wpcap.c ../../capture_wpcap_packet.c + +HEADERS += \ + ../../wsutil/privileges.h \ + byte_view_tab.h \ + byte_view_text.h \ + capture_file_dialog.h \ + capture_info_dialog.h \ + capture_interface_dialog.h \ + color_dialog.h \ + color_utils.h \ + display_filter_combo.h \ + display_filter_edit.h \ + fileset_dialog.h \ + interface_tree.h \ + main_status_bar.h \ + main_welcome.h \ + main_window.h \ + monospace_font.h \ + packet_list.h \ + packet_list_model.h \ + packet_list_record.h \ + progress_dialog.h \ + proto_tree.h \ + qt_ui_utils.h \ + qt_ui_utils.h \ + recent_file_status.h \ + simple_dialog_qt.h \ + wireshark_application.h \ + + +FORMS += main_window.ui + +DEFINES += HAVE_CONFIG_H INET6 REENTRANT +unix:DEFINES += _U_=\"__attribute__((unused))\" +win32:DEFINES += \ + MSVC_VARIANT=MSVC2010 MSC_VER_REQUIRED=1600 \ + _U_= _NEED_VAR_IMPORT_ \ + _CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_DEPRECATE _BIND_TO_CURRENT_CRT_VERSION=1 \ + + +# We need to pull in config.nmake somehow. +#win32:DEFINES += MSC_VER_REQUIRED=1600 _U_= IPV6STRICT +win32:WIRESHARK_LOCAL_CFLAGS = \ + /Zi /W3 /MD /DWIN32_LEAN_AND_MEAN \ + /MP /GS +win32:QMAKE_CFLAGS += $${WIRESHARK_LOCAL_CFLAGS} +win32:QMAKE_CXXFLAGS += $${WIRESHARK_LOCAL_CFLAGS} + +# http://stackoverflow.com/questions/3984104/qmake-how-to-copy-a-file-to-the-output +unix:!mac { + EXTRA_BINFILES = \ + ../../dumpcap \ + + for(FILE,EXTRA_BINFILES){ + QMAKE_POST_LINK += $$quote(cp $${FILE} .$$escape_expand(\n\t)) + } +} +# qmake 2.01a / Qt 4.7.0 doesn't set DESTDIR on OS X. +mac { + EXTRA_BINFILES = \ + ../../dumpcap \ + + for(FILE,EXTRA_BINFILES){ + QMAKE_POST_LINK += $$quote(cp $${FILE} Wireshark.app/Contents/MacOS$$escape_expand(\n\t)) + } +} +win32 { + EXTRA_BINFILES = \ + ../../dumpcap.exe \ + ../../epan/libwireshark.dll ../../wiretap/wiretap-1.7.0.dll ../../wsutil/libwsutil.dll \ + $${GLIB_DIR}/bin/libglib-2.0-0.dll $${GLIB_DIR}/bin/libgmodule-2.0-0.dll \ + $${GLIB_DIR}/bin/libgthread-2.0-0.dll $${GLIB_DIR}/bin/intl.dll \ + $${C_ARES_DIR}/bin/libcares-2.dll $${ZLIB_DIR}/zlib1.dll \ + $${GNUTLS_DIR}/bin/libgcrypt-11.dll $${GNUTLS_DIR}/bin/libgnutls-26.dll \ + $${GNUTLS_DIR}/bin/libgpg-error-0.dll $${GNUTLS_DIR}/bin/ $${GNUTLS_DIR}/bin/libtasn1-3.dll \ + $${GNUTLS_DIR}/bin/libintl-8.dll $${SMI_DIR}/bin/libsmi-2.dll \ + $${KFW_DIR}/bin/comerr32.dll $${KFW_DIR}/bin/krb5_32.dll $${KFW_DIR}/bin/k5sprt32.dll \ + $${LUA_DIR}/lua5.1.dll \ + ../../colorfilters ../../dfilters ../../cfilters + + EXTRA_BINFILES ~= s,/,\\,g + for(FILE,EXTRA_BINFILES){ + message("$${DESTDIR_WIN}") + QMAKE_POST_LINK +=$$quote(cmd /c copy /y $${FILE} $(DESTDIR)$$escape_expand(\n\t)) + } +} + +macx:QMAKE_LFLAGS += \ + -framework CoreServices \ + -framework ApplicationServices -framework CoreFoundation -framework CoreServices + +unix:LIBS += -L../../lib -Wl,-rpath ../../lib -lwireshark -lwiretap -lwsutil \ + -lpcap +macx:LIBS += -Wl,-macosx_version_min,10.5 -liconv + +win32:LIBS += \ + wsock32.lib user32.lib shell32.lib comctl32.lib \ + -L../../epan -llibwireshark -L../../wsutil -llibwsutil -L../../wiretap -lwiretap-1.7.0 \ + -L$${GLIB_DIR}/lib -lglib-2.0 -lgmodule-2.0 + +RESOURCES += \ + toolbar.qrc \ + welcome.qrc \ + display_filter.qrc + +ICON = ../../packaging/macosx/Resources/Wireshark.icns diff --git a/ui/qt/byte_view_tab.cpp b/ui/qt/byte_view_tab.cpp new file mode 100644 index 0000000000..e876d47e97 --- /dev/null +++ b/ui/qt/byte_view_tab.cpp @@ -0,0 +1,92 @@ +/* byte_view_tab.cpp + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "byte_view_tab.h" +#include "byte_view_text.h" +#include <QTabBar> +#include <QTreeWidgetItem> + +ByteViewTab::ByteViewTab(QWidget *parent) : + QTabWidget(parent) +{ + setAccessibleName("Packet bytes"); + addTab(); +} + +void ByteViewTab::addTab(const char *name, tvbuff_t *tvb, proto_tree *tree, QTreeWidget *protoTree, unsigned int encoding) { + ByteViewText *byteViewText = new ByteViewText(this, tvb, tree, protoTree, encoding); + + byteViewText->setAccessibleName(name); + QTabWidget::addTab(byteViewText, name); +} + +void ByteViewTab::tabInserted(int index) { + setTabsVisible(); + QTabWidget::tabInserted(index); +} + +void ByteViewTab::tabRemoved(int index) { + setTabsVisible(); + QTabWidget::tabRemoved(index); +} + +void ByteViewTab::setTabsVisible() { + if (count() > 1) + tabBar()->show(); + else + tabBar()->hide(); +} + +void ByteViewTab::protoTreeItemChanged(QTreeWidgetItem *current) { + if (current) { + field_info *fi; + + QVariant v = current->data(0, Qt::UserRole); + fi = (field_info *) v.value<void *>(); +// g_log(NULL, G_LOG_LEVEL_DEBUG, "fi selected %p", fi); + + int i = 0; + ByteViewText *byteViewText = dynamic_cast<ByteViewText*>(widget(i)); + while (byteViewText) { + if (byteViewText->hasDataSource(fi->ds_tvb)) { + QTreeWidgetItem *parent = current->parent(); + field_info *parent_fi = NULL; + while (parent && parent->parent()) { + parent = parent->parent(); + } + if (parent) { + v = parent->data(0, Qt::UserRole); + parent_fi = (field_info *) v.value<void *>(); + } + if (parent_fi && parent_fi->ds_tvb == fi->ds_tvb) { + byteViewText->highlight(parent_fi->start, parent_fi->length, true); + } else { + byteViewText->highlight(0, 0, true); + } + byteViewText->highlight(fi->start, fi->length); + setCurrentIndex(i); + } + byteViewText = dynamic_cast<ByteViewText*>(widget(++i)); + } + } +} diff --git a/ui/qt/byte_view_tab.h b/ui/qt/byte_view_tab.h new file mode 100644 index 0000000000..862193732d --- /dev/null +++ b/ui/qt/byte_view_tab.h @@ -0,0 +1,56 @@ +/* byte_view_tab.h + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef BYTE_VIEW_TAB_H +#define BYTE_VIEW_TAB_H + +#include "config.h" + +#include <epan/packet.h> +#include <epan/proto.h> +#include <epan/tvbuff.h> + +#include <QTabWidget> +#include <QTreeWidget> + +class ByteViewTab : public QTabWidget +{ + Q_OBJECT +public: + explicit ByteViewTab(QWidget *parent = 0); + void addTab(const char *name = "", tvbuff_t *tvb = NULL, proto_tree *tree = NULL, QTreeWidget *protoTree = NULL, unsigned int encoding = PACKET_CHAR_ENC_CHAR_ASCII); + +private: + void setTabsVisible(); + +protected: + void tabInserted(int index); + void tabRemoved(int index); + +signals: + +public slots: + void protoTreeItemChanged(QTreeWidgetItem *current); +}; + +#endif // BYTE_VIEW_TAB_H diff --git a/ui/qt/byte_view_text.cpp b/ui/qt/byte_view_text.cpp new file mode 100644 index 0000000000..32650593b3 --- /dev/null +++ b/ui/qt/byte_view_text.cpp @@ -0,0 +1,638 @@ +/* byte_view_text.cpp + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "monospace_font.h" +#include "byte_view_text.h" + +#include <epan/charsets.h> + +#include <QTextCursor> +#include <QApplication> +#include <QMouseEvent> + +// XXX - Use KHexEdit instead? +// http://api.kde.org/4.x-api/kdelibs-apidocs/interfaces/khexedit/html/index.html + +ByteViewText::ByteViewText(QWidget *parent, tvbuff_t *tvb, proto_tree *tree, QTreeWidget *protoTree, unsigned int encoding) : + QTextEdit(parent) +{ + setReadOnly(true); + setLineWrapMode(QTextEdit::NoWrap); + setCurrentFont(get_monospace_font()); + + m_tvb = tvb; + m_tree = tree; + m_protoTree = protoTree; + m_encoding = encoding; + m_start = m_len = 0; + +// m_background = textBackgroundColor(); +// m_foreground = textColor(); + +// g_log(NULL, G_LOG_LEVEL_DEBUG, "fg %d %d %d bg %d %d %d", +// m_foreground.red(), m_foreground.green(), m_foreground.blue(), +// m_background.red(), m_background.green(), m_background.blue() +// ); + + hexPrintCommon(); +} + +#define MAX_OFFSET_LEN 8 /* max length of hex offset of bytes */ +#define BYTES_PER_LINE 16 /* max byte values in a line */ +#define BITS_PER_LINE 8 /* max bit values in a line */ +#define BYTE_VIEW_SEP 8 /* insert a space every BYTE_VIEW_SEP bytes */ +#define HEX_DUMP_LEN (BYTES_PER_LINE*3 + 1) +/* max number of characters hex dump takes - + 2 digits plus trailing blank + plus separator between first and + second 8 digits */ +#define DATA_DUMP_LEN (HEX_DUMP_LEN + 2 + BYTES_PER_LINE) +/* number of characters those bytes take; + 3 characters per byte of hex dump, + 2 blanks separating hex from ASCII, + 1 character per byte of ASCII dump */ +#define MAX_LINE_LEN (MAX_OFFSET_LEN + 2 + DATA_DUMP_LEN) +/* number of characters per line; + offset, 2 blanks separating offset + from data dump, data dump */ +#define MAX_LINES 100 +#define MAX_LINES_LEN (MAX_LINES*MAX_LINE_LEN) + +// Copied from packet_hex_print_common +void +ByteViewText::hexPrintCommon() +{ + int i = 0, j, k = 0, b, len; + const guint8 *pd; + QString line; + static guchar hexchars[16] = { + '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; + static const guint8 bitmask[8] = { + 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; + guchar c = '\0'; + +// progdlg_t *progbar = NULL; +// float progbar_val; +// gboolean progbar_stop_flag; +// GTimeVal progbar_start_time; +// gchar progbar_status_str[100]; +// int progbar_nextstep; +// int progbar_quantum; + + setPlainText(""); + // Replaces get_byte_view_data_and_length(). + if (!m_tvb) + return; + len = tvb_length(m_tvb); + pd = tvb_get_ptr(m_tvb, 0, -1); + + /* + * How many of the leading digits of the offset will we supply? + * We always supply at least 4 digits, but if the maximum offset + * won't fit in 4 digits, we use as many digits as will be needed. + */ + if (((len - 1) & 0xF0000000) != 0) + m_useDigits = 8; /* need all 8 digits */ + else if (((len - 1) & 0x0F000000) != 0) + m_useDigits = 7; /* need 7 digits */ + else if (((len - 1) & 0x00F00000) != 0) + m_useDigits = 6; /* need 6 digits */ + else if (((len - 1) & 0x000F0000) != 0) + m_useDigits = 5; /* need 5 digits */ + else + m_useDigits = 4; /* we'll supply 4 digits */ + + /* Update the progress bar when it gets to this value. */ +// if (len > MIN_PACKET_LENGTH){ +// progbar_nextstep = 0; +// }else{ +// /* If length =< MIN_PACKET_LENGTH +// * there is no need to calculate the progress +// */ +// progbar_nextstep = len+1; +// } + +// /* When we reach the value that triggers a progress bar update, +// bump that value by this amount. */ +// progbar_quantum = len/N_PROGBAR_UPDATES; +// /* Progress so far. */ +// progbar_val = 0.0f; + +// progbar_stop_flag = FALSE; +// g_get_current_time(&progbar_start_time); + + while (i < len) { + /* Create the progress bar if necessary. + We check on every iteration of the loop, so that it takes no + longer than the standard time to create it (otherwise, for a + large packet, we might take considerably longer than that standard + time in order to get to the next progress bar step). */ +// if ((progbar == NULL) && (len > MIN_PACKET_LENGTH)) +// progbar = delayed_create_progress_dlg("Processing", "Packet Details", +// TRUE, +// &progbar_stop_flag, +// &progbar_start_time, +// progbar_val); + + /* Update the progress bar, but do it only N_PROGBAR_UPDATES times; + when we update it, we have to run the GTK+ main loop to get it + to repaint what's pending, and doing so may involve an "ioctl()" + to see if there's any pending input from an X server, and doing + that for every packet can be costly, especially on a big file. */ +// if (i >= progbar_nextstep) { + +// if (progbar != NULL) { +// /* let's not divide by zero. I should never be started +// * with count == 0, so let's assert that +// */ +// g_assert(len > 0); +// progbar_val = (gfloat) i / len; +// g_snprintf(progbar_status_str, sizeof(progbar_status_str), +// "%4u of %u bytes", i, len); +// update_progress_dlg(progbar, progbar_val, progbar_status_str); +// } + +// progbar_nextstep += progbar_quantum; +// } + +// if (progbar_stop_flag) { +// /* Well, the user decided to abort the operation. Just stop, +// and arrange to return TRUE to our caller, so they know it +// was stopped explicitly. */ +// break; +// } + + /* Print the line number */ + j = m_useDigits; + do { + j--; + c = (i >> (j*4)) & 0xF; + line += hexchars[c]; + } while (j != 0); + line += " "; + + j = i; +// switch (recent.gui_bytes_view) { +// case BYTES_HEX: + k = i + BYTES_PER_LINE; +// break; +// case BYTES_BITS: +// k = i + BITS_PER_LINE; +// break; +// default: +// g_assert_not_reached(); +// } + /* Print the hex bit */ + while (i < k) { + if (i < len) { +// switch (recent.gui_bytes_view) { +// case BYTES_HEX: + line += hexchars[(pd[i] & 0xf0) >> 4]; + line += hexchars[pd[i] & 0x0f]; +// break; +// case BYTES_BITS: +// for (b = 0; b < 8; b++) { +// line += (pd[i] & bitmask[b]) ? '1' : '0'; +// } +// break; +// default: +// g_assert_not_reached(); +// } + } else { +// switch (recent.gui_bytes_view) { +// case BYTES_HEX: + line += " "; +// break; +// case BYTES_BITS: +// for (b = 0; b < 8; b++) { +// line += ' '; +// } +// break; +// default: +// g_assert_not_reached(); +// } + } + i++; + /* Inter byte space if not at end of line */ + if (i < k) { + line += ' '; + /* insert a space every BYTE_VIEW_SEP bytes */ + if( ( i % BYTE_VIEW_SEP ) == 0 ) { + line += ' '; + } + } + } + + /* Print some space at the end of the line */ + line += " "; + + /* Print the ASCII bit */ + i = j; + + while (i < k) { + if (i < len) { + if (m_encoding == PACKET_CHAR_ENC_CHAR_ASCII) { + c = pd[i]; + } + else if (m_encoding == PACKET_CHAR_ENC_CHAR_EBCDIC) { + c = EBCDIC_to_ASCII1(pd[i]); + } + else { + g_assert_not_reached(); + } + line += isprint(c) ? c : '.'; + } else { + line += ' '; + } + i++; + if (i < k) { + /* insert a space every BYTE_VIEW_SEP bytes */ + if( ( i % BYTE_VIEW_SEP ) == 0 ) { + line += ' '; + } + } + } + line += '\n'; + if (line.length() >= (MAX_LINES_LEN - MAX_LINE_LEN)) { + append(line); + line.clear(); + } + } + +// /* We're done printing the packets; destroy the progress bar if +// it was created. */ +// if (progbar != NULL) +// destroy_progress_dlg(progbar); + + if (line.length()) { + append(line); + } +} + +bool ByteViewText::hasDataSource(tvbuff_t *ds_tvb) { + if (ds_tvb != NULL && ds_tvb == m_tvb) + return true; + return false; +} + +// Copied from packet_hex_apply_reverse_tag +void ByteViewText::highlight(int bstart, int blen, bool is_root) { + m_start = bstart; +// m_len = blen; + +// g_log(NULL, G_LOG_LEVEL_DEBUG, "hl %d %d %d %d", start, len, m_foreground.color().red(), m_background.color().red()); + QTextCursor cursor(textCursor()); + QTextCharFormat format = cursor.charFormat(); + + QPalette pal = QApplication::palette(); + + if (is_root) { + cursor.movePosition(QTextCursor::Start); + cursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor); + format.setForeground(pal.text()); + format.setBackground(pal.base()); + cursor.setCharFormat(format); + } + + // XXX - We should probably use the same colors as the packet list and proto tree selections. + // It isn't obvious how to fetch these. + format.setForeground(is_root ? pal.text() : pal.base()); + format.setBackground(is_root ? pal.alternateBase() : pal.text()); + + int bend = bstart + blen; + int per_line = 0; + int per_one = 0; + int bits_per_one = 0; + int hex_offset, ascii_offset; + + int start_line, start_line_pos; + int stop_line, stop_line_pos; + + if (bstart == -1 || blen == -1) + return; + +// /* Display with inverse video ? */ +// if (prefs.gui_hex_dump_highlight_style) +// revstyle = "reverse"; +// else +// revstyle = "bold"; + +// switch (recent.gui_bytes_view) { +// case BYTES_HEX: + per_line = BYTES_PER_LINE; + per_one = 2+1; /* "ff " */ + bits_per_one = 4; +// break; +// case BYTES_BITS: +// per_line = BITS_PER_LINE; +// per_one = 8+1; /* "10101010 " */ +// bits_per_one = 1; +// break; +// default: +// g_assert_not_reached(); +// } + + start_line = bstart / per_line; + start_line_pos = bstart % per_line; + + stop_line = bend / per_line; + stop_line_pos = bend % per_line; + +#define hex_fix(pos) hex_offset + (pos * per_one) + (pos / BYTE_VIEW_SEP) - (pos == per_line) +#define ascii_fix(pos) pos + (pos / BYTE_VIEW_SEP) - (pos == per_line) + + hex_offset = m_useDigits + 2; + ascii_offset = hex_fix(per_line) + 2; + + cursor.setPosition(0); + cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, start_line); + +// if (mask == 0x00) { + while (start_line <= stop_line) { + int line_pos_end = (start_line == stop_line) ? stop_line_pos : per_line; +// int first_block_adjust = (recent.gui_bytes_view == BYTES_HEX) ? (line_pos_end == per_line/2) : 0; + int first_block_adjust = line_pos_end == per_line/2; + + if (start_line_pos == line_pos_end) break; + + // Should we just jump to absolute offsets instead? + /* bits/hex */ + int cursor_start = hex_fix(start_line_pos); + int cursor_len = hex_fix(line_pos_end) - cursor_start - 1 - first_block_adjust; + cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, cursor_start); + cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, cursor_len); + cursor.setCharFormat(format); + cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, ascii_offset - cursor_start - cursor_len); + + /* ascii */ + cursor_start = ascii_fix(start_line_pos); + cursor_len = ascii_fix(line_pos_end) - cursor_start - first_block_adjust; + cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, cursor_start); + cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, cursor_len); + cursor.setCharFormat(format); + + start_line_pos = 0; + start_line++; + // You are encouraged to make carriage return and line feed sound + // effects as you read the next two lines. + cursor.movePosition(QTextCursor::StartOfLine); + cursor.movePosition(QTextCursor::Down); + } + +// } else if (mask_le) { /* LSB of mask first (little-endian) */ +// while (start_line <= stop_line) { +// int line_pos_end = (start_line == stop_line) ? stop_line_pos : per_line; +// int line_pos = start_line_pos; + +// while (line_pos < line_pos_end) { +// int lop = 8 / bits_per_one; +// int mask_per_one = (1 << bits_per_one) - 1; +// int ascii_on = 0; + +// while (lop--) { +// if ((mask & mask_per_one)) { +// /* bits/hex */ +// gtk_text_buffer_get_iter_at_line_index(buf, &i_start, start_line, hex_fix(line_pos)+lop); +// gtk_text_buffer_get_iter_at_line_index(buf, &i_stop, start_line, hex_fix(line_pos)+lop+1); +// gtk_text_buffer_apply_tag(buf, revstyle_tag, &i_start, &i_stop); + +// ascii_on = 1; +// } +// mask >>= bits_per_one; +// } + +// /* at least one bit of ascii was one -> turn ascii on */ +// if (ascii_on) { +// /* ascii */ +// gtk_text_buffer_get_iter_at_line_index(buf, &i_start, start_line, ascii_fix(line_pos)); +// gtk_text_buffer_get_iter_at_line_index(buf, &i_stop, start_line, ascii_fix(line_pos)+1); +// gtk_text_buffer_apply_tag(buf, revstyle_tag, &i_start, &i_stop); +// } + +// if (!mask) +// goto xend; + +// line_pos++; +// } + +// start_line_pos = 0; +// start_line++; +// } +// } else { /* mask starting from end (big-endian) */ +// while (start_line <= stop_line) { +// int line_pos_start = (start_line == stop_line) ? start_line_pos : 0; +// int line_pos = stop_line_pos-1; + +// while (line_pos >= line_pos_start) { +// int lop = 8 / bits_per_one; +// int mask_per_one = (1 << bits_per_one) - 1; +// int ascii_on = 0; + +// while (lop--) { +// if ((mask & mask_per_one)) { +// /* bits/hex */ +// gtk_text_buffer_get_iter_at_line_index(buf, &i_start, stop_line, hex_fix(line_pos)+lop); +// gtk_text_buffer_get_iter_at_line_index(buf, &i_stop, stop_line, hex_fix(line_pos)+lop+1); +// gtk_text_buffer_apply_tag(buf, revstyle_tag, &i_start, &i_stop); + +// ascii_on = 1; +// } +// mask >>= bits_per_one; +// } + +// /* at least one bit of ascii was one -> turn ascii on */ +// if (ascii_on) { +// /* ascii */ +// gtk_text_buffer_get_iter_at_line_index(buf, &i_start, stop_line, ascii_fix(line_pos)); +// gtk_text_buffer_get_iter_at_line_index(buf, &i_stop, stop_line, ascii_fix(line_pos)+1); +// gtk_text_buffer_apply_tag(buf, revstyle_tag, &i_start, &i_stop); +// } + +// if (!mask) +// goto xend; + +// line_pos--; +// } + +// stop_line_pos = per_line; +// stop_line--; +// } +// } +//xend: + +#undef hex_fix +#undef ascii_fix +} + +// XXX - Copied from main_proto_draw.c +/* Which byte the offset is referring to. Associates + * whitespace with the preceding digits. */ +static int +byte_num(int offset, int start_point) +{ + return (offset - start_point) / 3; +} + +// XXX - Copied from main_proto_draw.c +static int +bit_num(int offset, int start_point) +{ + return (offset - start_point) / 9; +} + +// XXX - Copied from main_proto_draw.c +static int +hex_view_get_byte(guint ndigits, int row, int column) +{ + int byte; + int digits_start_1; + int digits_end_1; + int digits_start_2; + int digits_end_2; + int text_start_1; + int text_end_1; + int text_start_2; + int text_end_2; + + /* + * The column of the first hex digit in the first half. + * That starts after "ndigits" digits of offset and two + * separating blanks. + */ + digits_start_1 = ndigits + 2; + + /* + * The column of the last hex digit in the first half. + * There are BYTES_PER_LINE/2 bytes displayed in the first + * half; there are 2 characters per byte, plus a separating + * blank after all but the last byte's characters. + */ + digits_end_1 = digits_start_1 + (BYTES_PER_LINE/2)*2 + + (BYTES_PER_LINE/2 - 1); + + /* + * The column of the first hex digit in the second half. + * Add 2 for the 2 separating blanks between the halves. + */ + digits_start_2 = digits_end_1 + 2; + + /* + * The column of the last hex digit in the second half. + * Add the same value we used to get "digits_end_1" from + * "digits_start_1". + */ + digits_end_2 = digits_start_2 + (BYTES_PER_LINE/2)*2 + + (BYTES_PER_LINE/2 - 1); + + /* + * The column of the first "text dump" character in the first half. + * Add 3 for the 3 separating blanks between the hex and text dump. + */ + text_start_1 = digits_end_2 + 3; + + /* + * The column of the last "text dump" character in the first half. + * There are BYTES_PER_LINE/2 bytes displayed in the first + * half; there is 1 character per byte. + * + * Then subtract 1 to get the last column of the first half + * rather than the first column after the first half. + */ + text_end_1 = text_start_1 + BYTES_PER_LINE/2 - 1; + + /* + * The column of the first "text dump" character in the second half. + * Add back the 1 to get the first column after the first half, + * and then add 1 for the separating blank between the halves. + */ + text_start_2 = text_end_1 + 2; + + /* + * The column of the last "text dump" character in second half. + * Add the same value we used to get "text_end_1" from + * "text_start_1". + */ + text_end_2 = text_start_2 + BYTES_PER_LINE/2 - 1; + + /* Given the column and row, determine which byte offset + * the user clicked on. */ + if (column >= digits_start_1 && column <= digits_end_1) { + byte = byte_num(column, digits_start_1); + if (byte == -1) { + return byte; + } + } + else if (column >= digits_start_2 && column <= digits_end_2) { + byte = byte_num(column, digits_start_2); + if (byte == -1) { + return byte; + } + byte += 8; + } + else if (column >= text_start_1 && column <= text_end_1) { + byte = column - text_start_1; + } + else if (column >= text_start_2 && column <= text_end_2) { + byte = 8 + column - text_start_2; + } + else { + /* The user didn't select a hex digit or + * text-dump character. */ + return -1; + } + + /* Add the number of bytes from the previous rows. */ + byte += row * BYTES_PER_LINE; + + return byte; +} + +void ByteViewText::mousePressEvent (QMouseEvent * event) { + if (event->button() == Qt::LeftButton) { + int byte; + QTextCursor cursor(cursorForPosition(event->pos())); + field_info *fi; + + byte = hex_view_get_byte(m_useDigits, cursor.blockNumber(), cursor.columnNumber()); + fi = proto_find_field_from_offset(m_tree, byte, m_tvb); + g_log(NULL, G_LOG_LEVEL_DEBUG, "byte %d fi %p", byte, fi); + + if (fi && m_protoTree) { + // XXX - This should probably be a ProtoTree method. + QTreeWidgetItemIterator iter(m_protoTree); + QVariant v; + while (*iter) { + v = (*iter)->data(0, Qt::UserRole); + if (fi == (field_info *) v.value<void *>()) { + g_log(NULL, G_LOG_LEVEL_DEBUG, "found %p", fi); + m_protoTree->setCurrentItem((*iter)); + } + + iter++; + } + } + } + + QWidget::mousePressEvent (event); +} diff --git a/ui/qt/byte_view_text.h b/ui/qt/byte_view_text.h new file mode 100644 index 0000000000..0db1339911 --- /dev/null +++ b/ui/qt/byte_view_text.h @@ -0,0 +1,62 @@ +/* byte_view_text.h + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef BYTE_VIEW_TEXT_H +#define BYTE_VIEW_TEXT_H + +#include "config.h" + +#include <epan/packet.h> +#include <epan/proto.h> +#include <epan/tvbuff.h> + +#include "proto_tree.h" +#include <QTextEdit> + +// XXX - Is there any reason we shouldn't add ByteViewImage, etc? + +class ByteViewText : public QTextEdit +{ + Q_OBJECT +public: + explicit ByteViewText(QWidget *parent = 0, tvbuff_t *tvb = NULL, proto_tree *tree = NULL, QTreeWidget *protoTree = NULL, unsigned int encoding = PACKET_CHAR_ENC_CHAR_ASCII); + void hexPrintCommon(); + bool hasDataSource(tvbuff_t *ds_tvb = NULL); + void highlight(int start, int len, bool is_root = false); + +private: + tvbuff_t *m_tvb; + proto_tree *m_tree; + QTreeWidget *m_protoTree; + int m_encoding; + unsigned int m_useDigits; + int m_start, m_len; + void mousePressEvent (QMouseEvent * event); + +signals: + +public slots: + +}; + +#endif // BYTE_VIEW_TEXT_H diff --git a/ui/qt/capture_file_dialog.cpp b/ui/qt/capture_file_dialog.cpp new file mode 100644 index 0000000000..4c29c08038 --- /dev/null +++ b/ui/qt/capture_file_dialog.cpp @@ -0,0 +1,29 @@ +/* capture_file_dialog.cpp + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "capture_file_dialog.h" + +CaptureFileDialog::CaptureFileDialog(QWidget *parent) : + QFileDialog(parent) +{ +} diff --git a/ui/qt/capture_file_dialog.h b/ui/qt/capture_file_dialog.h new file mode 100644 index 0000000000..d4daae1b02 --- /dev/null +++ b/ui/qt/capture_file_dialog.h @@ -0,0 +1,41 @@ +/* capture_file_dialog.h + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef CAPTURE_FILE_DIALOG_H +#define CAPTURE_FILE_DIALOG_H + +#include <QFileDialog> + +class CaptureFileDialog : public QFileDialog +{ + Q_OBJECT +public: + explicit CaptureFileDialog(QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // CAPTURE_FILE_DIALOG_H diff --git a/ui/qt/capture_info_dialog.cpp b/ui/qt/capture_info_dialog.cpp new file mode 100644 index 0000000000..63d13999f7 --- /dev/null +++ b/ui/qt/capture_info_dialog.cpp @@ -0,0 +1,63 @@ +/* capture_info_dialog.cpp + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <glib.h> + +#include <epan/packet.h> + +#include "capture_info_dialog.h" +#include "capture_info.h" + +/* create the capture info dialog */ +/* will keep pointers to the fields in the counts parameter */ +void capture_info_ui_create( +capture_info *cinfo, +capture_options *capture_opts) +{ + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: capture_info_ui_create"); +} + +/* update the capture info dialog */ +/* As this function is a bit time critical while capturing, */ +/* prepare everything possible in the capture_info_ui_create() function above! */ +void capture_info_ui_update( +capture_info *cinfo) +{ + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: capture_info_ui_update"); +} + +/* destroy the capture info dialog again */ +void capture_info_ui_destroy( +capture_info *cinfo) +{ + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: capture_info_ui_destroy"); +} + +CaptureInfoDialog::CaptureInfoDialog(QWidget *parent) : + QDialog(parent) +{ +} diff --git a/ui/qt/capture_info_dialog.h b/ui/qt/capture_info_dialog.h new file mode 100644 index 0000000000..be7721944e --- /dev/null +++ b/ui/qt/capture_info_dialog.h @@ -0,0 +1,41 @@ +/* capture_info_dialog.h + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef CAPTURE_INFO_DIALOG_H +#define CAPTURE_INFO_DIALOG_H + +#include <QDialog> + +class CaptureInfoDialog : public QDialog +{ + Q_OBJECT +public: + explicit CaptureInfoDialog(QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // CAPTURE_INFO_DIALOG_H diff --git a/ui/qt/capture_interface_dialog.cpp b/ui/qt/capture_interface_dialog.cpp new file mode 100644 index 0000000000..d1817d96cf --- /dev/null +++ b/ui/qt/capture_interface_dialog.cpp @@ -0,0 +1,102 @@ +/* capture_interface_dialog.cpp + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "capture_interface_dialog.h" + +#ifdef HAVE_PCAP_REMOTE + +#include "qt_ui_utils.h" + +#include "gtk/recent.h" + +#include <epan/prefs.h> + +#include <QHash> + +QHash<QString, remote_host_t *> remote_host_list; + +// xxx - copied from capture_dlg.c +void +capture_remote_combo_recent_write_all(FILE *rf) +{ + remote_host_t *rh; + foreach (rh, remote_host_list) { + fprintf (rf, RECENT_KEY_REMOTE_HOST ": %s,%s,%d\n", rh->remote_host, rh->remote_port, rh->auth_type); + } +} + +gboolean +capture_remote_combo_add_recent(gchar *s) +{ + GList *vals = prefs_get_string_list (s); + GList *valp = vals; + struct remote_host_t *rh; + gint auth_type; + char *p; + + if (valp == NULL) + return FALSE; + + rh = (remote_host_t *) g_malloc (sizeof (remote_host_t)); + + /* First value is the host */ + rh->remote_host = g_strdup ((const gchar *) valp->data); + if (strlen(rh->remote_host) == 0) + /* Empty remote host */ + return FALSE; + rh->auth_type = CAPTURE_AUTH_NULL; + valp = valp->next; + + if (valp) { + /* Found value 2, this is the port number */ + rh->remote_port = g_strdup ((const gchar *) valp->data); + valp = valp->next; + } else { + /* Did not find a port number */ + rh->remote_port = g_strdup (""); + } + + if (valp) { + /* Found value 3, this is the authentication type */ + auth_type = strtol((const gchar *) valp->data, &p, 0); + if (p != valp->data && *p == '\0') { + rh->auth_type = auth_type; + } + } + + /* Do not store username and password */ + rh->auth_username = g_strdup (""); + rh->auth_password = g_strdup (""); + + prefs_clear_string_list(vals); + + remote_host_list.insert(QString::fromUtf8(rh->remote_host), rh); + + return TRUE; +} +#endif /* HAVE_PCAP_REMOTE */ + +CaptureInterfaceDialog::CaptureInterfaceDialog(QWidget *parent) : + QDialog(parent) +{ +} diff --git a/ui/qt/capture_interface_dialog.h b/ui/qt/capture_interface_dialog.h new file mode 100644 index 0000000000..da167071a4 --- /dev/null +++ b/ui/qt/capture_interface_dialog.h @@ -0,0 +1,43 @@ +/* capture_interface_dialog.h + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef CAPTURE_INTERFACE_DIALOG_H +#define CAPTURE_INTERFACE_DIALOG_H + +#include "config.h" + +#include <QDialog> + +class CaptureInterfaceDialog : public QDialog +{ + Q_OBJECT +public: + explicit CaptureInterfaceDialog(QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // CAPTURE_INTERFACE_DIALOG_H diff --git a/ui/qt/capture_start_24.png b/ui/qt/capture_start_24.png Binary files differnew file mode 100644 index 0000000000..b635f62d00 --- /dev/null +++ b/ui/qt/capture_start_24.png diff --git a/ui/qt/capture_start_active_24.png b/ui/qt/capture_start_active_24.png Binary files differnew file mode 100644 index 0000000000..e7e0fc1ea3 --- /dev/null +++ b/ui/qt/capture_start_active_24.png diff --git a/ui/qt/capture_stop_24.png b/ui/qt/capture_stop_24.png Binary files differnew file mode 100644 index 0000000000..d00cf751f5 --- /dev/null +++ b/ui/qt/capture_stop_24.png diff --git a/ui/qt/color_dialog.cpp b/ui/qt/color_dialog.cpp new file mode 100644 index 0000000000..3fb8748d9b --- /dev/null +++ b/ui/qt/color_dialog.cpp @@ -0,0 +1,54 @@ +/* color_dialog.cpp + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <glib.h> + +#include "color_dialog.h" + +#include <epan/packet.h> +#include <epan/dfilter/dfilter.h> +#include <epan/prefs.h> + +#include "color.h" +#include "color_filters.h" + +/* a new color filter was read in from a filter file */ +void +color_filter_add_cb(color_filter_t *colorf, gpointer user_data) +{ + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: color_filter_add_cb"); +// GtkWidget *color_filters = user_data; + +// add_filter_to_list(colorf, color_filters); + +// gtk_widget_grab_focus(color_filters); +} + +ColorDialog::ColorDialog(QWidget *parent) : + QDialog(parent) +{ +} diff --git a/ui/qt/color_dialog.h b/ui/qt/color_dialog.h new file mode 100644 index 0000000000..a90fd14b5f --- /dev/null +++ b/ui/qt/color_dialog.h @@ -0,0 +1,41 @@ +/* color_dialog.h + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef COLOR_DIALOG_H +#define COLOR_DIALOG_H + +#include <QDialog> + +class ColorDialog : public QDialog +{ + Q_OBJECT +public: + explicit ColorDialog(QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // COLOR_DIALOG_H diff --git a/ui/qt/color_utils.cpp b/ui/qt/color_utils.cpp new file mode 100644 index 0000000000..c79c5d41bd --- /dev/null +++ b/ui/qt/color_utils.cpp @@ -0,0 +1,60 @@ +/* color_utils.cpp + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <glib.h> + +#include "color_utils.h" + +#include "color.h" + +/* + * Initialize a color with R, G, and B values, including any toolkit-dependent + * work that needs to be done. + */ +gboolean +initialize_color(color_t *color, guint16 red, guint16 green, guint16 blue) +{ + QColor qc; + + // color_t uses 16-bit components to match Gtk+. Qt use 8. + qc.setRgb(red>>8, green>>8, blue>>8); + if (!qc.isValid()) + return FALSE; + + // Match what color_filters.c does. + color->red = red; + color->green = green; + color->blue = blue; + color->pixel = 0; + return TRUE; +} + +// XXX - We probably don't need a class. +ColorUtils::ColorUtils(QWidget *parent) : + QWidget(parent) +{ +} diff --git a/ui/qt/color_utils.h b/ui/qt/color_utils.h new file mode 100644 index 0000000000..b6b988ce01 --- /dev/null +++ b/ui/qt/color_utils.h @@ -0,0 +1,41 @@ +/* color_utils.h + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef COLOR_UTILS_H +#define COLOR_UTILS_H + +#include <QWidget> + +class ColorUtils : public QWidget +{ + Q_OBJECT +public: + explicit ColorUtils(QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // COLOR_UTILS_H diff --git a/ui/qt/dfilter_apply_hover.png b/ui/qt/dfilter_apply_hover.png Binary files differnew file mode 100644 index 0000000000..25ee2cedfe --- /dev/null +++ b/ui/qt/dfilter_apply_hover.png diff --git a/ui/qt/dfilter_apply_normal.png b/ui/qt/dfilter_apply_normal.png Binary files differnew file mode 100644 index 0000000000..a9ad9e1ffc --- /dev/null +++ b/ui/qt/dfilter_apply_normal.png diff --git a/ui/qt/dfilter_apply_pressed.png b/ui/qt/dfilter_apply_pressed.png Binary files differnew file mode 100644 index 0000000000..1e465c37d7 --- /dev/null +++ b/ui/qt/dfilter_apply_pressed.png diff --git a/ui/qt/dfilter_bookmark_hover.png b/ui/qt/dfilter_bookmark_hover.png Binary files differnew file mode 100644 index 0000000000..6017b9ffb8 --- /dev/null +++ b/ui/qt/dfilter_bookmark_hover.png diff --git a/ui/qt/dfilter_bookmark_normal.png b/ui/qt/dfilter_bookmark_normal.png Binary files differnew file mode 100644 index 0000000000..170edc403b --- /dev/null +++ b/ui/qt/dfilter_bookmark_normal.png diff --git a/ui/qt/dfilter_bookmark_pressed.png b/ui/qt/dfilter_bookmark_pressed.png Binary files differnew file mode 100644 index 0000000000..c2f15193ce --- /dev/null +++ b/ui/qt/dfilter_bookmark_pressed.png diff --git a/ui/qt/dfilter_dropdown.png b/ui/qt/dfilter_dropdown.png Binary files differnew file mode 100644 index 0000000000..56a056e0d2 --- /dev/null +++ b/ui/qt/dfilter_dropdown.png diff --git a/ui/qt/dfilter_erase_active.png b/ui/qt/dfilter_erase_active.png Binary files differnew file mode 100644 index 0000000000..3cb15e81a3 --- /dev/null +++ b/ui/qt/dfilter_erase_active.png diff --git a/ui/qt/dfilter_erase_normal.png b/ui/qt/dfilter_erase_normal.png Binary files differnew file mode 100644 index 0000000000..2e36e25b80 --- /dev/null +++ b/ui/qt/dfilter_erase_normal.png diff --git a/ui/qt/dfilter_erase_selected.png b/ui/qt/dfilter_erase_selected.png Binary files differnew file mode 100644 index 0000000000..f7774756bd --- /dev/null +++ b/ui/qt/dfilter_erase_selected.png diff --git a/ui/qt/dfilter_refresh_active.png b/ui/qt/dfilter_refresh_active.png Binary files differnew file mode 100644 index 0000000000..18cb24763f --- /dev/null +++ b/ui/qt/dfilter_refresh_active.png diff --git a/ui/qt/dfilter_refresh_normal.png b/ui/qt/dfilter_refresh_normal.png Binary files differnew file mode 100644 index 0000000000..7609cb77a0 --- /dev/null +++ b/ui/qt/dfilter_refresh_normal.png diff --git a/ui/qt/display_filter.qrc b/ui/qt/display_filter.qrc new file mode 100644 index 0000000000..42dea62f52 --- /dev/null +++ b/ui/qt/display_filter.qrc @@ -0,0 +1,16 @@ +<RCC> + <qresource prefix="/dfilter"> + <file>dfilter_dropdown.png</file> + <file>dfilter_erase_active.png</file> + <file>dfilter_erase_normal.png</file> + <file>dfilter_erase_selected.png</file> + <file>dfilter_refresh_active.png</file> + <file>dfilter_refresh_normal.png</file> + <file>dfilter_bookmark_normal.png</file> + <file>dfilter_bookmark_hover.png</file> + <file>dfilter_bookmark_pressed.png</file> + <file>dfilter_apply_hover.png</file> + <file>dfilter_apply_normal.png</file> + <file>dfilter_apply_pressed.png</file> + </qresource> +</RCC> diff --git a/ui/qt/display_filter_16.svg b/ui/qt/display_filter_16.svg new file mode 100644 index 0000000000..06708d3b54 --- /dev/null +++ b/ui/qt/display_filter_16.svg @@ -0,0 +1,802 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="256" + height="16" + id="svg2" + version="1.1" + inkscape:version="0.48.0 r9654" + sodipodi:docname="display_filter_16.svg" + inkscape:export-filename="/Users/gerald/Development/wxshark/image/toolbar/capture_start_24.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="5.656854" + inkscape:cx="97.434735" + inkscape:cy="12.40242" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="true" + inkscape:window-width="1130" + inkscape:window-height="793" + inkscape:window-x="139" + inkscape:window-y="798" + inkscape:window-maximized="0" + objecttolerance="2" + guidetolerance="5" + gridtolerance="4"> + <inkscape:grid + type="xygrid" + id="grid2812" + empspacing="4" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" + spacingx="4px" + spacingy="4px" + color="#7fffff" + opacity="0.49803922" + empcolor="#007fff" + empopacity="0.49803922" /> + </sodipodi:namedview> + <defs + id="defs4"> + <marker + inkscape:stockid="TriangleInS" + orient="auto" + refY="0.0" + refX="0.0" + id="TriangleInS" + style="overflow:visible"> + <path + id="path4487" + d="M 5.77,0.0 L -2.88,5.0 L -2.88,-5.0 L 5.77,0.0 z " + style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none" + transform="scale(-0.2)" /> + </marker> + <marker + inkscape:stockid="TriangleInM" + orient="auto" + refY="0.0" + refX="0.0" + id="TriangleInM" + style="overflow:visible"> + <path + id="path4484" + d="M 5.77,0.0 L -2.88,5.0 L -2.88,-5.0 L 5.77,0.0 z " + style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none" + transform="scale(-0.4)" /> + </marker> + <marker + inkscape:stockid="Arrow1Send" + orient="auto" + refY="0.0" + refX="0.0" + id="Arrow1Send" + style="overflow:visible;"> + <path + id="path4362" + d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " + style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;" + transform="scale(0.2) rotate(180) translate(6,0)" /> + </marker> + <marker + inkscape:stockid="Arrow2Send" + orient="auto" + refY="0.0" + refX="0.0" + id="Arrow2Send" + style="overflow:visible;"> + <path + id="path4380" + style="font-size:12.0;fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round;" + d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z " + transform="scale(0.3) rotate(180) translate(-2.3,0)" /> + </marker> + <marker + inkscape:stockid="Arrow2Mstart" + orient="auto" + refY="0.0" + refX="0.0" + id="Arrow2Mstart" + style="overflow:visible"> + <path + id="path4371" + style="font-size:12.0;fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round" + d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z " + transform="scale(0.6) translate(0,0)" /> + </marker> + <marker + inkscape:stockid="Arrow2Lstart" + orient="auto" + refY="0.0" + refX="0.0" + id="Arrow2Lstart" + style="overflow:visible"> + <path + id="path4365" + style="font-size:12.0;fill-rule:evenodd;stroke-width:0.62500000;stroke-linejoin:round" + d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z " + transform="scale(1.1) translate(1,0)" /> + </marker> + <marker + inkscape:stockid="Arrow1Lend" + orient="auto" + refY="0.0" + refX="0.0" + id="Arrow1Lend" + style="overflow:visible;"> + <path + id="path4350" + d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " + style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none;" + transform="scale(0.8) rotate(180) translate(12.5,0)" /> + </marker> + <marker + inkscape:stockid="Arrow1Lstart" + orient="auto" + refY="0.0" + refX="0.0" + id="Arrow1Lstart" + style="overflow:visible"> + <path + id="path4347" + d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z " + style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt;marker-start:none" + transform="scale(0.8) translate(12.5,0)" /> + </marker> + <linearGradient + id="linearGradient3855"> + <stop + style="stop-color:#ffffff;stop-opacity:0.77083331;" + offset="0" + id="stop3857" /> + <stop + style="stop-color:#ffffff;stop-opacity:0;" + offset="1" + id="stop3859" /> + </linearGradient> + <linearGradient + id="linearGradient3622"> + <stop + style="stop-color:#ffffff;stop-opacity:1;" + offset="0" + id="stop3624" /> + <stop + style="stop-color:#999999;stop-opacity:1;" + offset="1" + id="stop3626" /> + </linearGradient> + <inkscape:perspective + sodipodi:type="inkscape:persp3d" + inkscape:vp_x="0 : 526.18109 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_z="744.09448 : 526.18109 : 1" + inkscape:persp3d-origin="372.04724 : 350.78739 : 1" + id="perspective10" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient3622" + id="radialGradient3617" + cx="11.478261" + cy="10.956548" + fx="11.478261" + fy="10.956548" + r="9.391304" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(1.5,4.4485238e-8,-4.4485238e-8,1.5,-5.1521738,-5.1521876)" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient3855" + id="radialGradient3861" + cx="10.383852" + cy="7.6142039" + fx="10.383852" + fy="7.6142039" + r="12" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.39585463,0.00788241,-0.00767096,0.38523527,5.8229123,4.7348906)" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient3855" + id="radialGradient3878" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.39585463,0.00788241,-0.00767096,0.38523527,5.8229123,4.7348906)" + cx="10.383852" + cy="7.6142039" + fx="10.383852" + fy="7.6142039" + r="12" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient3855" + id="radialGradient3881" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.39585463,0.00788241,-0.00767096,0.38523527,29.822912,1033.0971)" + cx="10.383852" + cy="7.6142039" + fx="10.383852" + fy="7.6142039" + r="12" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient3855" + id="radialGradient3888" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.39585463,0.00788241,-0.00767096,0.38523527,29.822912,1033.0971)" + cx="10.383852" + cy="7.6142039" + fx="10.383852" + fy="7.6142039" + r="12" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient3855" + id="radialGradient3891" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.39585463,0.00788241,-0.00767096,0.38523527,29.822912,1033.0971)" + cx="10.383852" + cy="7.6142039" + fx="10.383852" + fy="7.6142039" + r="12" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient3622" + id="radialGradient3893" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(1.5,4.4485238e-8,-4.4485238e-8,1.5,-5.1521738,-5.1521876)" + cx="11.478261" + cy="10.956548" + fx="11.478261" + fy="10.956548" + r="9.391304" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient3855" + id="radialGradient3895" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.39585463,0.00788241,-0.00767096,0.38523527,5.8229123,4.7348906)" + cx="10.383852" + cy="7.6142039" + fx="10.383852" + fy="7.6142039" + r="12" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient3855" + id="radialGradient3898" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.39585463,0.00788241,-0.00767096,0.38523527,5.8229123,1033.0971)" + cx="10.383852" + cy="7.6142039" + fx="10.383852" + fy="7.6142039" + r="12" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient3855" + id="radialGradient3906" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.39585463,0.00788241,-0.00767096,0.38523527,53.822912,1033.0971)" + cx="10.383852" + cy="7.6142039" + fx="10.383852" + fy="7.6142039" + r="12" /> + <marker + inkscape:stockid="TriangleInSx" + orient="auto" + refY="0.0" + refX="0.0" + id="TriangleInSx" + style="overflow:visible"> + <path + id="path2902" + d="M 5.77,0.0 L -2.88,5.0 L -2.88,-5.0 L 5.77,0.0 z " + style="marker-start:none;stroke:#555753;stroke-width:1.0pt;fill:#555753;fill-rule:evenodd" + transform="scale(-0.2)" /> + </marker> + <marker + inkscape:stockid="TriangleInSxF" + orient="auto" + refY="0.0" + refX="0.0" + id="TriangleInSxF" + style="overflow:visible"> + <path + id="path3031" + d="M 5.77,0.0 L -2.88,5.0 L -2.88,-5.0 L 5.77,0.0 z " + style="fill-rule:evenodd;marker-start:none;stroke:#0066cc;stroke-width:1.0pt;fill:#0066cc" + transform="scale(-0.2)" /> + </marker> + </defs> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-1036.3622)"> + <flowRoot + xml:space="preserve" + id="flowRoot2835" + style="font-size:1.5px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + transform="matrix(1.0165643,0,0,1.0165643,0.3185175,1020.5936)"><flowRegion + id="flowRegion2837"><rect + id="rect2839" + width="36" + height="6" + x="-11.868164" + y="32.4095" + style="font-size:1.5px;text-align:center;text-anchor:middle" /></flowRegion><flowPara + id="flowPara3648">Clear Edit</flowPara></flowRoot> <flowRoot + xml:space="preserve" + id="flowRoot3619" + style="font-size:1.5px;font-style:normal;font-weight:normal;text-align:start;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + transform="translate(23.868164,983.9527)"><flowRegion + id="flowRegion3621"><rect + id="rect3623" + width="36" + height="6" + x="-11.868164" + y="32.4095" + style="font-size:1.5px;text-align:start;text-anchor:start" /></flowRegion><flowPara + id="flowPara3627">To export: Select an entire 16x16 square,</flowPara><flowPara + id="flowPara3631">including its invisible border.</flowPara></flowRoot> <g + id="g3196" + style="stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/dfilter_erase_normal.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <path + inkscape:connector-curvature="0" + id="path3192" + d="m 2.5,1038.8622 c 11,11 11,11 11,11" + style="fill:none;stroke:#555753;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none" /> + <path + style="fill:none;stroke:#555753;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none" + d="m 13.5,1038.8622 c -11,11 -11,11 -11,11" + id="path3194" + inkscape:connector-curvature="0" /> + </g> + <flowRoot + transform="matrix(1.0165643,0,0,1.0165643,98.219446,1021.2438)" + style="font-size:1.5px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + id="flowRoot3968" + xml:space="preserve"><flowRegion + id="flowRegion3970"><rect + style="font-size:1.5px;text-align:center;text-anchor:middle" + y="32.4095" + x="-11.868164" + height="6" + width="36" + id="rect3972" /></flowRegion><flowPara + id="flowPara3974">Refresh</flowPara></flowRoot> <path + sodipodi:type="arc" + style="fill:none;stroke:#555753;stroke-width:2.42877483;stroke-linecap:butt;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker-start:none;marker-mid:none;marker-end:url(#TriangleInSx)" + id="path3976" + sodipodi:cx="39.89164" + sodipodi:cy="8.8390093" + sodipodi:rx="4.8761611" + sodipodi:ry="4.8390093" + d="M 44.767801,8.8390093 A 4.8761611,4.8390093 0 1 1 39.89164,4" + transform="matrix(0.82031745,0,0,0.82661548,71.276192,1037.0557)" + sodipodi:start="0" + sodipodi:end="4.712389" + sodipodi:open="true" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/dfilter_refresh_normal.png" + inkscape:export-xdpi="16.560936" + inkscape:export-ydpi="16.560936" /> + <g + style="stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke:#ff3300" + id="g3978" + transform="translate(16,0)" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/dfilter_erase_active.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <path + style="fill:none;stroke:#ff3300;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 2.5,1038.8622 c 11,11 11,11 11,11" + id="path3980" + inkscape:connector-curvature="0" /> + <path + inkscape:connector-curvature="0" + id="path3982" + d="m 13.5,1038.8622 c -11,11 -11,11 -11,11" + style="fill:none;stroke:#ff3300;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + </g> + <path + sodipodi:open="true" + sodipodi:end="4.712389" + sodipodi:start="0" + transform="matrix(0.82031745,0,0,0.82661548,87.276192,1037.0557)" + d="M 44.767801,8.8390093 A 4.8761611,4.8390093 0 1 1 39.89164,4" + sodipodi:ry="4.8390093" + sodipodi:rx="4.8761611" + sodipodi:cy="8.8390093" + sodipodi:cx="39.89164" + id="path2989" + style="fill:none;stroke:#0066cc;stroke-width:2.42877483;stroke-linecap:butt;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker-start:none;marker-mid:none;marker-end:url(#TriangleInSxF)" + sodipodi:type="arc" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/dfilter_refresh_active.png" + inkscape:export-xdpi="16.560936" + inkscape:export-ydpi="16.560936" /> + <rect + style="fill:none;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + id="rect3048" + width="16" + height="16" + x="0" + y="0" + transform="translate(0,1036.3622)" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/dfilter_erase_normal.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" /> + <rect + y="1036.3622" + x="16" + height="16" + width="16" + id="rect3050" + style="fill:none;stroke:none" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/dfilter_erase_active.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" /> + <rect + style="fill:none;stroke:none" + id="rect3052" + width="16" + height="16" + x="96" + y="1036.3622" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/dfilter_refresh_active.png" + inkscape:export-xdpi="16.560936" + inkscape:export-ydpi="16.560936" /> + <rect + y="1036.3622" + x="112" + height="16" + width="16" + id="rect3054" + style="fill:none;stroke:none" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/dfilter_refresh_active.png" + inkscape:export-xdpi="16.560936" + inkscape:export-ydpi="16.560936" /> + <rect + style="fill:none;stroke:none" + id="rect3056" + width="16" + height="16" + x="48" + y="1036.3622" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/dfilter_apply_normal.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" /> + <rect + y="1036.3622" + x="64" + height="16" + width="16" + id="rect3058" + style="fill:none;stroke:none" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/dfilter_apply_active.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" /> + <flowRoot + xml:space="preserve" + id="flowRoot3060" + style="font-size:1.5px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + transform="matrix(1.0165643,0,0,1.0165643,50.219446,1021.2438)"><flowRegion + id="flowRegion3062"><rect + id="rect3064" + width="36" + height="6" + x="-11.868164" + y="32.4095" + style="font-size:1.5px;text-align:center;text-anchor:middle" /></flowRegion><flowPara + id="flowPara3066">Apply</flowPara></flowRoot> <g + id="g3902" + style="stroke:#555753" + transform="translate(-16,0)" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/dfilter_apply_normal.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <path + inkscape:connector-curvature="0" + id="path3068" + d="m 66,1044.4492 c 10.17421,0 10.17421,0 10.17421,0" + style="fill:none;stroke:#555753;stroke-width:1.99999988;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + style="fill:none;stroke:#555753;stroke-width:1.99999988;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 75,1041.8621 c 2.5,2.5 2.5,2.5 2.5,2.5" + id="path3898" + inkscape:connector-curvature="0" /> + <path + inkscape:connector-curvature="0" + id="path3900" + d="m 74.999996,1046.8622 c 2.5,-2.5 2.5,-2.5 2.5,-2.5" + style="fill:none;stroke:#555753;stroke-width:1.99999988;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + </g> + <g + id="g3907" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/dfilter_apply_active.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <path + style="fill:none;stroke:#0066cc;stroke-width:1.99999988;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 66,1044.4492 c 10.17421,0 10.17421,0 10.17421,0" + id="path3909" + inkscape:connector-curvature="0" /> + <path + inkscape:connector-curvature="0" + id="path3911" + d="m 75,1041.8621 c 2.5,2.5 2.5,2.5 2.5,2.5" + style="fill:none;stroke:#0066cc;stroke-width:1.99999988;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + style="fill:none;stroke:#0066cc;stroke-width:1.99999988;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 74.999996,1046.8622 c 2.5,-2.5 2.5,-2.5 2.5,-2.5" + id="path3913" + inkscape:connector-curvature="0" /> + </g> + <path + sodipodi:type="star" + style="fill:none;stroke:#555753;stroke-width:0.72866327;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + id="path3069" + sodipodi:sides="5" + sodipodi:cx="104" + sodipodi:cy="8" + sodipodi:r1="4.9833269" + sodipodi:r2="2.2424972" + sodipodi:arg1="-1.5707963" + sodipodi:arg2="-0.9424778" + inkscape:flatsided="false" + inkscape:rounded="-3.469447e-18" + inkscape:randomized="0" + d="m 104,3.0166731 1.31811,3.1691085 3.42132,0.2742858 -2.60669,2.2329023 0.79639,3.3386263 L 104,10.242497 l -2.92913,1.789099 0.79639,-3.3386262 -2.606685,-2.2329026 3.421315,-0.2742855 z" + transform="matrix(1.3714742,0,0,1.3732785,9.366679,1034.1395)" + inkscape:transform-center-y="-0.65350952" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/dfilter_favorite.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" /> + <rect + inkscape:export-ydpi="90" + inkscape:export-xdpi="90" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/dfilter_favorite.png" + style="fill:none;stroke:none" + id="rect3899" + width="16" + height="16" + x="144" + y="1036.3622" /> + <flowRoot + xml:space="preserve" + id="flowRoot3901" + style="font-size:1.5px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + transform="matrix(1.0165643,0,0,1.0165643,144.21945,1021.2438)"><flowRegion + id="flowRegion3903"><rect + id="rect3905" + width="36" + height="6" + x="-11.868164" + y="32.4095" + style="font-size:1.5px;text-align:center;text-anchor:middle" /></flowRegion><flowPara + id="flowPara3907">Favorites /</flowPara><flowPara + id="flowPara3909">Manage filters</flowPara></flowRoot> <path + sodipodi:type="star" + style="fill:#555753;stroke:none" + id="path3912" + sodipodi:sides="3" + sodipodi:cx="116" + sodipodi:cy="6.0121169" + sodipodi:r1="0.22362253" + sodipodi:r2="0.97227186" + sodipodi:arg1="1.5707963" + sodipodi:arg2="2.6179939" + inkscape:flatsided="true" + inkscape:rounded="-3.469447e-18" + inkscape:randomized="0" + d="m 116,6.2357394 -0.19366,-0.3354338 0.38732,0 z" + transform="matrix(18.072651,0,0,10.43425,-1896.4275,981.79694)" + inkscape:transform-center-y="2.5363326" + inkscape:transform-center-x="0.018274753" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/dfilter_dropdown.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" /> + <rect + y="1036.3622" + x="192" + height="16" + width="16" + id="rect3914" + style="fill:none;stroke:none" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/dfilter_dropdown.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" /> + <flowRoot + xml:space="preserve" + id="flowRoot3916" + style="font-size:1.5px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + transform="matrix(1.0165643,0,0,1.0165643,194.21945,1021.2438)"><flowRegion + id="flowRegion3918"><rect + id="rect3920" + width="36" + height="6" + x="-11.868164" + y="32.4095" + style="font-size:1.5px;text-align:center;text-anchor:middle" /></flowRegion><flowPara + id="flowPara3922">Combo Dropdown</flowPara><flowPara + id="flowPara3924">Arrow</flowPara></flowRoot> <g + inkscape:export-ydpi="90" + inkscape:export-xdpi="90" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/dfilter_erase_selected.png" + transform="translate(32,0)" + id="g3079" + style="stroke:#990000;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none"> + <path + inkscape:connector-curvature="0" + id="path3081" + d="m 2.5,1038.8622 c 11,11 11,11 11,11" + style="fill:none;stroke:#990000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + style="fill:none;stroke:#990000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 13.5,1038.8622 c -11,11 -11,11 -11,11" + id="path3083" + inkscape:connector-curvature="0" /> + </g> + <rect + inkscape:export-ydpi="90" + inkscape:export-xdpi="90" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/dfilter_erase_selected.png" + style="fill:none;stroke:none" + id="rect3085" + width="16" + height="16" + x="32" + y="1036.3622" /> + <path + inkscape:export-ydpi="90" + inkscape:export-xdpi="90" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/dfilter_bookmark_pressed.png" + inkscape:transform-center-y="-0.65350952" + transform="matrix(1.3714742,0,0,1.3732785,41.366679,1034.1395)" + d="m 104,3.0166731 1.31811,3.1691085 3.42132,0.2742858 -2.60669,2.2329023 0.79639,3.3386263 L 104,10.242497 l -2.92913,1.789099 0.79639,-3.3386262 -2.606685,-2.2329026 3.421315,-0.2742855 z" + inkscape:randomized="0" + inkscape:rounded="-3.469447e-18" + inkscape:flatsided="false" + sodipodi:arg2="-0.9424778" + sodipodi:arg1="-1.5707963" + sodipodi:r2="2.2424972" + sodipodi:r1="4.9833269" + sodipodi:cy="8" + sodipodi:cx="104" + sodipodi:sides="5" + id="path3337" + style="fill:none;stroke:#fce94f;stroke-width:0.72866327;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + sodipodi:type="star" /> + <rect + y="1036.3622" + x="176" + height="16" + width="16" + id="rect3339" + style="fill:none;stroke:none" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/dfilter_bookmark_pressed.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" /> + <path + sodipodi:type="star" + style="fill:none;stroke:#c4a000;stroke-width:0.72866327;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + id="path3085" + sodipodi:sides="5" + sodipodi:cx="104" + sodipodi:cy="8" + sodipodi:r1="4.9833269" + sodipodi:r2="2.2424972" + sodipodi:arg1="-1.5707963" + sodipodi:arg2="-0.9424778" + inkscape:flatsided="false" + inkscape:rounded="-3.469447e-18" + inkscape:randomized="0" + d="m 104,3.0166731 1.31811,3.1691085 3.42132,0.2742858 -2.60669,2.2329023 0.79639,3.3386263 L 104,10.242497 l -2.92913,1.789099 0.79639,-3.3386262 -2.606685,-2.2329026 3.421315,-0.2742855 z" + transform="matrix(1.3714742,0,0,1.3732785,25.366679,1034.1395)" + inkscape:transform-center-y="-0.65350952" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/dfilter_bookmark_hover.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" /> + <rect + inkscape:export-ydpi="90" + inkscape:export-xdpi="90" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/dfilter_bookmark_hover.png" + style="fill:none;stroke:none" + id="rect3087" + width="16" + height="16" + x="160" + y="1036.3622" /> + <rect + inkscape:export-ydpi="90" + inkscape:export-xdpi="90" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/dfilter_apply_pressed.png" + style="fill:none;stroke:none" + id="rect3088" + width="16" + height="16" + x="80" + y="1036.3622" /> + <g + inkscape:export-ydpi="90" + inkscape:export-xdpi="90" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/dfilter_apply_pressed.png" + id="g3090" + transform="translate(16,0)" + style="fill:#0083d7;stroke:#0099ff"> + <path + inkscape:connector-curvature="0" + id="path3092" + d="m 66,1044.4492 c 10.17421,0 10.17421,0 10.17421,0" + style="fill:#0083d7;stroke:#0099ff;stroke-width:1.99999988000000006;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + style="fill:#0083d7;stroke:#0099ff;stroke-width:1.99999988000000006;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 75,1041.8621 c 2.5,2.5 2.5,2.5 2.5,2.5" + id="path3094" + inkscape:connector-curvature="0" /> + <path + inkscape:connector-curvature="0" + id="path3096" + d="m 74.999996,1046.8622 c 2.5,-2.5 2.5,-2.5 2.5,-2.5" + style="fill:#0083d7;stroke:#0099ff;stroke-width:1.99999988000000006;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + </g> + <path + inkscape:export-ydpi="16.560936" + inkscape:export-xdpi="16.560936" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/dfilter_refresh_active.png" + sodipodi:type="arc" + style="fill:none;stroke:#0099ff;stroke-width:2.42877483000000005;stroke-linecap:butt;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker-start:none;marker-mid:none;marker-end:url(#TriangleInSxF)" + id="path3098" + sodipodi:cx="39.89164" + sodipodi:cy="8.8390093" + sodipodi:rx="4.8761611" + sodipodi:ry="4.8390093" + d="M 44.767801,8.8390093 A 4.8761611,4.8390093 0 1 1 39.89164,4" + transform="matrix(0.82031745,0,0,0.82661548,103.27619,1037.0557)" + sodipodi:start="0" + sodipodi:end="4.712389" + sodipodi:open="true" /> + <rect + inkscape:export-ydpi="16.560936" + inkscape:export-xdpi="16.560936" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/dfilter_refresh_active.png" + style="fill:none;stroke:none" + id="rect3100" + width="16" + height="16" + x="128" + y="1036.3622" /> + </g> +</svg> diff --git a/ui/qt/display_filter_combo.cpp b/ui/qt/display_filter_combo.cpp new file mode 100644 index 0000000000..626d2198be --- /dev/null +++ b/ui/qt/display_filter_combo.cpp @@ -0,0 +1,116 @@ +/* display_filter_combo.cpp + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include <stdio.h> + +#include "qt_ui_utils.h" +#include "gtk/recent.h" + +#include "display_filter_edit.h" + +#include "display_filter_combo.h" + +// If we ever add support for multiple windows this will need to be replaced. +static DisplayFilterCombo *cur_display_filter_combo = NULL; + +DisplayFilterCombo::DisplayFilterCombo(QWidget *parent) : + QComboBox(parent) +{ + setEditable(true); + setLineEdit(new DisplayFilterEdit()); + setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); + setAccessibleName("Dispaly filter selector"); + cur_display_filter_combo = this; + setStyleSheet( + "QComboBox {" + " border: 1px solid gray;" + " border-radius: 3px;" + " padding: 0px 0px 0px 0px;" + " margin-left: 0px;" + " min-width: 20em;" +// " background: #ccccff;" + " }" + + "QComboBox::drop-down {" + " subcontrol-origin: padding;" + " subcontrol-position: top right;" + " width: 16px;" + " border-left-width: 0px;" + " }" + + "QComboBox::down-arrow {" + " image: url(:/dfilter/dfilter_dropdown.png);" + " }" + + "QComboBox::down-arrow:on { /* shift the arrow when popup is open */" + " top: 1px;" + " left: 1px;" + "}" + ); + completer()->setCompletionMode(QCompleter::PopupCompletion); +} + +void dfilter_recent_combo_write_all(FILE *rf) { + if (!cur_display_filter_combo) + return; + + cur_display_filter_combo->writeRecent(rf); +} + +void DisplayFilterCombo::writeRecent(FILE *rf) { + int i; + const char *filter_str; + + for (i = 0; i < count(); i++) { + filter_str = itemText(i).toUtf8().constData(); + if(filter_str && strlen(filter_str) > 0) { + fprintf(rf, RECENT_KEY_DISPLAY_FILTER ": %s\n", filter_str); + } + } +} + +gboolean dfilter_combo_add_recent(gchar *filter) { + if (!cur_display_filter_combo) + return FALSE; + + cur_display_filter_combo->addItem(filter); + cur_display_filter_combo->clearEditText(); + return TRUE; +} + + +// xxx - Move to an as-yet-to-be-written capture filter module along with ::addRecentCapture and ::writeRecentCapture +QList<QString> cfilters; + +gboolean cfilter_combo_add_recent(gchar *filter) { + cfilters.append(filter); + return TRUE; +} + +void cfilter_combo_recent_write_all(FILE *rf) { + QString cfilter; + + foreach (cfilter, cfilters) { + fprintf (rf, RECENT_KEY_CAPTURE_FILTER ": %s\n", cfilter.toUtf8().constData()); + } +} diff --git a/ui/qt/display_filter_combo.h b/ui/qt/display_filter_combo.h new file mode 100644 index 0000000000..2b5c3fa4ca --- /dev/null +++ b/ui/qt/display_filter_combo.h @@ -0,0 +1,44 @@ +/* display_filter_combo.h + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef DISPLAY_FILTER_COMBO_H +#define DISPLAY_FILTER_COMBO_H + +#include <QComboBox> +#include <QList> + +class DisplayFilterCombo : public QComboBox +{ + Q_OBJECT +public: + explicit DisplayFilterCombo(QWidget *parent = 0); + bool addRecentCapture(const char *filter); + void writeRecent(FILE *rf); + +signals: + +public slots: + +}; + +#endif // DISPLAY_FILTER_COMBO_H diff --git a/ui/qt/display_filter_edit.cpp b/ui/qt/display_filter_edit.cpp new file mode 100644 index 0000000000..ab76014124 --- /dev/null +++ b/ui/qt/display_filter_edit.cpp @@ -0,0 +1,342 @@ +/* display_filter_edit.cpp + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "config.h" + +#include "globals.h" + +#include <glib.h> + +#include <epan/proto.h> + +#include "display_filter_edit.h" + +#include "gtk/utf8_entities.h" + +// platform +// osx +// win +// default + +#if defined(Q_WS_MAC) && 0 +// http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSImage_Class/Reference/Reference.html +// http://www.virtualbox.org/svn/vbox/trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/UICocoaSpecialControls.mm + +class UIMiniCancelButton: public QAbstractButton +{ + Q_OBJECT; + +public: + UIMiniCancelButton(QWidget *pParent = 0); + + void setText(const QString &strText) { m_pButton->setText(strText); } + void setToolTip(const QString &strTip) { m_pButton->setToolTip(strTip); } + void removeBorder() {} + +protected: + void paintEvent(QPaintEvent * /* pEvent */) {} + void resizeEvent(QResizeEvent *pEvent); + +private: + UICocoaButton *m_pButton; +}; + +UIMiniCancelButton::UIMiniCancelButton(QWidget *pParent /* = 0 */) + : QAbstractButton(pParent) +{ + setShortcut(QKeySequence(Qt::Key_Escape)); + m_pButton = new UICocoaButton(UICocoaButton::CancelButton, this); + connect(m_pButton, SIGNAL(clicked()), + this, SIGNAL(clicked())); + setFixedSize(m_pButton->size()); +} + +#endif + +#ifdef __APPLE__ +#define DEFAULT_MODIFIER QChar(0x2318) // PLACE OF INTEREST SIGN +#else +#define DEFAULT_MODIFIER "Ctrl-" +#endif + +// XXX - We need simplified (button- and dropdown-free) versions for use in dialogs and field-only checking. + +DisplayFilterEdit::DisplayFilterEdit(QWidget *parent) : + QLineEdit(parent) +{ + fieldNameOnly = false; + m_syntaxState = Empty; + emptyFilterMessage = QString::fromUtf8("Apply a display filter" UTF8_HORIZONTAL_ELLIPSIS " <%1/>").arg(DEFAULT_MODIFIER); + + setAccessibleName("Dispaly filter entry"); + + // DFCombo + // Bookmark (star) + // DispalyFilterEdit + // Clear button + // Apply (right arrow) + Cancel (x) + Reload (arrowed circle) + // Down Arrow + + // XXX - Move bookmark and apply buttons to the toolbar a la Firefox, Chrome & Safari? + // XXX - Use native buttons on OS X? + + bookmarkButton = new QToolButton(this); + bookmarkButton->setCursor(Qt::ArrowCursor); + bookmarkButton->setStyleSheet( + "QToolButton { /* all types of tool button */" + " border 0 0 0 0;" + " border-right: 1px solid gray;" + " border-top-left-radius: 3px;" + " border-bottom-left-radius: 3px;" + " padding-left: 1px;" + " image: url(:/dfilter/dfilter_bookmark_normal.png);" +// " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1," +// " stop: 0 #f6f7fa, stop: 1 #dadbde);" + "}" + + "QToolButton:hover {" + " image: url(:/dfilter/dfilter_bookmark_hover.png);" + "}" + "QToolButton:pressed {" + " image: url(:/dfilter/dfilter_bookmark_pressed.png);" + "}" + +// "QToolButton:pressed {" +// " background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1," +// " stop: 0 #dadbde, stop: 1 #f6f7fa);" +// "}" + + ); + connect(bookmarkButton, SIGNAL(clicked()), this, SLOT(showDisplayFilterDialog())); + + clearButton = new QToolButton(this); + clearButton->setCursor(Qt::ArrowCursor); + clearButton->setStyleSheet( + "QToolButton {" + " image: url(:/dfilter/dfilter_erase_normal.png);" + " border: none;" + " width: 16px;" + "}" + "QToolButton:hover {" + " image: url(:/dfilter/dfilter_erase_active.png);" + "}" + "QToolButton:pressed {" + " image: url(:/dfilter/dfilter_erase_selected.png);" + "}" + ); + clearButton->hide(); + connect(clearButton, SIGNAL(clicked()), this, SLOT(clear())); + connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(checkFilter(const QString&))); + + applyButton = new QToolButton(this); + applyButton->setCursor(Qt::ArrowCursor); + applyButton->setStyleSheet( + "QToolButton { /* all types of tool button */" + " border 0 0 0 0;" + " border-top-right-radius: 3px;" + " border-bottom-right-radius: 3px;" + " padding-right: 1px;" + " image: url(:/dfilter/dfilter_apply_normal.png);" + "}" + + "QToolButton:hover {" + " image: url(:/dfilter/dfilter_apply_hover.png);" + "}" + "QToolButton:pressed {" + " image: url(:/dfilter/dfilter_apply_pressed.png);" + "}" + ); + connect(applyButton, SIGNAL(clicked()), this, SLOT(applyDisplayFilter())); + connect(this, SIGNAL(returnPressed()), this, SLOT(applyDisplayFilter())); + + int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); + QSize bksz = bookmarkButton->sizeHint(); + QSize cbsz = clearButton->sizeHint(); + QSize apsz = applyButton->sizeHint(); + syntaxStyleSheet = QString( + "DisplayFilterEdit {" + " padding-left: %1px;" + " margin-left: %2px;" + " margin-right: %3px;" + " background: transparent;" + "}" + + // Should the backgrounds fade away on the right? + // Tango "Scarlet Red" + "DisplayFilterEdit[syntaxState=\"%4\"] {" + " color: white;" + " background-color: rgba(239, 41, 41, 128);" + "}" + + // Tango "Butter" + "DisplayFilterEdit[syntaxState=\"%5\"] {" + " color: black;" + " background-color: rgba(252, 233, 79, 128);" + "}" + + // Tango "Chameleon + "DisplayFilterEdit[syntaxState=\"%6\"] {" + " color: black;" + " background-color: rgba(138, 226, 52, 128);" + "}" + ) + .arg(frameWidth + 1) + .arg(bksz.width()) + .arg(cbsz.width() + apsz.width() + frameWidth + 1) + .arg(Invalid) + .arg(Deprecated) + .arg(Valid); + setStyleSheet(syntaxStyleSheet); +} + +void DisplayFilterEdit::paintEvent(QPaintEvent *evt) { + QLineEdit::paintEvent(evt); + + // http://wiki.forum.nokia.com/index.php/Custom_QLineEdit + if (text().isEmpty() && ! this->hasFocus()) { + QPainter p(this); + QFont f = font(); + f.setItalic(true); + p.setFont(f); + + QColor color(palette().color(foregroundRole())); + color.setAlphaF(0.5); + p.setPen(color); + + QStyleOptionFrame opt; + initStyleOption(&opt); + QRect cr = style()->subElementRect(QStyle::SE_LineEditContents, &opt, this); + cr.setLeft(cr.left() + 2); + cr.setRight(cr.right() - 2); + + p.drawText(cr, Qt::AlignLeft|Qt::AlignVCenter, emptyFilterMessage); + } + // else check filter syntax and set the background accordingly + // XXX - Should we add little warning/error icons as well? +} + +void DisplayFilterEdit::resizeEvent(QResizeEvent *) +{ + QSize cbsz = clearButton->sizeHint(); + QSize apsz = applyButton->sizeHint(); + int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); + clearButton->move(rect().right() - frameWidth - cbsz.width() - apsz.width(), + (rect().bottom() + 1 - cbsz.height())/2); + applyButton->move(rect().right() - frameWidth - apsz.width(), + (rect().bottom() + 1 - apsz.height())/2); +} + +void DisplayFilterEdit::checkFilter(const QString& text) +{ + dfilter_t *dfp; + GPtrArray *depr = NULL; + guchar c; + + clearButton->setVisible(!text.isEmpty()); + + if (fieldNameOnly && (c = proto_check_field_name(text.toUtf8().constData()))) { + m_syntaxState = Invalid; +// if (use_statusbar) { +// statusbar_push_filter_msg(" Illegal character in field name: '%c'", c); +// } + } else if (dfilter_compile(text.toUtf8().constData(), &dfp)) { + if (dfp != NULL) { + depr = dfilter_deprecated_tokens(dfp); + } + if (text.length() < 1) { + m_syntaxState = Empty; + } else if (depr) { + /* You keep using that word. I do not think it means what you think it means. */ + m_syntaxState = Deprecated; +// if (use_statusbar) { +// /* +// * We're being lazy and only printing the first "problem" token. +// * Would it be better to print all of them? +// */ +// statusbar_push_temporary_msg(" \"%s\" may have unexpected results (see the User's Guide)", +// (const char *) g_ptr_array_index(depr, 0)); +// } + } else { + m_syntaxState = Valid; + } + dfilter_free(dfp); + } else { + m_syntaxState = Invalid; +// if (use_statusbar) { +// if (dfilter_error_msg) { +// statusbar_push_filter_msg(" Invalid filter: %s", dfilter_error_msg); +// } else { +// statusbar_push_filter_msg(" Invalid filter"); +// } +// } + } + + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: show display filter syntax status in statusbar"); + setStyleSheet(syntaxStyleSheet); + applyButton->setEnabled(m_syntaxState == Empty || m_syntaxState == Valid); + +} + +void DisplayFilterEdit::showDisplayFilterDialog() +{ + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: implement display filter dialog for \"%s\"", this->text().toUtf8().constData()); +} + +void DisplayFilterEdit::applyDisplayFilter() +{ + QString dfString(text()); + gchar *dftext = NULL; + cf_status_t cf_status; + + if (m_syntaxState != Valid && m_syntaxState != Empty) { + return; + } + + if (dfString.length() > 0) + dftext = g_strdup(dfString.toUtf8().constData()); + cf_status = cf_filter_packets(&cfile, dftext, FALSE); + g_free(dftext); + + if (cf_status == CF_OK) { + applyButton->setEnabled(false); + if (dfString.length() < 1) { +// gtk_widget_set_sensitive (g_object_get_data (G_OBJECT(filter_cm), E_DFILTER_CLEAR_KEY), FALSE); +// gtk_widget_set_sensitive (g_object_get_data (G_OBJECT(filter_cm), E_DFILTER_SAVE_KEY), FALSE); + } + } + + if (cf_status == CF_OK && dfString.length() > 0) { +// int index; + + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: add \"%s\" to recent display filters", this->text().toUtf8().constData()); + +// if(!dfilter_entry_match(filter_cm,s, &index)){ +// gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(filter_cm), s); +// index++; +// } +// while ((guint)index >= prefs.gui_recent_df_entries_max){ +// gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(filter_cm), index); +// index--; +// } + } +} diff --git a/ui/qt/display_filter_edit.h b/ui/qt/display_filter_edit.h new file mode 100644 index 0000000000..2d8bffd81d --- /dev/null +++ b/ui/qt/display_filter_edit.h @@ -0,0 +1,67 @@ +/* display_filter_edit.h + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef DISPLAYFILTEREDIT_H +#define DISPLAYFILTEREDIT_H + +#include <QtGui> + +class DisplayFilterEdit : public QLineEdit +{ + Q_OBJECT + Q_PROPERTY(SyntaxState syntaxState READ syntaxState) + Q_ENUMS(SyntaxState) +public: + explicit DisplayFilterEdit(QWidget *parent = 0); + enum SyntaxState { Empty, Invalid, Deprecated, Valid }; + SyntaxState syntaxState() const + { return m_syntaxState; } + + +protected: + void paintEvent(QPaintEvent *evt); + void resizeEvent(QResizeEvent *); +// void focusInEvent(QFocusEvent *evt); +// void focusOutEvent(QFocusEvent *evt); + +private slots: + void checkFilter(const QString &text); + void showDisplayFilterDialog(); + void applyDisplayFilter(); + +private: + bool fieldNameOnly; + SyntaxState m_syntaxState; + QString emptyFilterMessage; + QString syntaxStyleSheet; + QToolButton *bookmarkButton; + QToolButton *clearButton; + QToolButton *applyButton; + +signals: + +public slots: + +}; + +#endif // DISPLAYFILTEREDIT_H diff --git a/ui/qt/fileset_dialog.cpp b/ui/qt/fileset_dialog.cpp new file mode 100644 index 0000000000..80df817232 --- /dev/null +++ b/ui/qt/fileset_dialog.cpp @@ -0,0 +1,166 @@ +/* fileset_dialog.cpp + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <glib.h> + +#include "fileset_dialog.h" + +#include "fileset.h" + +/* this file is a part of the current file set, add it to the dialog */ +void +fileset_dlg_add_file(fileset_entry *entry) { +// char *created; +// char *modified; +// char *size; +// struct tm *local; +// GtkWidget *fs_lb; +// GtkWidget *fs_rb; +// gchar *title; + + + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: fileset_dlg_add_file: %s", entry->name); +// if (fs_w == NULL) { +// return; +// } + +// created = fileset_dlg_name2date_dup(entry->name); +// if(!created) { +// /* if this file doesn't follow the file set pattern, */ +// /* use the creation time of that file */ +// local = localtime(&entry->ctime); +// created = g_strdup_printf("%04u.%02u.%02u %02u:%02u:%02u", +// local->tm_year+1900, local->tm_mon+1, local->tm_mday, +// local->tm_hour, local->tm_min, local->tm_sec); +// } + +// local = localtime(&entry->mtime); +// modified = g_strdup_printf("%04u.%02u.%02u %02u:%02u:%02u", +// local->tm_year+1900, local->tm_mon+1, local->tm_mday, +// local->tm_hour, local->tm_min, local->tm_sec); +// size = g_strdup_printf("%" G_GINT64_MODIFIER "d Bytes", entry->size); + +// fs_rb = gtk_radio_button_new_with_label_from_widget( +// fs_first_rb ? GTK_RADIO_BUTTON(fs_first_rb) : NULL, entry->name); +// if(row == 1) { +// fs_first_rb = fs_rb; +// } +// if(entry->current) { +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (fs_rb), entry->current); +// } +// gtk_tooltips_set_tip(tooltips, fs_rb, "Open this capture file", NULL); +// gtk_table_attach_defaults(GTK_TABLE(fs_tb), fs_rb, 0, 1, row, row+1); +// g_signal_connect(fs_rb, "toggled", G_CALLBACK(fs_rb_cb), entry); +// gtk_widget_show(fs_rb); + +// fs_lb = gtk_label_new(created); +// gtk_table_attach_defaults(GTK_TABLE(fs_tb), fs_lb, 1, 2, row, row+1); +// gtk_widget_set_sensitive(fs_lb, entry->current); +// gtk_widget_show(fs_lb); + +// fs_lb = gtk_label_new(modified); +// gtk_table_attach_defaults(GTK_TABLE(fs_tb), fs_lb, 2, 3, row, row+1); +// gtk_widget_set_sensitive(fs_lb, entry->current); +// gtk_widget_show(fs_lb); + +// fs_lb = gtk_label_new(size); +// gtk_table_attach_defaults(GTK_TABLE(fs_tb), fs_lb, 3, 4, row, row+1); +// gtk_widget_set_sensitive(fs_lb, entry->current); +// gtk_widget_show(fs_lb); + +// title = g_strdup_printf("Wireshark: %u File%s in Set", row, plurality(row, "", "s")); +// gtk_window_set_title(GTK_WINDOW(fs_w), title); +// g_free(title); + +// title = g_strdup_printf("... in directory: %s", fileset_get_dirname()); +// gtk_label_set_text(GTK_LABEL(fs_dir_lb), title); +// g_free(title); + +// gtk_widget_show_all(fs_tb); + +// /* resize the table until we use 18 rows (fits well into 800*600), if it's bigger use a scrollbar */ +// /* XXX - I didn't found a way to automatically shrink the table size again */ +// if(row <= 18) { +// GtkRequisition requisition; + +// gtk_widget_size_request(fs_tb, &requisition); +// gtk_widget_set_size_request(fs_sw, -1, requisition.height); +// gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(fs_sw), GTK_POLICY_NEVER, GTK_POLICY_NEVER); +// } + +// if(row == 18) { +// gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(fs_sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); +// } + +// row++; + +// g_free(created); +// g_free(modified); +// g_free(size); +} + +/* a new capture file was opened, browse the dir and look for files matching the given file set */ +void +fileset_file_opened(const char *fname) { + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: fileset_file_opened: %s", fname); +// fileset_add_dir(fname); +// if(fs_w) { +// window_present(fs_w); +// } + +// /* update the menu */ +// set_menus_for_file_set(TRUE /* file_set */, +// fileset_get_previous() != NULL, fileset_get_next() != NULL ); +} + + +/* the capture file was closed */ +void +fileset_file_closed(void) +{ + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: fileset_file_closed"); +// if(fs_w) { +// /* reinit the table, title and alike */ +// g_object_ref(G_OBJECT(fs_tb_vb)); +// gtk_widget_destroy(fs_tb); +// fileset_delete(); +// fileset_init_table(fs_tb_vb); +// window_present(fs_w); +// } else { +// fileset_delete(); +// } + +// /* update the menu */ +// set_menus_for_file_set(FALSE /* file_set */, +// fileset_get_previous() != NULL, +// fileset_get_next() != NULL ); +} + +FilesetDialog::FilesetDialog(QWidget *parent) : + QDialog(parent) +{ +} diff --git a/ui/qt/fileset_dialog.h b/ui/qt/fileset_dialog.h new file mode 100644 index 0000000000..4ea7301552 --- /dev/null +++ b/ui/qt/fileset_dialog.h @@ -0,0 +1,41 @@ +/* fileset_dialog.h + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef FILESET_DIALOG_H +#define FILESET_DIALOG_H + +#include <QDialog> + +class FilesetDialog : public QDialog +{ + Q_OBJECT +public: + explicit FilesetDialog(QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // FILESET_DIALOG_H diff --git a/ui/qt/gpl-template.txt b/ui/qt/gpl-template.txt new file mode 100644 index 0000000000..8af44de07b --- /dev/null +++ b/ui/qt/gpl-template.txt @@ -0,0 +1,22 @@ +/* <filename>.c + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ diff --git a/ui/qt/interface_tree.cpp b/ui/qt/interface_tree.cpp new file mode 100644 index 0000000000..39e4001462 --- /dev/null +++ b/ui/qt/interface_tree.cpp @@ -0,0 +1,93 @@ +/* interface_tree.cpp + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "interface_tree.h" + +#include "config.h" + +#ifdef HAVE_LIBPCAP +#include "capture.h" +#include "capture-pcap-util.h" +#include "capture_opts.h" +#include "capture_ui_utils.h" +#endif + +#include <QLabel> +#include <QHeaderView> + +InterfaceTree::InterfaceTree(QWidget *parent) : + QTreeWidget(parent) +{ + GList *if_list; + QTreeWidgetItem *ti; + int err; + gchar *err_str = NULL; + + header()->setVisible(false); + setRootIsDecorated(false); + setUniformRowHeights(true); + setAccessibleName("Welcome screen list"); + + setStyleSheet( + "QTreeWidget {" + " border: 0;" + "}" + ); + + if_list = capture_interface_list(&err, &err_str); + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: move if_list_comparator_alph out of gtk/"); +// if_list = g_list_sort(if_list, if_list_comparator_alph); + + if (if_list == NULL && err == CANT_GET_INTERFACE_LIST) { + ti = new QTreeWidgetItem(); + QLabel *label = new QLabel(QString("<h3>No interfaces found</h3>%1").arg(QString().fromUtf8(err_str))); + label->setWordWrap(true); + + setDisabled(true); + addTopLevelItem(ti); + setItemWidget(ti, 0, label); + return; + } else if (err_str) { + g_free(err_str); + } + + // XXX Do we need to check for this? capture_interface_list returns an error if the length is 0. + if (g_list_length(if_list) > 0) { + if_info_t *if_info; + GList *curr; + setDisabled(false); + + for (curr = g_list_first(if_list); curr; curr = g_list_next(curr)) { + if_info = (if_info_t *) curr->data; + /* Continue if capture device is hidden */ +// if (prefs_is_capture_device_hidden(if_info->name)) { +// continue; +// } + + ti = new QTreeWidgetItem(); + ti->setText(0, QString().fromUtf8(if_info->description ? if_info->description : if_info->name)); + addTopLevelItem(ti); + } + } + free_interface_list(if_list); +} diff --git a/ui/qt/interface_tree.h b/ui/qt/interface_tree.h new file mode 100644 index 0000000000..e9dbd388b8 --- /dev/null +++ b/ui/qt/interface_tree.h @@ -0,0 +1,43 @@ +/* interface_tree.h + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef INTERFACE_TREE_H +#define INTERFACE_TREE_H + +#include <glib.h> + +#include <QTreeWidget> + +class InterfaceTree : public QTreeWidget +{ + Q_OBJECT +public: + explicit InterfaceTree(QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // INTERFACE_TREE_H diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp new file mode 100644 index 0000000000..bcdbcc2808 --- /dev/null +++ b/ui/qt/main.cpp @@ -0,0 +1,980 @@ +/* main.cpp + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "wireshark_application.h" +#include "main_window.h" + +#include "config.h" + +#include "globals.h" + +#include <glib.h> + +#ifndef HAVE_GETOPT +#include "wsutil/wsgetopt.h" +#endif + +#include <epan/epan.h> +#include <epan/filesystem.h> +#include <wsutil/privileges.h> +#include <epan/epan_dissect.h> +#include <epan/timestamp.h> +#include <epan/packet.h> +#include <epan/plugins.h> +#include <epan/dfilter/dfilter.h> +#include <epan/strutil.h> +#include <epan/addr_resolv.h> +#include <epan/emem.h> +#include <epan/ex-opt.h> +#include <epan/funnel.h> +#include <epan/expert.h> +#include <epan/frequency-utils.h> +#include <epan/prefs.h> +#include <epan/prefs-int.h> +#include <epan/tap.h> +#include <epan/stat_cmd_args.h> +#include <epan/uat.h> +#include <epan/column.h> + +/* general (not Qt specific) */ +#include "file.h" +#include "summary.h" +#include "filters.h" +#include "disabled_protos.h" +#include "color.h" +#include "color_filters.h" +#include "print.h" +#include "simple_dialog.h" +#include "main_statusbar.h" +#include "register.h" +#include "ringbuffer.h" +#include "ui_util.h" +#include "util.h" +#include "clopts_common.h" +#include "console_io.h" +#include "cmdarg_err.h" +#include "version_info.h" +#include "merge.h" +#include "alert_box.h" +#include "log.h" +#include "u3.h" +#include <wsutil/file_util.h> + +#include "gtk/recent.h" + +#ifdef HAVE_LIBPCAP +#include "capture_ui_utils.h" +#include "capture-pcap-util.h" +#include "capture_ifinfo.h" +#include "capture.h" +#include "capture_sync.h" +#endif + +#ifdef _WIN32 +#include "capture-wpcap.h" +#include "capture_wpcap_packet.h" +#include <tchar.h> /* Needed for Unicode */ +#include <wsutil/unicode-utils.h> +#include <commctrl.h> +#include <shellapi.h> +#endif /* _WIN32 */ + +#ifdef HAVE_AIRPCAP +#include <airpcap.h> +#include "airpcap_loader.h" +//#include "airpcap_dlg.h" +//#include "airpcap_gui_utils.h" +#endif + +#include <epan/crypt/airpdcap_ws.h> + +#include "monospace_font.h" + +#include <QDebug> +#include <QDateTime> +#include <QTextCodec> + +capture_file cfile; + +#ifdef HAVE_AIRPCAP +int airpcap_dll_ret_val = -1; +#endif + +GString *comp_info_str, *runtime_info_str; + +static gboolean have_capture_file = FALSE; /* XXX - is there an equivalent in cfile? */ + +static guint tap_update_timer_id; + +#ifdef _WIN32 +static gboolean has_console; /* TRUE if app has console */ +static gboolean console_wait; /* "Press any key..." */ +//static void destroy_console(void); +static gboolean stdin_capture = FALSE; /* Don't grab stdin & stdout if TRUE */ +#endif +static void console_log_handler(const char *log_domain, + GLogLevelFlags log_level, const char *message, gpointer user_data); + +void create_console(void); + +#ifdef HAVE_LIBPCAP +capture_options global_capture_opts; +#endif + +// Copied from gtk/gui_utils.c +void pipe_input_set_handler(gint source, gpointer user_data, int *child_process, pipe_input_cb_t input_cb) +{ +// static pipe_input_t pipe_input; + +// pipe_input.source = source; +// pipe_input.child_process = child_process; +// pipe_input.user_data = user_data; +// pipe_input.input_cb = input_cb; + + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: pipe_input_set_handler"); +//#ifdef _WIN32 +// /* Tricky to use pipes in win9x, as no concept of wait. NT can +// do this but that doesn't cover all win32 platforms. GTK can do +// this but doesn't seem to work over processes. Attempt to do +// something similar here, start a timer and check for data on every +// timeout. */ +// /*g_log(NULL, G_LOG_LEVEL_DEBUG, "pipe_input_set_handler: new");*/ +// pipe_input.pipe_input_id = g_timeout_add(200, pipe_timer_cb, &pipe_input); +//#else +// pipe_input.channel = g_io_channel_unix_new(source); +// g_io_channel_set_encoding(pipe_input.channel, NULL, NULL); +// pipe_input.pipe_input_id = g_io_add_watch_full(pipe_input.channel, +// G_PRIORITY_HIGH, +// G_IO_IN|G_IO_ERR|G_IO_HUP, +// pipe_input_cb, +// &pipe_input, +// NULL); +//#endif +} + +static void +main_cf_callback(gint event, gpointer data, gpointer user_data _U_) +{ + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: main_cf_callback %d %p", event, data); +// switch(event) { +// case(cf_cb_file_closing): +// g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Closing"); +// main_cf_cb_file_closing(data); +// break; +// case(cf_cb_file_closed): +// g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Closed"); +// main_cf_cb_file_closed(data); +// break; +// case(cf_cb_file_read_started): +// g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Read started"); +// main_cf_cb_file_read_started(data); +// break; +// case(cf_cb_file_read_finished): +// g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Read finished"); +// main_cf_cb_file_read_finished(data); +// break; +// case(cf_cb_packet_selected): +// main_cf_cb_packet_selected(data); +// break; +// case(cf_cb_packet_unselected): +// main_cf_cb_packet_unselected(data); +// break; +// case(cf_cb_field_unselected): +// main_cf_cb_field_unselected(data); +// break; +// case(cf_cb_file_save_started): +// g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Save started"); +// break; +// case(cf_cb_file_save_finished): +// g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Save finished"); +// break; +// case(cf_cb_file_save_reload_finished): +// g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Reload finished"); +// main_cf_cb_file_save_reload_finished(data); +// break; +// case(cf_cb_file_save_failed): +// g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: Save failed"); +// break; +// default: +// g_warning("main_cf_callback: event %u unknown", event); +// g_assert_not_reached(); +// } +} + +// XXX Copied from gtk/main.c. This should be moved to a common location. +static e_prefs * +read_configuration_files(char **gdp_path, char **dp_path) +{ + int gpf_open_errno, gpf_read_errno; + int cf_open_errno, df_open_errno; + int gdp_open_errno, gdp_read_errno; + int dp_open_errno, dp_read_errno; + char *gpf_path, *pf_path; + char *cf_path, *df_path; + int pf_open_errno, pf_read_errno; + e_prefs *prefs_p; + + /* Read the preference files. */ + prefs_p = read_prefs(&gpf_open_errno, &gpf_read_errno, &gpf_path, + &pf_open_errno, &pf_read_errno, &pf_path); + + if (gpf_path != NULL) { + if (gpf_open_errno != 0) { + simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, + "Could not open global preferences file\n\"%s\": %s.", gpf_path, + g_strerror(gpf_open_errno)); + } + if (gpf_read_errno != 0) { + simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, + "I/O error reading global preferences file\n\"%s\": %s.", gpf_path, + g_strerror(gpf_read_errno)); + } + } + if (pf_path != NULL) { + if (pf_open_errno != 0) { + simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, + "Could not open your preferences file\n\"%s\": %s.", pf_path, + g_strerror(pf_open_errno)); + } + if (pf_read_errno != 0) { + simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, + "I/O error reading your preferences file\n\"%s\": %s.", pf_path, + g_strerror(pf_read_errno)); + } + g_free(pf_path); + pf_path = NULL; + } + +#ifdef _WIN32 + /* if the user wants a console to be always there, well, we should open one for him */ + if (prefs_p->gui_console_open == console_open_always) { + create_console(); + } +#endif + + /* Read the capture filter file. */ + read_filter_list(CFILTER_LIST, &cf_path, &cf_open_errno); + if (cf_path != NULL) { + simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, + "Could not open your capture filter file\n\"%s\": %s.", cf_path, + g_strerror(cf_open_errno)); + g_free(cf_path); + } + + /* Read the display filter file. */ + read_filter_list(DFILTER_LIST, &df_path, &df_open_errno); + if (df_path != NULL) { + simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, + "Could not open your display filter file\n\"%s\": %s.", df_path, + g_strerror(df_open_errno)); + g_free(df_path); + } + + /* Read the disabled protocols file. */ + read_disabled_protos_list(gdp_path, &gdp_open_errno, &gdp_read_errno, + dp_path, &dp_open_errno, &dp_read_errno); + if (*gdp_path != NULL) { + if (gdp_open_errno != 0) { + simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, + "Could not open global disabled protocols file\n\"%s\": %s.", + *gdp_path, g_strerror(gdp_open_errno)); + } + if (gdp_read_errno != 0) { + simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, + "I/O error reading global disabled protocols file\n\"%s\": %s.", + *gdp_path, g_strerror(gdp_read_errno)); + } + g_free(*gdp_path); + *gdp_path = NULL; + } + if (*dp_path != NULL) { + if (dp_open_errno != 0) { + simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, + "Could not open your disabled protocols file\n\"%s\": %s.", *dp_path, + g_strerror(dp_open_errno)); + } + if (dp_read_errno != 0) { + simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, + "I/O error reading your disabled protocols file\n\"%s\": %s.", *dp_path, + g_strerror(dp_read_errno)); + } + g_free(*dp_path); + *dp_path = NULL; + } + + return prefs_p; +} + +/* update the main window */ +void main_window_update(void) +{ + WiresharkApplication::processEvents(); +} + +/* exit the main window */ +void main_window_exit(void) +{ + exit(0); +} + +#ifdef HAVE_LIBPCAP + +/* quit a nested main window */ +void main_window_nested_quit(void) +{ +// if (gtk_main_level() > 0) + WiresharkApplication::quit(); +} + +/* quit the main window */ +void main_window_quit(void) +{ + WiresharkApplication::quit(); +} + +#endif /* HAVE_LIBPCAP */ + + +// xxx copied from ../gtk/main.c +static void +print_usage(gboolean print_ver) { + FILE *output; + +#ifdef _WIN32 + create_console(); +#endif + + if (print_ver) { + output = stdout; + fprintf(output, "Wireshark " VERSION "%s\n" + "Interactively dump and analyze network traffic.\n" + "See http://www.wireshark.org for more information.\n" + "\n" + "%s", + wireshark_svnversion, get_copyright_info()); + } else { + output = stderr; + } + fprintf(output, "\n"); + fprintf(output, "Usage: wireshark [options] ... [ <infile> ]\n"); + fprintf(output, "\n"); + +#ifdef HAVE_LIBPCAP + fprintf(output, "Capture interface:\n"); + fprintf(output, " -i <interface> name or idx of interface (def: first non-loopback)\n"); + fprintf(output, " -f <capture filter> packet filter in libpcap filter syntax\n"); + fprintf(output, " -s <snaplen> packet snapshot length (def: 65535)\n"); + fprintf(output, " -p don't capture in promiscuous mode\n"); + fprintf(output, " -k start capturing immediately (def: do nothing)\n"); + fprintf(output, " -Q quit Wireshark after capturing\n"); + fprintf(output, " -S update packet display when new packets are captured\n"); + fprintf(output, " -l turn on automatic scrolling while -S is in use\n"); +#if defined(_WIN32) || defined(HAVE_PCAP_CREATE) + fprintf(output, " -B <buffer size> size of kernel buffer (def: 1MB)\n"); +#endif + fprintf(output, " -y <link type> link layer type (def: first appropriate)\n"); + fprintf(output, " -D print list of interfaces and exit\n"); + fprintf(output, " -L print list of link-layer types of iface and exit\n"); + fprintf(output, "\n"); + fprintf(output, "Capture stop conditions:\n"); + fprintf(output, " -c <packet count> stop after n packets (def: infinite)\n"); + fprintf(output, " -a <autostop cond.> ... duration:NUM - stop after NUM seconds\n"); + fprintf(output, " filesize:NUM - stop this file after NUM KB\n"); + fprintf(output, " files:NUM - stop after NUM files\n"); + /*fprintf(output, "\n");*/ + fprintf(output, "Capture output:\n"); + fprintf(output, " -b <ringbuffer opt.> ... duration:NUM - switch to next file after NUM secs\n"); + fprintf(output, " filesize:NUM - switch to next file after NUM KB\n"); + fprintf(output, " files:NUM - ringbuffer: replace after NUM files\n"); +#endif /* HAVE_LIBPCAP */ + + /*fprintf(output, "\n");*/ + fprintf(output, "Input file:\n"); + fprintf(output, " -r <infile> set the filename to read from (no pipes or stdin!)\n"); + + fprintf(output, "\n"); + fprintf(output, "Processing:\n"); + fprintf(output, " -R <read filter> packet filter in Wireshark display filter syntax\n"); + fprintf(output, " -n disable all name resolutions (def: all enabled)\n"); + fprintf(output, " -N <name resolve flags> enable specific name resolution(s): \"mntC\"\n"); + + fprintf(output, "\n"); + fprintf(output, "User interface:\n"); + fprintf(output, " -C <config profile> start with specified configuration profile\n"); + fprintf(output, " -g <packet number> go to specified packet number after \"-r\"\n"); + fprintf(output, " -J <jump filter> jump to the first packet matching the (display)\n"); + fprintf(output, " filter\n"); + fprintf(output, " -j search backwards for a matching packet after \"-J\"\n"); + fprintf(output, " -m <font> set the font name used for most text\n"); + fprintf(output, " -t ad|a|r|d|dd|e output format of time stamps (def: r: rel. to first)\n"); + fprintf(output, " -u s|hms output format of seconds (def: s: seconds)\n"); + fprintf(output, " -X <key>:<value> eXtension options, see man page for details\n"); + fprintf(output, " -z <statistics> show various statistics, see man page for details\n"); + + fprintf(output, "\n"); + fprintf(output, "Output:\n"); + fprintf(output, " -w <outfile|-> set the output filename (or '-' for stdout)\n"); + + fprintf(output, "\n"); + fprintf(output, "Miscellaneous:\n"); + fprintf(output, " -h display this help and exit\n"); + fprintf(output, " -v display version info and exit\n"); + fprintf(output, " -P <key>:<path> persconf:path - personal configuration files\n"); + fprintf(output, " persdata:path - personal data files\n"); + fprintf(output, " -o <name>:<value> ... override preference or recent setting\n"); + fprintf(output, " -K <keytab> keytab file to use for kerberos decryption\n"); +#ifndef _WIN32 + fprintf(output, " --display=DISPLAY X display to use\n"); +#endif + +#ifdef _WIN32 +// destroy_console(); +#endif +} + +// xxx copied from ../gtk/main.c +static void +show_version(void) +{ +#ifdef _WIN32 + create_console(); +#endif + + printf(PACKAGE " " VERSION "%s\n" + "\n" + "%s" + "\n" + "%s" + "\n" + "%s", + wireshark_svnversion, get_copyright_info(), comp_info_str->str, + runtime_info_str->str); + +#ifdef _WIN32 +// destroy_console(); +#endif +} + +/* + * Print to the standard error. On Windows, create a console for the + * standard error to show up on, if necessary. + * XXX - pop this up in a window of some sort on UNIX+X11 if the controlling + * terminal isn't the standard error? + */ +// xxx copied from ../gtk/main.c +void +vfprintf_stderr(const char *fmt, va_list ap) +{ +#ifdef _WIN32 + create_console(); +#endif + vfprintf(stderr, fmt, ap); +} + +void +fprintf_stderr(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vfprintf_stderr(fmt, ap); + va_end(ap); +} + +/* + * Report an error in command-line arguments. + * Creates a console on Windows. + */ +// xxx copied from ../gtk/main.c +void +cmdarg_err(const char *fmt, ...) +{ + va_list ap; + + fprintf_stderr("wireshark: "); + va_start(ap, fmt); + vfprintf_stderr(fmt, ap); + va_end(ap); + fprintf_stderr("\n"); +} + +/* + * Report additional information for an error in command-line arguments. + * Creates a console on Windows. + * XXX - pop this up in a window of some sort on UNIX+X11 if the controlling + * terminal isn't the standard error? + */ +// xxx copied from ../gtk/main.c +void +cmdarg_err_cont(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vfprintf_stderr(fmt, ap); + fprintf_stderr("\n"); + va_end(ap); +} + +static void +console_log_handler(const char *log_domain, GLogLevelFlags log_level, + const char *message, gpointer user_data _U_) +{ + QString level; + QDateTime qt = QDateTime::currentDateTime(); + +// xxx qtshark: We want all of the messages for now. +// /* ignore log message, if log_level isn't interesting based +// upon the console log preferences. +// If the preferences haven't been loaded loaded yet, display the +// message anyway. + +// The default console_log_level preference value is such that only +// ERROR, CRITICAL and WARNING level messages are processed; +// MESSAGE, INFO and DEBUG level messages are ignored. */ +// if((log_level & G_LOG_LEVEL_MASK & prefs.console_log_level) == 0 && +// prefs.console_log_level != 0) { +// return; + + switch(log_level & G_LOG_LEVEL_MASK) { + case G_LOG_LEVEL_ERROR: + level = "Err "; + break; + case G_LOG_LEVEL_CRITICAL: + level = "Crit"; + break; + case G_LOG_LEVEL_WARNING: + level = "Warn"; + break; + case G_LOG_LEVEL_MESSAGE: + level = "Msg "; + break; + case G_LOG_LEVEL_INFO: + level = "Info"; + break; + case G_LOG_LEVEL_DEBUG: + level = "Dbg "; + break; + default: + level = "unknown log_level %u"; + level.arg(log_level); + qDebug() << level; + g_assert_not_reached(); + } + + qDebug() << qt.toString() << log_domain << " " << level << message; + } + + +/* And now our feature presentation... [ fade to music ] */ +int main(int argc, char *argv[]) +{ + WiresharkApplication a(argc, argv); + MainWindow *w; + + char *init_progfile_dir_error; + char *s; + int opt; + gboolean arg_error = FALSE; + + extern int info_update_freq; /* Found in about_dlg.c. */ + const gchar *filter; + +#ifdef _WIN32 + WSADATA wsaData; +#endif /* _WIN32 */ + + char *rf_path; + int rf_open_errno; + char *gdp_path, *dp_path; + int err; +#ifdef HAVE_LIBPCAP + gboolean start_capture = FALSE; + gboolean list_link_layer_types = FALSE; + GList *if_list; + gchar *err_str; +#else + gboolean capture_option_specified = FALSE; +#ifdef _WIN32 +#ifdef HAVE_AIRPCAP + gchar *err_str; +#endif +#endif +#endif + gint pl_size = 280, tv_size = 95, bv_size = 75; + gchar *rc_file, *cf_name = NULL, *rfilter = NULL, *jfilter = NULL; + dfilter_t *rfcode = NULL; + gboolean rfilter_parse_failed = FALSE; + e_prefs *prefs_p; + char badopt; + //GtkWidget *splash_win = NULL; + GLogLevelFlags log_flags; + guint go_to_packet = 0; + gboolean jump_backwards = FALSE; + dfilter_t *jump_to_filter = NULL; + int optind_initial; + int status; + + // Hopefully we won't have to use QString::fromUtf8() in as many places. + QTextCodec *utf8codec = QTextCodec::codecForName("UTF-8"); + QTextCodec::setCodecForCStrings(utf8codec); + QTextCodec::setCodecForTr(utf8codec); + +#ifdef HAVE_LIBPCAP +#if defined(_WIN32) || defined(HAVE_PCAP_CREATE) +#define OPTSTRING_B "B:" +#else +#define OPTSTRING_B "" +#endif /* _WIN32 or HAVE_PCAP_CREATE */ +#else /* HAVE_LIBPCAP */ +#define OPTSTRING_B "" +#endif /* HAVE_LIBPCAP */ + +#ifdef HAVE_PCAP_CREATE +#define OPTSTRING_I "I" +#else +#define OPTSTRING_I "" +#endif + +#define OPTSTRING "a:b:" OPTSTRING_B "c:C:Df:g:Hhi:" OPTSTRING_I "jJ:kK:lLm:nN:o:P:pQr:R:Ss:t:u:vw:X:y:z:" + + static const char optstring[] = OPTSTRING; + + /* + * Get credential information for later use, and drop privileges + * before doing anything else. + * Let the user know if anything happened. + */ + init_process_policies(); + relinquish_special_privs_perm(); + + /* + * Attempt to get the pathname of the executable file. + */ + init_progfile_dir_error = init_progfile_dir(argv[0], main); + g_log(NULL, G_LOG_LEVEL_DEBUG, "progfile_dir: %s", get_progfile_dir()); + + /* initialize the funnel mini-api */ + // xxx qtshark + //initialize_funnel_ops(); + + AirPDcapInitContext(&airpdcap_ctx); + +// xxx qtshark +#ifdef _WIN32 + /* Load wpcap if possible. Do this before collecting the run-time version information */ + load_wpcap(); + + /* ... and also load the packet.dll from wpcap */ + wpcap_packet_load(); + +#ifdef HAVE_AIRPCAP + /* Load the airpcap.dll. This must also be done before collecting + * run-time version information. */ + airpcap_dll_ret_val = load_airpcap(); + + switch (airpcap_dll_ret_val) { + case AIRPCAP_DLL_OK: + /* load the airpcap interfaces */ + airpcap_if_list = get_airpcap_interface_list(&err, &err_str); + + if (airpcap_if_list == NULL || g_list_length(airpcap_if_list) == 0){ + if (err == CANT_GET_AIRPCAP_INTERFACE_LIST && err_str != NULL) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", "Failed to open Airpcap Adapters!"); + g_free(err_str); + } + airpcap_if_active = NULL; + + } else { + + /* select the first ad default (THIS SHOULD BE CHANGED) */ + airpcap_if_active = airpcap_get_default_if(airpcap_if_list); + } + break; +#if 0 + /* + * XXX - Maybe we need to warn the user if one of the following happens??? + */ + case AIRPCAP_DLL_OLD: + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s","AIRPCAP_DLL_OLD\n"); + break; + + case AIRPCAP_DLL_ERROR: + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s","AIRPCAP_DLL_ERROR\n"); + break; + + case AIRPCAP_DLL_NOT_FOUND: + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s","AIRPCAP_DDL_NOT_FOUND\n"); + break; +#endif + } +#endif /* HAVE_AIRPCAP */ + + /* Start windows sockets */ + WSAStartup( MAKEWORD( 1, 1 ), &wsaData ); +#endif /* _WIN32 */ + + profile_store_persconffiles (TRUE); + + /* Assemble the compile-time version information string */ + comp_info_str = g_string_new("Compiled "); + + // xxx qtshark + //get_compiled_version_info(comp_info_str, get_gtk_compiled_info, get_gui_compiled_info); + + /* Assemble the run-time version information string */ + runtime_info_str = g_string_new("Running "); + // xxx qtshark + //get_runtime_version_info(runtime_info_str, get_gui_runtime_info); + + /* Read the profile independent recent file. We have to do this here so we can */ + /* set the profile before it can be set from the command line parameterts */ + // xxx qtshark + //recent_read_static(&rf_path, &rf_open_errno); + //if (rf_path != NULL && rf_open_errno != 0) { + // simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, + // "Could not open common recent file\n\"%s\": %s.", + // rf_path, strerror(rf_open_errno)); + //} + + /* "pre-scan" the command line parameters, if we have "console only" + parameters. We do this so we don't start GTK+ if we're only showing + command-line help or version information. + + XXX - this pre-scan is done before we start GTK+, so we haven't + run gtk_init() on the arguments. That means that GTK+ arguments + have not been removed from the argument list; those arguments + begin with "--", and will be treated as an error by getopt(). + + We thus ignore errors - *and* set "opterr" to 0 to suppress the + error messages. */ + opterr = 0; + optind_initial = optind; + while ((opt = getopt(argc, argv, optstring)) != -1) { + switch (opt) { + case 'C': /* Configuration Profile */ + if (profile_exists (optarg, FALSE)) { + set_profile_name (optarg); + } else { + cmdarg_err("Configuration Profile \"%s\" does not exist", optarg); + exit(1); + } + break; + case 'D': /* Print a list of capture devices and exit */ +#ifdef HAVE_LIBPCAP + if_list = capture_interface_list(&err, &err_str); + if (if_list == NULL) { + switch (err) { + case CANT_GET_INTERFACE_LIST: + cmdarg_err("%s", err_str); + g_free(err_str); + break; + + case NO_INTERFACES_FOUND: + cmdarg_err("There are no interfaces on which a capture can be done"); + break; + } + exit(2); + } + capture_opts_print_interfaces(if_list); + free_interface_list(if_list); + exit(0); +#else + capture_option_specified = TRUE; + arg_error = TRUE; +#endif + break; + case 'h': /* Print help and exit */ + print_usage(TRUE); + exit(0); + break; +#ifdef _WIN32 + case 'i': + if (strcmp(optarg, "-") == 0) + stdin_capture = TRUE; + break; +#endif + case 'P': /* Path settings - change these before the Preferences and alike are processed */ + status = filesystem_opt(opt, optarg); + if(status != 0) { + cmdarg_err("-P flag \"%s\" failed (hint: is it quoted and existing?)", optarg); + exit(status); + } + break; + case 'v': /* Show version and exit */ + show_version(); + exit(0); + break; + case 'X': + /* + * Extension command line options have to be processed before + * we call epan_init() as they are supposed to be used by dissectors + * or taps very early in the registration process. + */ + ex_opt_add(optarg); + break; + case '?': /* Ignore errors - the "real" scan will catch them. */ + break; + } + } + + cf_callback_add(main_cf_callback, NULL); + + /* Arrange that if we have no console window, and a GLib message logging + routine is called to log a message, we pop up a console window. + + We do that by inserting our own handler for all messages logged + to the default domain; that handler pops up a console if necessary, + and then calls the default handler. */ + + /* We might want to have component specific log levels later ... */ + + log_flags = (GLogLevelFlags) ( + G_LOG_LEVEL_ERROR| + G_LOG_LEVEL_CRITICAL| + G_LOG_LEVEL_WARNING| + G_LOG_LEVEL_MESSAGE| + G_LOG_LEVEL_INFO| + G_LOG_LEVEL_DEBUG| + G_LOG_FLAG_FATAL|G_LOG_FLAG_RECURSION ); + + g_log_set_handler(NULL, + log_flags, + console_log_handler, NULL /* user_data */); + g_log_set_handler(LOG_DOMAIN_MAIN, + log_flags, + console_log_handler, NULL /* user_data */); + +#ifdef HAVE_LIBPCAP + g_log_set_handler(LOG_DOMAIN_CAPTURE, + log_flags, + console_log_handler, NULL /* user_data */); + g_log_set_handler(LOG_DOMAIN_CAPTURE_CHILD, + log_flags, + console_log_handler, NULL /* user_data */); + + /* Set the initial values in the capture options. This might be overwritten + by preference settings and then again by the command line parameters. */ + capture_opts_init(&global_capture_opts, &cfile); +#endif + + /* Register all dissectors; we must do this before checking for the + "-G" flag, as the "-G" flag dumps information registered by the + dissectors, and we must do it before we read the preferences, in + case any dissectors register preferences. */ + epan_init(register_all_protocols,register_all_protocol_handoffs, + NULL, NULL, NULL, NULL, NULL, NULL +// splash_update, (gpointer) splash_win, +// failure_alert_box,open_failure_alert_box,read_failure_alert_box, +// write_failure_alert_box + ); + +// splash_update(RA_LISTENERS, NULL, (gpointer)splash_win); + + /* Register all tap listeners; we do this before we parse the arguments, + as the "-z" argument can specify a registered tap. */ + + /* we register the plugin taps before the other taps because + stats_tree taps plugins will be registered as tap listeners + by stats_tree_stat.c and need to registered before that */ + + #ifdef HAVE_PLUGINS + register_all_plugin_tap_listeners(); + #endif + +// register_all_tap_listeners(); + +// splash_update(RA_PREFERENCES, NULL, (gpointer)splash_win); + + /* Now register the preferences for any non-dissector modules. + We must do that before we read the preferences as well. */ + prefs_register_modules(); + + prefs_p = read_configuration_files (&gdp_path, &dp_path); + /* Removed thread code: + * http://anonsvn.wireshark.org/viewvc/viewvc.cgi?view=rev&revision=35027 + */ + + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: timestamp types should be set elsewhere"); + timestamp_set_type(TS_RELATIVE); + timestamp_set_precision(TS_PREC_AUTO_USEC); + timestamp_set_seconds_type(TS_SECONDS_DEFAULT); + +///////// + + build_column_format_array(&cfile.cinfo, prefs_p->num_cols, TRUE); + + font_init(); + +//////// + + /* Read the dynamic part of the recent file, as we have the gui now ready for + it. */ + recent_read_dynamic(&rf_path, &rf_open_errno); + if (rf_path != NULL && rf_open_errno != 0) { + simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, + "Could not open recent file\n\"%s\": %s.", + rf_path, g_strerror(rf_open_errno)); + } + + color_filters_enable(recent.packet_list_colorize); + + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: fetch recent color settings"); + color_filters_enable(TRUE); + +//////// + + switch (user_font_apply()) { + case FA_SUCCESS: + break; + case FA_FONT_NOT_RESIZEABLE: + /* "user_font_apply()" popped up an alert box. */ + /* turn off zooming - font can't be resized */ + case FA_FONT_NOT_AVAILABLE: + /* XXX - did we successfully load the un-zoomed version earlier? + If so, this *probably* means the font is available, but not at + this particular zoom level, but perhaps some other failure + occurred; I'm not sure you can determine which is the case, + however. */ + /* turn off zooming - zoom level is unavailable */ + default: + /* in any other case than FA_SUCCESS, turn off zooming */ +// recent.gui_zoom_level = 0; + /* XXX: would it be a good idea to disable zooming (insensitive GUI)? */ + break; + } + +//////// + color_filters_init(); + +//////// + w = new(MainWindow); + w->show(); + + return a.exec(); +} + +void +create_console(void) { + +} diff --git a/ui/qt/main_status_bar.cpp b/ui/qt/main_status_bar.cpp new file mode 100644 index 0000000000..4266fb4660 --- /dev/null +++ b/ui/qt/main_status_bar.cpp @@ -0,0 +1,107 @@ +/* main_status_bar.cpp + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <glib.h> + +#include "main_status_bar.h" + +#include "main_statusbar.h" + +/* Temporary message timeouts */ +#define TEMPORARY_MSG_TIMEOUT (7 * 1000) +#define TEMPORARY_FLASH_TIMEOUT (1 * 1000) +#define TEMPORARY_FLASH_INTERVAL (TEMPORARY_FLASH_TIMEOUT / 4) + +/* + * Push a formatted temporary message onto the statusbar. + */ +void +statusbar_push_temporary_msg(const gchar *msg_format, ...) +{ + va_list ap; + gchar *msg; + guint msg_id; + + va_start(ap, msg_format); + msg = g_strdup_vprintf(msg_format, ap); + va_end(ap); + + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: statusbar_push_temporary_msg: %s", msg); + +// msg_id = gtk_statusbar_push(GTK_STATUSBAR(info_bar), main_ctx, msg); + g_free(msg); + +// flash_time = TEMPORARY_FLASH_TIMEOUT - 1; +// g_timeout_add(TEMPORARY_FLASH_INTERVAL, statusbar_flash_temporary_msg, NULL); + +// g_timeout_add(TEMPORARY_MSG_TIMEOUT, statusbar_remove_temporary_msg, GUINT_TO_POINTER(msg_id)); +} + +/* + * Update the packets statusbar to the current values + */ +void +packets_bar_update(void) +{ + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: packets_bar_update"); +// if(packets_bar) { +// /* Remove old status */ +// if(packets_str) { +// gtk_statusbar_pop(GTK_STATUSBAR(packets_bar), packets_ctx); +// } else { +// packets_str = g_string_new (""); +// } + +// /* Do we have any packets? */ +// if(cfile.count) { +// g_string_printf(packets_str, " Packets: %u Displayed: %u Marked: %u", +// cfile.count, cfile.displayed_count, cfile.marked_count); +// if(cfile.drops_known) { +// g_string_append_printf(packets_str, " Dropped: %u", cfile.drops); +// } +// if(cfile.ignored_count > 0) { +// g_string_append_printf(packets_str, " Ignored: %u", cfile.ignored_count); +// } +// if(!cfile.is_tempfile){ +// /* Loading an existing file */ +// gulong computed_elapsed = cf_get_computed_elapsed(); +// g_string_append_printf(packets_str, " Load time: %lu:%02lu.%03lu", +// computed_elapsed/60000, +// computed_elapsed%60000/1000, +// computed_elapsed%1000); +// } +// } else { +// g_string_printf(packets_str, " No Packets"); +// } +// gtk_statusbar_push(GTK_STATUSBAR(packets_bar), packets_ctx, packets_str->str); +// } +} + +MainStatusBar::MainStatusBar(QWidget *parent) : + QStatusBar(parent) +{ +} diff --git a/ui/qt/main_status_bar.h b/ui/qt/main_status_bar.h new file mode 100644 index 0000000000..a4e5c074d2 --- /dev/null +++ b/ui/qt/main_status_bar.h @@ -0,0 +1,41 @@ +/* main_status_bar.h + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef MAIN_STATUS_BAR_H +#define MAIN_STATUS_BAR_H + +#include <QStatusBar> + +class MainStatusBar : public QStatusBar +{ + Q_OBJECT +public: + explicit MainStatusBar(QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // MAIN_STATUS_BAR_H diff --git a/ui/qt/main_welcome.cpp b/ui/qt/main_welcome.cpp new file mode 100644 index 0000000000..90e71b7888 --- /dev/null +++ b/ui/qt/main_welcome.cpp @@ -0,0 +1,201 @@ +/* main_welcome.cpp + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include <glib.h> + +#include "config.h" + +#include <epan/prefs.h> + +#include "version_info.h" + +#include "main_welcome.h" + +#include "wireshark_application.h" +#include "interface_tree.h" + +#include <QWidget> +#include <QGridLayout> +#include <QVBoxLayout> +#include <QPainter> +#include <QPen> +#include <QResizeEvent> +#include <QGraphicsBlurEffect> +#include <QLabel> +#include <QHeaderView> +#include <QFont> + +//MWOverlay::MWOverlay(QWidget *parent) : QWidget(parent) +//{ +// setPalette(Qt::transparent); +// setAttribute(Qt::WA_TransparentForMouseEvents); + +// QGraphicsBlurEffect *blur = new QGraphicsBlurEffect(this); +// setGraphicsEffect(blur); +//} + +//void MWOverlay::paintEvent(QPaintEvent *event) +//{ +// QPainter painter(this); +// painter.setRenderHint(QPainter::Antialiasing); + +// QRect border = rect(); +//// g_log(NULL, G_LOG_LEVEL_DEBUG, "rect pre: %d %d %d %d", border.top(), border.left(), border.bottom(), border.right()); +// border.setWidth(border.width() - 8); +// border.moveLeft(4); +// border.setHeight(border.height() - 8); +// border.moveTop(4); +//// g_log(NULL, G_LOG_LEVEL_DEBUG, "rect post: %d %d %d %d", border.top(), border.left(), border.bottom(), border.right()); +// QPen pen; +// pen.setWidth(8); +// pen.setColor(QColor(60, 60, 60, 80)); +// painter.setPen(pen); +//// painter.setBrush(Qt::blue); +// painter.drawRect(border); +//} + + +MainWelcome::MainWelcome(QWidget *parent) : + QFrame(parent) +{ + QGridLayout *grid = new QGridLayout(this); + QVBoxLayout *column; + QLabel *heading; + InterfaceTree *iface_tree; + + setStyleSheet( + "QFrame {" + " background: palette(base);" + " }" + ); + +// grid->setContentsMargins (0, 0, 0, 0); + grid->setColumnStretch(0, 60); + + // Banner row, 3 column span + QString banner = QString("Wireshark"); + heading = new QLabel(banner); + grid->addWidget(heading, 0, 0, 1, 3); + + // Column 1: Capture + column = new QVBoxLayout(); + grid->addLayout(column, 1, 0, Qt::AlignTop); + + heading = new QLabel("<h1>Capture</h1>"); + column->addWidget(heading); + + iface_tree = new InterfaceTree(this); + column->addWidget(iface_tree); + + heading = new QLabel("<h1>Capture Help</h1>"); + column->addWidget(heading); + + // Column 2: Files + column = new QVBoxLayout(); + grid->addLayout(column, 1, 1, Qt::AlignTop); + grid->setColumnStretch(1, 70); + + heading = new QLabel("<h1>Files</h1>"); + column->addWidget(heading); + + m_recent_files.setStyleSheet( + "QListWidget {" + " border: 0;" + "}" + ); + column->addWidget(&m_recent_files); + connect(wsApp, SIGNAL(updateRecentItemStatus(const QString &, qint64, bool)), this, SLOT(updateRecentFiles())); + connect(&m_recent_files, SIGNAL(itemActivated(QListWidgetItem *)), this, SLOT(openRecentItem(QListWidgetItem *))); + updateRecentFiles(); + + // Column 3: Online Resources + column = new QVBoxLayout(); + grid->addLayout(column, 1, 2, Qt::AlignTop); + grid->setColumnStretch(2, 50); + + heading = new QLabel("<h1>Online</h1>"); + column->addWidget(heading); + + // Sigh. This doesn't work in Qt 4.7 on OS X. +// QGraphicsBlurEffect *effect = new QGraphicsBlurEffect(this) ; +// effect->setBlurRadius(10); +// effect->setBlurHints(QGraphicsBlurEffect::QualityHint); +// setGraphicsEffect( effect ); +// overlay = new MWOverlay(this); + +} + + +void MainWelcome::updateRecentFiles() { + QString itemLabel; + QListWidgetItem *rfItem; + QFont rfFont; + + int rfRow = 0; + foreach (recent_item_status *ri, wsApp->recent_item_list()) { + itemLabel = ri->filename; + + if (rfRow >= m_recent_files.count()) { + m_recent_files.addItem(itemLabel); + } + + itemLabel.append(" ("); + if (ri->accessible) { + if (ri->size/1024/1024/1024 > 10) { + itemLabel.append(QString("%1 GB)").arg(ri->size/1024/1024/1024)); + } else if (ri->size/1024/1024 > 10) { + itemLabel.append(QString("%1 MB)").arg(ri->size/1024/1024)); + } else if (ri->size/1024 > 10) { + itemLabel.append(QString("%1 KB)").arg(ri->size/1024)); + } else { + itemLabel.append(QString("%1 Bytes").arg(ri->size)); + } + } else { + itemLabel.append("not found)"); + } + rfFont.setItalic(!ri->accessible); + rfItem = m_recent_files.item(rfRow); + rfItem->setText(itemLabel); + rfItem->setData(Qt::UserRole, ri->filename); + rfItem->setFlags(ri->accessible ? Qt::ItemIsSelectable | Qt::ItemIsEnabled : Qt::NoItemFlags); + rfItem->setFont(rfFont); + rfRow++; + } + + while (m_recent_files.count() > prefs.gui_recent_files_count_max) { + m_recent_files.takeItem(m_recent_files.count()); + } +} + +void MainWelcome::openRecentItem(QListWidgetItem *item) { + QString cfPath = item->data(Qt::UserRole).toString(); + emit recentFileActivated(cfPath); +} + +//void MainWelcome::resizeEvent(QResizeEvent *event) +//{ +// overlay->resize(event->size()); +//// event->accept(); + +// QFrame::resizeEvent(event); +//} diff --git a/ui/qt/main_welcome.h b/ui/qt/main_welcome.h new file mode 100644 index 0000000000..0cfa5bb77c --- /dev/null +++ b/ui/qt/main_welcome.h @@ -0,0 +1,65 @@ +/* main_welcome.h + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef MAIN_WELCOME_H +#define MAIN_WELCOME_H + +#include <QFrame> +#include <QListWidget> + +//class MWOverlay : public QWidget +//{ +//public: +// MWOverlay(QWidget *parent); + +//protected: +// void paintEvent(QPaintEvent *event); +//}; + + +class MainWelcome : public QFrame +{ + Q_OBJECT +public: + explicit MainWelcome(QWidget *parent = 0); + +protected: +// void resizeEvent(QResizeEvent *event); + +private: + // QListWidget doesn't activate items when the return or enter keys are pressed on OS X. + // We may want to subclass it at some point. + QListWidget m_recent_files; +// MWOverlay *overlay; + + +signals: + void recentFileActivated(QString& cfile); + +private slots: + void updateRecentFiles(); + void openRecentItem(QListWidgetItem *item); + +}; + +#endif // MAIN_WELCOME_H diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp new file mode 100644 index 0000000000..ecf83f096a --- /dev/null +++ b/ui/qt/main_window.cpp @@ -0,0 +1,229 @@ +/* main_window.cpp + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "main_window.h" +#include "ui_main_window.h" + +#include "config.h" + +#include <glib.h> + +#include <epan/prefs.h> + +#include "wireshark_application.h" +#include "packet_list.h" +#include "byte_view_tab.h" +#include "capture_file_dialog.h" + +#include "qt_ui_utils.h" + +#include <QTreeWidget> +#include <QTabWidget> +#include <QAction> +#include <QToolButton> +#include <QKeyEvent> + +#include "globals.h" + +//menu_recent_file_write_all + +// If we ever add support for multiple windows this will need to be replaced. +static MainWindow *cur_main_window = NULL; + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + cur_main_window = this; + ui->setupUi(this); + + connect(wsApp, SIGNAL(updateRecentItemStatus(const QString &, qint64, bool)), this, SLOT(updateRecentFiles())); + updateRecentFiles(); + + dfComboBox = new DisplayFilterCombo(); + +#ifdef _WIN32 + // Qt <= 4.7 doesn't seem to style Windows toolbars. If we wanted to be really fancy we could use Blur Behind: + // http://labs.qt.nokia.com/2009/09/15/using-blur-behind-on-windows/ + setStyleSheet( + "QToolBar {" + " background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(255,255,255,127), stop:0.37 rgba(234,234,234,127), stop:1 rgba(155,155,155,91));" + "}" + ); +#endif + ui->mainToolBar->addWidget(dfComboBox); + + splitterV = new QSplitter(ui->mainStack); + splitterV->setObjectName(QString::fromUtf8("splitterV")); + splitterV->setOrientation(Qt::Vertical); + + PacketList *packetList = new PacketList(splitterV); + + QTreeWidget *protoTree = new QTreeWidget(splitterV); + protoTree->setHeaderHidden(true); + + ByteViewTab *byteViewTab = new ByteViewTab(splitterV); + byteViewTab->setTabPosition(QTabWidget::South); + byteViewTab->setDocumentMode(true); + + packetList->setProtoTree(protoTree); + packetList->setByteViewTab(byteViewTab); + + splitterV->addWidget(packetList); + splitterV->addWidget(protoTree); + splitterV->addWidget(byteViewTab); + + ui->mainStack->addWidget(splitterV); + + mainWelcome = new MainWelcome(ui->mainStack); + ui->mainStack->addWidget(mainWelcome); + connect(mainWelcome, SIGNAL(recentFileActivated(QString&)), this, SLOT(openCaptureFile(QString&))); + + ui->mainStack->setCurrentWidget(mainWelcome); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::closeCaptureFile() { + cf_close(&cfile); + ui->mainStack->setCurrentWidget(mainWelcome); +} + +void MainWindow::openCaptureFile(QString &cfPath) + { + dfilter_t *rfcode = NULL; + + if (cfPath.isEmpty()) { + QStringList cfNames; + CaptureFileDialog cfDlg(this); + + cfDlg.setLabelText(QFileDialog::FileName, tr("Wireshark: Open Capture File")); + cfDlg.setDirectory("/Users/gcombs/Documents/Captures"); + cfDlg.setNameFilter(tr("Capture Files (*.pcap *.pcapng)")); + cfDlg.setFileMode(QFileDialog::ExistingFile); + + if (cfDlg.exec()) { + cfNames = cfDlg.selectedFiles(); + if (cfNames.length() > 0) { + cfPath = cfNames[0]; + } + } + } + + if (cfPath.length() > 0) { + int err; + + /* Try to open the capture file. */ + if (cf_open(&cfile, cfPath.toUtf8().constData(), FALSE, &err) != CF_OK) { + /* We couldn't open it; don't dismiss the open dialog box, + just leave it around so that the user can, after they + dismiss the alert box popped up for the open error, + try again. */ + if (rfcode != NULL) + dfilter_free(rfcode); + return; + } else { + ui->mainStack->setCurrentWidget(splitterV); + cf_read(&cfile, FALSE); + } + } +} + +void MainWindow::recentActionTriggered() { + QAction *ra = qobject_cast<QAction*>(sender()); + + if (ra) { + QString cfPath = ra->data().toString(); + openCaptureFile(cfPath); + } +} + +// XXX - Copied from gtk/menus.c + +/** + * Add the capture filename (with an absolute path) to the "Recent Files" menu. + * + * @param cf_name Absolute path to the file. + * @param first Prepend the filename if true, otherwise append it. Default is false (append). + */ +// XXX - We should probably create a RecentFile class. +void MainWindow::updateRecentFiles() { + QAction *ra; + QMenu *recentMenu = ui->menuOpenRecentCaptureFile; + QString action_cf_name; + + if (!recentMenu) { + return; + } + + recentMenu->clear(); + + /* Iterate through the actions in menuOpenRecentCaptureFile, + * removing special items, a maybe duplicate entry and every item above count_max */ + int shortcut = Qt::Key_0; + foreach (recent_item_status *ri, wsApp->recent_item_list()) { + // Add the new item + ra = new QAction(recentMenu); + ra->setData(ri->filename); + // XXX - Needs get_recent_item_status or equivalent + ra->setEnabled(ri->accessible); + recentMenu->insertAction(NULL, ra); + action_cf_name = ra->data().toString(); + if (shortcut <= Qt::Key_9) { + ra->setShortcut(Qt::META | shortcut); + shortcut++; + } + ra->setText(action_cf_name); + connect(ra, SIGNAL(triggered()), this, SLOT(recentActionTriggered())); + } + + if (recentMenu->actions().count() > 0) { + // Separator + "Clear" + // XXX - Do we really need this? + ra = new QAction(recentMenu); + ra->setSeparator(true); + recentMenu->insertAction(NULL, ra); + + ra = new QAction(recentMenu); + ra->setText("Clear Menu"); + recentMenu->insertAction(NULL, ra); + connect(ra, SIGNAL(triggered()), wsApp, SLOT(clearRecentItems())); + } else { + if (ui->actionDummyNoFilesFound) { + recentMenu->addAction(ui->actionDummyNoFilesFound); + } + } +} + +void MainWindow::keyPressEvent(QKeyEvent *event) { + + if (event->modifiers() & Qt::ControlModifier && event->key() == Qt::Key_Slash) { + dfComboBox->setFocus(Qt::ShortcutFocusReason); + return; + } + + QMainWindow::keyPressEvent(event); +} diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h new file mode 100644 index 0000000000..98c1950ac2 --- /dev/null +++ b/ui/qt/main_window.h @@ -0,0 +1,68 @@ +/* main_window.h + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <stdio.h> + +#include <QMainWindow> +#include <QSplitter> +#include "main_welcome.h" +#include "display_filter_combo.h" + +class QAction; + +namespace Ui { + class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +protected: + void keyPressEvent(QKeyEvent *event); + +private: + Ui::MainWindow *ui; + QMenu *openRecentMenu; + QSplitter *splitterV; + MainWelcome *mainWelcome; + DisplayFilterCombo *dfComboBox; + +public slots: + +private slots: + void closeCaptureFile(); + void updateRecentFiles(); + void openCaptureFile(QString& cfPath = *new QString()); + void recentActionTriggered(); +}; + + +#endif // MAINWINDOW_H diff --git a/ui/qt/main_window.ui b/ui/qt/main_window.ui new file mode 100644 index 0000000000..6ab73243b4 --- /dev/null +++ b/ui/qt/main_window.ui @@ -0,0 +1,257 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>960</width> + <height>768</height> + </rect> + </property> + <property name="windowTitle"> + <string>Wireshark</string> + </property> + <property name="iconSize"> + <size> + <width>24</width> + <height>24</height> + </size> + </property> + <property name="unifiedTitleAndToolBarOnMac"> + <bool>true</bool> + </property> + <widget class="QWidget" name="centralWidget"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <layout class="QGridLayout" name="gridLayout"> + <property name="margin"> + <number>0</number> + </property> + <item row="0" column="0"> + <widget class="QStackedWidget" name="mainStack"> + <widget class="QWidget" name="welcomePage"/> + <widget class="QWidget" name="packetPage"/> + </widget> + </item> + </layout> + </widget> + <widget class="QMenuBar" name="menuBar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>960</width> + <height>22</height> + </rect> + </property> + <widget class="QMenu" name="menuFile"> + <property name="title"> + <string>File</string> + </property> + <widget class="QMenu" name="menuOpenRecentCaptureFile"> + <property name="title"> + <string>Open Recent</string> + </property> + <addaction name="actionDummyNoFilesFound"/> + </widget> + <addaction name="actionOpenCaptureFile"/> + <addaction name="menuOpenRecentCaptureFile"/> + <addaction name="separator"/> + <addaction name="actionCloseCaptureFile"/> + <addaction name="actionQuit"/> + </widget> + <widget class="QMenu" name="menuEdit"> + <property name="title"> + <string>Edit</string> + </property> + </widget> + <widget class="QMenu" name="menuCapture"> + <property name="title"> + <string>Capture</string> + </property> + <addaction name="actionInterfaces"/> + <addaction name="actionStartCapture"/> + <addaction name="actionStopCapture"/> + </widget> + <addaction name="menuFile"/> + <addaction name="menuEdit"/> + <addaction name="menuCapture"/> + </widget> + <widget class="QToolBar" name="mainToolBar"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="movable"> + <bool>true</bool> + </property> + <property name="allowedAreas"> + <set>Qt::BottomToolBarArea|Qt::TopToolBarArea</set> + </property> + <property name="iconSize"> + <size> + <width>24</width> + <height>24</height> + </size> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonTextUnderIcon</enum> + </property> + <attribute name="toolBarArea"> + <enum>TopToolBarArea</enum> + </attribute> + <attribute name="toolBarBreak"> + <bool>false</bool> + </attribute> + <addaction name="actionStartCapture"/> + <addaction name="actionStopCapture"/> + <addaction name="separator"/> + </widget> + <widget class="QStatusBar" name="statusBar"/> + <widget class="QToolBar" name="utilityToolBar"> + <property name="windowTitle"> + <string>toolBar</string> + </property> + <attribute name="toolBarArea"> + <enum>TopToolBarArea</enum> + </attribute> + <attribute name="toolBarBreak"> + <bool>true</bool> + </attribute> + </widget> + <action name="actionOpenCaptureFile"> + <property name="text"> + <string>Open</string> + </property> + <property name="shortcut"> + <string>Ctrl+O</string> + </property> + </action> + <action name="actionQuit"> + <property name="text"> + <string>Quit</string> + </property> + <property name="shortcut"> + <string>Ctrl+Q</string> + </property> + </action> + <action name="actionInterfaces"> + <property name="text"> + <string>Interfaces</string> + </property> + </action> + <action name="actionStartCapture"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="icon"> + <iconset resource="toolbar.qrc"> + <normaloff>:/toolbar/main/capture_start_24.png</normaloff> + <normalon>:/toolbar/main/capture_start_active_24.png</normalon>:/toolbar/main/capture_start_24.png</iconset> + </property> + <property name="text"> + <string>Start</string> + </property> + <property name="toolTip"> + <string>Start capturing packets</string> + </property> + <property name="shortcut"> + <string>Ctrl+K</string> + </property> + </action> + <action name="actionStopCapture"> + <property name="icon"> + <iconset resource="toolbar.qrc"> + <normaloff>:/toolbar/main/capture_stop_24.png</normaloff>:/toolbar/main/capture_stop_24.png</iconset> + </property> + <property name="text"> + <string>Stop</string> + </property> + <property name="toolTip"> + <string>Stop capturing packets</string> + </property> + </action> + <action name="actionCloseCaptureFile"> + <property name="text"> + <string>Close</string> + </property> + <property name="shortcut"> + <string>Ctrl+W</string> + </property> + </action> + <action name="actionDummyNoFilesFound"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>No files found</string> + </property> + </action> + </widget> + <layoutdefault spacing="6" margin="11"/> + <resources> + <include location="toolbar.qrc"/> + </resources> + <connections> + <connection> + <sender>actionQuit</sender> + <signal>triggered()</signal> + <receiver>MainWindow</receiver> + <slot>close()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>408</x> + <y>258</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionOpenCaptureFile</sender> + <signal>triggered()</signal> + <receiver>MainWindow</receiver> + <slot>openCaptureFile()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>408</x> + <y>258</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionCloseCaptureFile</sender> + <signal>triggered()</signal> + <receiver>MainWindow</receiver> + <slot>closeCaptureFile()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>479</x> + <y>383</y> + </hint> + </hints> + </connection> + </connections> + <slots> + <slot>openCaptureFile()</slot> + <slot>closeCaptureFile()</slot> + </slots> +</ui> diff --git a/ui/qt/monospace_font.cpp b/ui/qt/monospace_font.cpp new file mode 100644 index 0000000000..6cc7aae119 --- /dev/null +++ b/ui/qt/monospace_font.cpp @@ -0,0 +1,134 @@ +/* monospace_font.cpp + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "monospace_font.h" + +#include <QFontMetrics> + +//MonospaceFont::MonospaceFont(QObject *parent) : +// QFont(parent) +//{ +//} + +QFont m_r_font, m_b_font; + +//void MonospaceFont::propagate() { +// emit(monospaceFontChanged(self)); +//} + +void +font_init(void) { + m_r_font.setFamily("Lucida Console"); +// m_r_font.setPointSize(10); +#if QT_VERSION >= 0x040700 + m_r_font.setStyleHint(QFont::Monospace); +#else + m_r_font.setStyleHint(QFont::TypeWriter); +#endif + + m_b_font.setFamily("Lucida Console"); +// m_b_font.setPointSize(10); + m_b_font.setWeight(QFont::Bold); +#if QT_VERSION >= 0x040700 + m_b_font.setStyleHint(QFont::Monospace); +#else + m_b_font.setStyleHint(QFont::TypeWriter); +#endif +} + +fa_ret_t +user_font_apply(void) { +// char *gui_font_name; +// PangoFontDescription *new_r_font, *new_b_font; +// PangoFontDescription *old_r_font = NULL, *old_b_font = NULL; + + /* convert font name to reflect the zoom level */ +// gui_font_name = font_zoom(prefs.gui_font_name); +// if (gui_font_name == NULL) { +// /* +// * This means the font name isn't an XLFD font name. +// * We just report that for now as a font not available in +// * multiple sizes. +// */ +// simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, +// "Your current font isn't available in any other sizes.\n"); +// return FA_FONT_NOT_RESIZEABLE; +// } + +// /* load normal and bold font */ +// new_r_font = pango_font_description_from_string(gui_font_name); +// new_b_font = pango_font_description_copy(new_r_font); +// pango_font_description_set_weight(new_b_font, PANGO_WEIGHT_BOLD); + +// if (new_r_font == NULL || new_b_font == NULL) { +// /* We're no longer using the new fonts; unreference them. */ +// if (new_r_font != NULL) +// pango_font_description_free(new_r_font); +// if (new_b_font != NULL) +// pango_font_description_free(new_b_font); +// g_free(gui_font_name); + +// /* We let our caller pop up a dialog box, as the error message +// depends on the context (did they zoom in or out, or did they +// do something else? */ +// return FA_FONT_NOT_AVAILABLE; +// } + +// /* the font(s) seem to be ok */ +// new_packet_list_set_font(new_r_font); +// set_ptree_font_all(new_r_font); +// old_r_font = m_r_font; +// old_b_font = m_b_font; +// set_fonts(new_r_font, new_b_font); + +// /* Redraw the packet bytes windows. */ +// redraw_packet_bytes_all(); + +// /* Redraw the "Follow TCP Stream" windows. */ +// follow_tcp_redraw_all(); + +// /* We're no longer using the old fonts; unreference them. */ +// if (old_r_font != NULL) +// pango_font_description_free(old_r_font); +// if (old_b_font != NULL) +// pango_font_description_free(old_b_font); +// g_free(gui_font_name); + + return FA_SUCCESS; +} + +// XXX - We might want to use a signal/slot for this (or just us a global variable). +QFont get_monospace_font(void) { + return m_r_font; +} + +int get_monospace_text_size(const char *str, bool regular) { + QFontMetrics *fm; + + if (regular) + fm = new QFontMetrics(m_r_font); + else + fm = new QFontMetrics(m_b_font); + + return fm->width(str); +} diff --git a/ui/qt/monospace_font.h b/ui/qt/monospace_font.h new file mode 100644 index 0000000000..d74dac945b --- /dev/null +++ b/ui/qt/monospace_font.h @@ -0,0 +1,64 @@ +/* monospace_font.h + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef MONOSPACE_FONT_H +#define MONOSPACE_FONT_H + +#include <QFont> + +//class MonospaceFont : public QFont +//{ +// Q_OBJECT +//public: +// explicit MonospaceFont(QObject *parent = 0); +// void propagate(void); + +//signals: +// void monospaceFontChanged(QFont); + +//public slots: + +//}; + +/** Init the application and user fonts at program start. */ +extern void font_init(void); + +/** Return value from font_apply() */ +typedef enum { + FA_SUCCESS, /**< function succeeded */ + FA_FONT_NOT_RESIZEABLE, /**< the chosen font isn't resizable */ + FA_FONT_NOT_AVAILABLE /**< the chosen font isn't available */ +} fa_ret_t; + +/** Applies a new user font, corresponding to the preferences font name and recent zoom level. + * Will also redraw the screen. + * + * @return if the new font could be set or not + */ +extern fa_ret_t user_font_apply(void); + +extern QFont get_monospace_font(void); + +extern int get_monospace_text_size(const char *str, bool regular); + +#endif // MONOSPACE_FONT_H diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp new file mode 100644 index 0000000000..0b8e0844b2 --- /dev/null +++ b/ui/qt/packet_list.cpp @@ -0,0 +1,410 @@ +/* packet_list.cpp + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <glib.h> + +#include <epan/epan.h> +#include <epan/epan_dissect.h> + +#include <epan/column_info.h> +#include <epan/column.h> +#include <epan/packet.h> + +#include "packet_list.h" +#include "monospace_font.h" +#include "proto_tree.h" + +#include "ui_util.h" +#include "globals.h" +#include "qt_ui_utils.h" + +#include "gtk/recent.h" + +#include <QTreeWidget> +#include <QTabWidget> +#include <QTextEdit> + +static gboolean enable_color; + +// If we ever add the ability to open multiple capture files we might be +// able to use something like QMap<capture_file *, PacketList *> to match +// capture files against packet lists and models. +static PacketList *cur_packet_list = NULL; + +guint +new_packet_list_append(column_info *cinfo _U_, frame_data *fdata, packet_info *pinfo _U_) +{ + if (!cur_packet_list) + return 0; + + /* fdata should be filled with the stuff we need + * strings are built at display time. + */ + guint visible_pos; + + visible_pos = cur_packet_list->packetListModel()->appendPacket(fdata); + return visible_pos; +} + +// Copied from gtk/new_packet_list.c +void new_packet_list_resize_column(gint col) +{ + // xxx qtshark +// gint col_width; +// const gchar *long_str; + +g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: new_packet_list_resize_column %d", col); +// long_str = packet_list_get_widest_column_string(packetlist, col); +// if(!long_str || strcmp("",long_str)==0) +// /* If we get an empty string leave the width unchanged */ +// return; +// column = gtk_tree_view_get_column (GTK_TREE_VIEW(packetlist->view), col); +// col_width = get_default_col_size (packetlist->view, long_str); +// gtk_tree_view_column_set_fixed_width(column, col_width); +} + +void +new_packet_list_select_first_row(void) +{ + cur_packet_list->setCurrentIndex(cur_packet_list->packetListModel()->index(0,0)); + cur_packet_list->setFocus(); +} + +void +new_packet_list_select_last_row(void) +{ + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: new_packet_list_select_last_row"); +// GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(packetlist->view)); +// GtkTreeIter iter; +// gint children; +// guint last_row; + +// if((children = gtk_tree_model_iter_n_children(model, NULL)) == 0) +// return; + +// last_row = children-1; +// if(!gtk_tree_model_iter_nth_child(model, &iter, NULL, last_row)) +// return; + +// scroll_to_and_select_iter(model, NULL, &iter); +} + +/* + * Given a frame_data structure, scroll to and select the row in the + * packet list corresponding to that frame. If there is no such + * row, return FALSE, otherwise return TRUE. + */ +gboolean +new_packet_list_select_row_from_data(frame_data *fdata_needle) +{ + int row = cur_packet_list->packetListModel()->visibleIndexOf(fdata_needle); + if (row >= 0) { + cur_packet_list->setCurrentIndex(cur_packet_list->packetListModel()->index(row,0)); + return TRUE; + } + + return FALSE; +} + +gboolean +new_packet_list_check_end(void) +{ + gboolean at_end = FALSE; +// GtkAdjustment *adj; + + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: new_packet_list_check_end"); + +// adj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(packetlist->view)); +// g_return_val_if_fail(adj != NULL, FALSE); + +//#if GTK_CHECK_VERSION(2,14,0) +// if (gtk_adjustment_get_value(adj) >= gtk_adjustment_get_upper(adj) - gtk_adjustment_get_page_size(adj)) { +//#else +// if (adj->value >= adj->upper - adj->page_size) { +//#endif +// at_end = TRUE; +// } +//#ifdef HAVE_LIBPCAP +//#if GTK_CHECK_VERSION(2,14,0) +// if (gtk_adjustment_get_value(adj) > 0 && at_end != last_at_end && at_end != auto_scroll_live) { +//#else +// if (adj->value > 0 && at_end != last_at_end && at_end != auto_scroll_live) { +//#endif +// menu_auto_scroll_live_changed(at_end); +// } +//#endif +// last_at_end = at_end; + return at_end; +} + +void +new_packet_list_clear(void) +{ + + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: new_packet_list_clear"); + + cur_packet_list->clear(); +} + +void +new_packet_list_enable_color(gboolean enable) +{ + enable_color = enable; + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: new_packet_list_enable_color: %d", enable); + + // gtk_widget_queue_draw (packetlist->view); +} + +void +new_packet_list_freeze(void) +{ + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: new_packet_list_freeze"); +// /* So we don't lose the model by the time we want to thaw it */ +// g_object_ref(packetlist); + +// /* Detach view from model */ +// gtk_tree_view_set_model(GTK_TREE_VIEW(packetlist->view), NULL); +} + +void +new_packet_list_thaw(void) +{ + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: new_packet_list_thaw"); +// /* Apply model */ +// gtk_tree_view_set_model( GTK_TREE_VIEW(packetlist->view), GTK_TREE_MODEL(packetlist)); + +// /* Remove extra reference added by new_packet_list_freeze() */ +// g_object_unref(packetlist); + +// packets_bar_update(); +} + +void +new_packet_list_recreate_visible_rows(void) +{ + cur_packet_list->packetListModel()->recreateVisibleRows(); +} + +frame_data * +new_packet_list_get_row_data(gint row) +{ + if (!cur_packet_list) + return NULL; + return cur_packet_list->packetListModel()->getRowFdata(row); +} + +void +new_packet_list_moveto_end(void) +{ +// GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(packetlist->view)); +// GtkTreeIter iter; +// GtkTreePath *path; +// gint children; +// guint last_row; + + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: new_packet_list_moveto_end"); + +// if((children = gtk_tree_model_iter_n_children(model, NULL)) == 0) +// return; + +// last_row = children-1; +// if(!gtk_tree_model_iter_nth_child(model, &iter, NULL, last_row)) +// return; + +// path = gtk_tree_model_get_path(model, &iter); + +// gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(packetlist->view), +// path, +// NULL, +// TRUE, /* use_align */ +// 0.5, /* row_align determines where the row is placed, 0.5 means center */ +// 0); /* The horizontal alignment of the column */ + +// gtk_tree_path_free(path); + +} + +/* Redraw the packet list *and* currently-selected detail */ +void +new_packet_list_queue_draw(void) +{ +// GtkTreeSelection *selection; +// GtkTreeIter iter; +// gint row; + + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: new_packet_list_queue_draw"); +// gtk_widget_queue_draw (packetlist->view); + +// selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(packetlist->view)); +// if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) +// return; +// row = row_number_from_iter(&iter); +// cf_select_packet(&cfile, row); + cf_select_packet(&cfile, 1); +} + +#define MIN_COL_WIDTH_STR "...." + +PacketList::PacketList(QWidget *parent) : + QTreeView(parent) +{ + setItemsExpandable(FALSE); + setRootIsDecorated(FALSE); + setSortingEnabled(TRUE); + setUniformRowHeights(TRUE); + setAccessibleName("Packet list"); + + m_packet_list_model = new PacketListModel(this, &cfile); + setModel(m_packet_list_model); + + g_assert(cur_packet_list == NULL); + cur_packet_list = this; + + m_protoTree = NULL; + m_byteViewTab = NULL; +} + +void PacketList::setProtoTree (QTreeWidget *protoTree) { + m_protoTree = protoTree; +} + +void PacketList::setByteViewTab (ByteViewTab *byteViewTab) { + m_byteViewTab = byteViewTab; +} + +PacketListModel *PacketList::packetListModel() const { + return m_packet_list_model; +} + +void PacketList::showEvent (QShowEvent *event) { +// g_log(NULL, G_LOG_LEVEL_DEBUG, "cols: %d", cfile.cinfo.num_cols); + for (int i = 0; i < cfile.cinfo.num_cols; i++) { + int fmt, col_width; + const char *long_str; + + fmt = get_column_format(i); + long_str = get_column_width_string(fmt, i); + if (long_str) { + col_width = get_monospace_text_size(long_str, TRUE); + } else { + col_width = get_monospace_text_size(MIN_COL_WIDTH_STR, TRUE); + } + setColumnWidth(i, col_width); + } +} + +void PacketList::selectionChanged (const QItemSelection & selected, const QItemSelection & deselected) { + QTreeView::selectionChanged(selected, deselected); + + if (m_protoTree) { + // Connect signals between the proto tree and byte views. + + int row = selected.first().top(); + cf_select_packet(&cfile, row); + + if (!cfile.edt && !cfile.edt->tree) { + return; + } + + proto_tree_draw(cfile.edt->tree, m_protoTree); + } + + g_log(NULL, G_LOG_LEVEL_DEBUG, "bvt: %p", m_byteViewTab); + if (m_byteViewTab && cfile.edt) { + GSList *src_le; + data_source *source; + + // Clear out existing tabs + while (m_byteViewTab->currentWidget()) { + delete m_byteViewTab->currentWidget(); + } + + for (src_le = cfile.edt->pi.data_src; src_le != NULL; src_le = src_le->next) { + source = (data_source *)src_le->data; + m_byteViewTab->addTab(get_data_source_name(source), source->tvb, cfile.edt->tree, m_protoTree, cfile.current_frame->flags.encoding); + } + } + + if (m_protoTree && m_byteViewTab) { + connect(m_protoTree, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), + m_byteViewTab, SLOT(protoTreeItemChanged(QTreeWidgetItem*))); + } +} + +void PacketList::clear() { + // packet_history_clear(); + packetListModel()->clear(); + m_protoTree->clear(); + + // Clear out existing tabs + while (m_byteViewTab->currentWidget()) { + delete m_byteViewTab->currentWidget(); + } + +// /* XXX is this correct in all cases? +// * Reset the sort column, use packetlist as model in case the list is frozen. +// */ + cur_packet_list->sortByColumn(0, Qt::AscendingOrder); + +} + +void new_packet_list_recent_write_all(FILE *rf) { + if (!cur_packet_list) + return; + + cur_packet_list->writeRecent(rf); +} + +void PacketList::writeRecent(FILE *rf) { + gint col, width, col_fmt; + gchar xalign; + + fprintf (rf, "%s:", RECENT_KEY_COL_WIDTH); + for (col = 0; col < packetListModel()->columnCount(); col++) { + if (col > 0) { + fprintf (rf, ","); + } + col_fmt = get_column_format(col); + if (col_fmt == COL_CUSTOM) { + fprintf (rf, " %%Cus:%s,", get_column_custom_field(col)); + } else { + fprintf (rf, " %s,", col_format_to_string(col_fmt)); + } + width = columnWidth(col); + xalign = recent_get_column_xalign (col); + if (width == 0) { + /* We have not initialized the packet list yet, use old values */ + width = recent_get_column_width (col); + } + fprintf (rf, " %d", width); + if (xalign != COLUMN_XALIGN_DEFAULT) { + fprintf (rf, ":%c", xalign); + } + } + fprintf (rf, "\n"); + +} diff --git a/ui/qt/packet_list.h b/ui/qt/packet_list.h new file mode 100644 index 0000000000..5f78a86a8f --- /dev/null +++ b/ui/qt/packet_list.h @@ -0,0 +1,60 @@ +/* packet_list.h + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef PACKET_LIST_H +#define PACKET_LIST_H + +#include "packet_list_model.h" +#include "byte_view_tab.h" + +#include <QTreeView> +#include <QTreeWidget> + +// It might make more sense to subclass QTableView here. +class PacketList : public QTreeView +{ + Q_OBJECT +public: + explicit PacketList(QWidget *parent = 0); + PacketListModel *packetListModel() const; + void setProtoTree(QTreeWidget *protoTree); + void setByteViewTab(ByteViewTab *byteViewTab); + void clear(); + void writeRecent(FILE *rf); + +protected: + void showEvent (QShowEvent *event); + void selectionChanged (const QItemSelection & selected, const QItemSelection & deselected); + +private: + PacketListModel *m_packet_list_model; + QTreeWidget *m_protoTree; + ByteViewTab *m_byteViewTab; + +signals: + +public slots: + +}; + +#endif // PACKET_LIST_H diff --git a/ui/qt/packet_list_model.cpp b/ui/qt/packet_list_model.cpp new file mode 100644 index 0000000000..30ec6f127e --- /dev/null +++ b/ui/qt/packet_list_model.cpp @@ -0,0 +1,293 @@ +/* packet_list_model.cpp + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "packet_list_model.h" +#include "monospace_font.h" + +#include <epan/epan_dissect.h> +#include <epan/column_info.h> +#include <epan/column.h> +#include <epan/nstime.h> +#include <epan/prefs.h> + +#include "color.h" +#include "color_filters.h" + +#include "globals.h" + +#include <QColor> + + +PacketListModel::PacketListModel(QObject *parent, capture_file *cfPtr) : + QAbstractItemModel(parent) +{ + cf = cfPtr; +} + +gint PacketListModel::appendPacket(frame_data *fdata) +{ + PacketListRecord *record = new PacketListRecord(fdata); + gint pos = visibleRows.count() + 1; + + physicalRows << record; + + if (fdata->flags.passed_dfilter || fdata->flags.ref_time) { + beginInsertRows(QModelIndex(), pos, pos); + visibleRows << record; + endInsertRows(); + } else { + pos = -1; + } + return pos; +} + +frame_data *PacketListModel::getRowFdata(int row) { + if (row >= visibleRows.count()) + return NULL; + PacketListRecord *record = visibleRows[row]; + if (!record) + return NULL; + return record->getFdata(); +} + + +QVariant PacketListModel::headerData(int section, Qt::Orientation orientation, + int role) const +{ + if (orientation == Qt::Horizontal && section < cf->cinfo.num_cols) { + switch (role) { + case Qt::DisplayRole: + return cf->cinfo.col_title[section]; + default: + break; + } + } + + return QVariant(); +} + +guint PacketListModel::recreateVisibleRows() +{ + int pos = visibleRows.count() + 1; + PacketListRecord *record; + + beginResetModel(); + visibleRows.clear(); + endResetModel(); + beginInsertRows(QModelIndex(), pos, pos); + foreach (record, physicalRows) { + if (record->getFdata()->flags.passed_dfilter || record->getFdata()->flags.ref_time) { + visibleRows << record; + } + } + endInsertRows(); + return visibleRows.count(); +} + +int PacketListModel::visibleIndexOf(frame_data *fdata) const +{ + int row = 0; + foreach (PacketListRecord *record, visibleRows) { + if (record->getFdata() == fdata) { + return row; + } + row++; + } + + return -1; +} + + +// Packet list records have no children (for now, at least). +QModelIndex PacketListModel::index(int row, int column, const QModelIndex &parent) + const +{ + if (row >= visibleRows.count() || row < 0 || column >= cf->cinfo.num_cols) + return QModelIndex(); + + PacketListRecord *record = visibleRows[row]; + + return createIndex(row, column, record); +} + +// Everything is under the root. +QModelIndex PacketListModel::parent(const QModelIndex &index) const +{ + return QModelIndex(); +} + +int PacketListModel::rowCount(const QModelIndex &parent) const +{ + if (parent.column() >= cf->cinfo.num_cols) + return 0; + + return visibleRows.count(); +} + +int PacketListModel::columnCount(const QModelIndex &parent) const +{ + return cf->cinfo.num_cols; +} + +QVariant PacketListModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) + return QVariant(); + + PacketListRecord *record = static_cast<PacketListRecord*>(index.internalPointer()); + if (!record) + return QVariant(); + frame_data *fdata = record->getFdata(); + if (!fdata) + return QVariant(); + + switch (role) { + case Qt::FontRole: + return get_monospace_font(); +// case Qt::TextAlignmentRole: + case Qt::BackgroundRole: + const color_t *color; + if (fdata->flags.ignored) { + color = &prefs.gui_ignored_bg; + } else if (fdata->flags.marked) { + color = &prefs.gui_marked_bg; + } else if (fdata->color_filter) { + const color_filter_t *color_filter = (const color_filter_t *) fdata->color_filter; + color = &color_filter->bg_color; + } else { + return QVariant(); + } +// g_log(NULL, G_LOG_LEVEL_DEBUG, "i: %d m: %d cf: %p bg: %d %d %d", fdata->flags.ignored, fdata->flags.marked, fdata->color_filter, color->red, color->green, color->blue); + return QColor(color->red >> 8, color->green >> 8, color->blue >> 8); + case Qt::ForegroundRole: + if (fdata->flags.ignored) { + color = &prefs.gui_ignored_fg; + } else if (fdata->flags.marked) { + color = &prefs.gui_marked_fg; + } else if (fdata->color_filter) { + const color_filter_t *color_filter = (const color_filter_t *) fdata->color_filter; + color = &color_filter->fg_color; + } else { + return QVariant(); + } + return QColor(color->red >> 8, color->green >> 8, color->blue >> 8); + case Qt::DisplayRole: + // Fall through + break; + default: + return QVariant(); + } + + int col_num = index.column(); + g_log(NULL, G_LOG_LEVEL_DEBUG, "showing col %d", col_num); + + if (col_num > cf->cinfo.num_cols) + return QVariant(); + + epan_dissect_t edt; + column_info *cinfo; + gboolean create_proto_tree; + union wtap_pseudo_header pseudo_header; /* Packet pseudo_header */ + guint8 pd[WTAP_MAX_PACKET_SIZE]; /* Packet data */ + gboolean dissect_columns = TRUE; // XXX - Currently only a placeholder + gboolean dissect_color = TRUE; // XXX - Currently only a placeholder + + if (dissect_columns) + cinfo = &cf->cinfo; + else + cinfo = NULL; + + if (!cf_read_frame_r(cf, fdata, &pseudo_header, pd)) { + /* + * Error reading the frame. + * + * Don't set the color filter for now (we might want + * to colorize it in some fashion to warn that the + * row couldn't be filled in or colorized), and + * set the columns to placeholder values, except + * for the Info column, where we'll put in an + * error message. + */ + if (dissect_columns) { + col_fill_in_error(cinfo, fdata, FALSE, FALSE /* fill_fd_columns */); + + // for(gint col = 0; col < cinfo->num_cols; ++col) { + // /* Skip columns based on frame_data because we already store those. */ + // if (!col_based_on_frame_data(cinfo, col)) + // packet_list_change_record(packet_list, record->physical_pos, col, cinfo); + // } + // record->columnized = TRUE; + } + if (dissect_color) { + fdata->color_filter = NULL; + // record->colorized = TRUE; + } + return QVariant(); /* error reading the frame */ + } + + create_proto_tree = (color_filters_used() && dissect_color) || + (have_custom_cols(cinfo) && dissect_columns); + + epan_dissect_init(&edt, + create_proto_tree, + FALSE /* proto_tree_visible */); + + if (dissect_color) + color_filters_prime_edt(&edt); + if (dissect_columns) + col_custom_prime_edt(&edt, cinfo); + + epan_dissect_run(&edt, &pseudo_header, pd, fdata, cinfo); + + if (dissect_color) + fdata->color_filter = color_filters_colorize_packet(&edt); + + if (dissect_columns) { + /* "Stringify" non frame_data vals */ + epan_dissect_fill_in_columns(&edt, FALSE, FALSE /* fill_fd_columns */); + + // for(col = 0; col < cinfo->num_cols; ++col) { + // /* Skip columns based on frame_data because we already store those. */ + // if (!col_based_on_frame_data(cinfo, col)) + // packet_list_change_record(packet_list, record->physical_pos, col, cinfo); + // } +// g_log(NULL, G_LOG_LEVEL_DEBUG, "d_c %d: %s", col_num, cinfo->col_data[col_num]); + } + + // if (dissect_columns) + // record->columnized = TRUE; + // if (dissect_color) + // record->colorized = TRUE; + + epan_dissect_cleanup(&edt); + + g_log(NULL, G_LOG_LEVEL_DEBUG, "rd for col %d: %p", col_num, record->data(col_num, cinfo)); + return record->data(col_num, cinfo); +} + +void PacketListModel::clear() { + beginResetModel(); + physicalRows.clear(); + visibleRows.clear(); + endResetModel(); +} diff --git a/ui/qt/packet_list_model.h b/ui/qt/packet_list_model.h new file mode 100644 index 0000000000..bd20c4e68c --- /dev/null +++ b/ui/qt/packet_list_model.h @@ -0,0 +1,78 @@ +/* packet_list_model.h + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef PACKET_LIST_MODEL_H +#define PACKET_LIST_MODEL_H + +#include "config.h" + +#include <stdio.h> + +#include <glib.h> + +#include <epan/packet.h> + +#include <QAbstractItemModel> +#include <QFont> +#include <QVector> + +#include "packet_list_record.h" + +#include "cfile.h" + +class PacketListModel : public QAbstractItemModel +{ + Q_OBJECT +public: + explicit PacketListModel(QObject *parent = 0, capture_file *cfPtr = NULL); + QModelIndex index(int row, int column, + const QModelIndex &parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex &index) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role) const; + + gint appendPacket(frame_data *fdata); + frame_data *getRowFdata(int row); + void clear(); + + int columnCount(const QModelIndex &parent = QModelIndex()) const; + QVariant headerData(int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const; + guint recreateVisibleRows(); + int visibleIndexOf(frame_data *fdata) const; + + +signals: + +public slots: + +private: + capture_file *cf; + QList<QString> colNames; + QVector<PacketListRecord *> visibleRows; + QVector<PacketListRecord *> physicalRows; + QFont plFont; + int headerHeight; +}; + +#endif // PACKET_LIST_MODEL_H diff --git a/ui/qt/packet_list_record.cpp b/ui/qt/packet_list_record.cpp new file mode 100644 index 0000000000..776a608a08 --- /dev/null +++ b/ui/qt/packet_list_record.cpp @@ -0,0 +1,49 @@ +/* packet_list_record.cpp + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "packet_list_record.h" + +PacketListRecord::PacketListRecord(frame_data *frameData) +{ + fdata = frameData; +} + +QVariant PacketListRecord::data(int col_num, column_info *cinfo) const +{ + g_assert(fdata); + + if (!cinfo) + return QVariant(); + + if (col_based_on_frame_data(cinfo, col_num)) //{ + col_fill_in_frame_data(fdata, cinfo, col_num, FALSE); + return cinfo->col_data[col_num]; +// } else { +// QString unknown; +// return unknown.sprintf("Unknown: frame %d col %d", fdata->num, col_num); +// } +} + +frame_data *PacketListRecord::getFdata() { + return fdata; +} diff --git a/ui/qt/packet_list_record.h b/ui/qt/packet_list_record.h new file mode 100644 index 0000000000..b5a86d2edb --- /dev/null +++ b/ui/qt/packet_list_record.h @@ -0,0 +1,65 @@ +/* packet_list_record.h + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef PACKET_LIST_RECORD_H +#define PACKET_LIST_RECORD_H + +#include "config.h" + +#include <glib.h> + +#include <epan/column_info.h> +#include <epan/packet.h> + +#include <QList> +#include <QVariant> + +class PacketListRecord +{ +public: + PacketListRecord(frame_data *frameData); + QVariant data(int col_num, column_info *cinfo) const; + frame_data *getFdata(); + +private: + /** The column text for some columns */ + gchar **col_text; + /**< The length of the column text strings in 'col_text' */ + guint *col_text_len; + + frame_data *fdata; + + /** Has this record been columnized? */ + gboolean columnized; + /** Has this record been colorized? */ + gboolean colorized; + + /* admin stuff used by the custom list model */ + /** position within the physical array */ + guint physical_pos; + /** position within the visible array */ + gint visible_pos; + +}; + +#endif // PACKET_LIST_RECORD_H diff --git a/ui/qt/progress_dialog.cpp b/ui/qt/progress_dialog.cpp new file mode 100644 index 0000000000..4ad1a50d7f --- /dev/null +++ b/ui/qt/progress_dialog.cpp @@ -0,0 +1,194 @@ +/* progress_dialog.cpp + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <glib.h> + +#include "progress_dialog.h" + +#include "progress_dlg.h" + +progdlg_t * +delayed_create_progress_dlg(const gchar *task_title, const gchar *item_title, + gboolean terminate_is_stop, gboolean *stop_flag, + const GTimeVal *start_time, gfloat progress) +{ + GTimeVal time_now; + gdouble delta_time; + gdouble min_display; + progdlg_t *dlg = NULL; + +#define INIT_DELAY 0.1 * 1e6 +#define MIN_DISPLAY_DEFAULT 2.0 * 1e6 + + /* Create a progress dialog, but only if it's not likely to disappear + * immediately, which can be disconcerting for the user. + * + * Arguments are as for create_progress_dlg(), plus: + * + * (a) A pointer to a GTimeVal structure which holds the time at which + * the caller started to process the data. + * (b) The current progress as a real number between 0 and 1. + */ + + g_get_current_time(&time_now); + + /* Get the time elapsed since the caller started processing the data */ + + delta_time = (time_now.tv_sec - start_time->tv_sec) * 1e6 + + time_now.tv_usec - start_time->tv_usec; + + /* Do nothing for the first INIT_DELAY microseconds */ + + if (delta_time < INIT_DELAY) + return NULL; + + /* If we create the progress dialog we want it to be displayed for a + * minimum of MIN_DISPLAY_DEFAULT microseconds. However, if we + * previously estimated that the progress dialog didn't need to be + * created and the caller's processing is slowing down (perhaps due + * to the action of the operating system's scheduler on a compute- + * intensive task), we tail off the minimum display time such that + * the progress dialog will always be created after + * 2*MIN_DISPLAY_DEFAULT microseconds. + */ + + if (delta_time <= INIT_DELAY + MIN_DISPLAY_DEFAULT) + min_display = MIN_DISPLAY_DEFAULT; + else + min_display = 2 * MIN_DISPLAY_DEFAULT - delta_time; + /* = MIN_DISPLAY_DEFAULT - (delta_time - MIN_DISPLAY_DEFAULT) */ + + /* Assuming the progress increases linearly, see if the progress + * dialog would be displayed for at least min_display microseconds if + * we created it now. + */ + + if (progress >= (delta_time / (delta_time + min_display))) + return NULL; + + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: delayed_create_progress_dlg tt: %s it: %s", task_title, item_title); +// dlg = create_progress_dlg(task_title, item_title, terminate_is_stop, +// stop_flag); + + /* + * Flush out the dialog so we don't see an "empty" one until first update. + */ + //WiresharkApplication::processEvents(); + + /* set dialog start_time to the start of processing, not box creation */ +// dlg->start_time = *start_time; + + return dlg; +} + +/* + * Update the progress information of the progress dialog box. + */ +void +update_progress_dlg(progdlg_t *dlg, gfloat percentage, const gchar *status) +{ +// GtkWidget *dlg_w = dlg->dlg_w; +// GtkWidget *prog_bar; + GTimeVal time_now; + gdouble delta_time; + gulong ul_left; + gulong ul_elapsed; + gulong ul_percentage; + gchar tmp[100]; + + + /* calculate some timing values */ + g_get_current_time(&time_now); + +// delta_time = (time_now.tv_sec - dlg->last_time.tv_sec) * 1e6 + +// time_now.tv_usec - dlg->last_time.tv_usec; + + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: update_progress_dlg: %0.2f %s", percentage, status); + +// /* after the first time don't update more than every 100ms */ +// if (dlg->last_time.tv_sec && delta_time < 100*1000) +// return; + +// dlg->last_time = time_now; +// delta_time = (time_now.tv_sec - dlg->start_time.tv_sec) * 1e6 + +// time_now.tv_usec - dlg->start_time.tv_usec; + +// ul_percentage = (gulong) (percentage * 100); +// ul_elapsed = (gulong) (delta_time / 1000 / 1000); + +// /* update labels */ +// g_snprintf(tmp, sizeof(tmp), "%lu%% of %s", ul_percentage, dlg->title); +// gtk_window_set_title(GTK_WINDOW(dlg_w), tmp); + +// gtk_label_set_text(dlg->status_lb, status); + +// g_snprintf(tmp, sizeof(tmp), "%lu%%", ul_percentage); +// gtk_label_set_text(dlg->percentage_lb, tmp); + +// g_snprintf(tmp, sizeof(tmp), "%02lu:%02lu", ul_elapsed / 60, +// ul_elapsed % 60); +// gtk_label_set_text(dlg->elapsed_lb, tmp); + +// /* show "Time Left" only, +// * if at least 5% and 3 seconds running (to get a useful estimation) */ +// if (ul_percentage >= 5 && delta_time >= 3 * 1e6) { +// ul_left = (gulong) ((delta_time / percentage - delta_time) / 1000 / 1000); + +// g_snprintf(tmp, sizeof(tmp), "%02lu:%02lu", ul_left / 60, +// ul_left % 60); +// gtk_label_set_text(dlg->time_left_lb, tmp); +// } + +// /* update progress bar */ +// prog_bar = g_object_get_data(G_OBJECT(dlg_w), PROG_BAR_KEY); +// gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(prog_bar), percentage); + + /* + * Flush out the update and process any input events. + */ +// WiresharkApplication::processEvents(); + } + +/* + * Destroy the progress dialog. + */ +void +destroy_progress_dlg(progdlg_t *dlg) +{ +// GtkWidget *dlg_w = dlg->dlg_w; + + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: destroy_progress_dlg"); +// window_destroy(GTK_WIDGET(dlg_w)); +// g_free(dlg->title); +// g_free(dlg); +} + + +ProgressDialog::ProgressDialog(QWidget *parent) : + QProgressDialog(parent) +{ +} diff --git a/ui/qt/progress_dialog.h b/ui/qt/progress_dialog.h new file mode 100644 index 0000000000..4bb0e13a51 --- /dev/null +++ b/ui/qt/progress_dialog.h @@ -0,0 +1,41 @@ +/* progress_dialog.h + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef PROGRESS_DIALOG_H +#define PROGRESS_DIALOG_H + +#include <QProgressDialog> + +class ProgressDialog : public QProgressDialog +{ + Q_OBJECT +public: + explicit ProgressDialog(QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // PROGRESS_DIALOG_H diff --git a/ui/qt/progress_overlay.png b/ui/qt/progress_overlay.png Binary files differnew file mode 100644 index 0000000000..69fe5baa60 --- /dev/null +++ b/ui/qt/progress_overlay.png diff --git a/ui/qt/progress_overlay.svg b/ui/qt/progress_overlay.svg new file mode 100644 index 0000000000..351a6322e8 --- /dev/null +++ b/ui/qt/progress_overlay.svg @@ -0,0 +1,87 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="50" + height="50" + id="svg2" + version="1.1" + inkscape:version="0.48.0 r9654" + sodipodi:docname="progress_overlay.svg" + inkscape:export-filename="/Users/gcombs/Development/qtshark/qt/progress_overlay.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <defs + id="defs4"> + <inkscape:perspective + sodipodi:type="inkscape:persp3d" + inkscape:vp_x="0 : 526.18109 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_z="744.09448 : 526.18109 : 1" + inkscape:persp3d-origin="372.04724 : 350.78739 : 1" + id="perspective10" /> + <filter + inkscape:collect="always" + id="filter3772" + x="-0.41738792" + width="1.8347758" + y="-0.42263143" + height="1.8452629"> + <feGaussianBlur + inkscape:collect="always" + stdDeviation="3.5354496" + id="feGaussianBlur3774" /> + </filter> + </defs> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="3.9999998" + inkscape:cx="21.724894" + inkscape:cy="23.391956" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:window-width="1179" + inkscape:window-height="725" + inkscape:window-x="0" + inkscape:window-y="798" + inkscape:window-maximized="0" /> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-1002.3622)"> + <rect + style="opacity:0.5;fill:#d3d7cf;fill-opacity:0.49777778;stroke:#2e3436;stroke-width:3.71728396;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;filter:url(#filter3772)" + id="rect2983" + width="20.329" + height="20.076782" + x="0.25253814" + y="0.30202535" + transform="matrix(2.6810257,0,0,2.6992783,-2.9283474,999.45062)" /> + </g> +</svg> diff --git a/ui/qt/proto_tree.cpp b/ui/qt/proto_tree.cpp new file mode 100644 index 0000000000..74cedbeaac --- /dev/null +++ b/ui/qt/proto_tree.cpp @@ -0,0 +1,155 @@ +/* proto_tree.cpp + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "proto_tree.h" +#include "monospace_font.h" + +#include <epan/prefs.h> + +#include <QApplication> +#include <QHeaderView> + +QColor expert_color_chat ( 0x80, 0xb7, 0xf7 ); /* light blue */ +QColor expert_color_note ( 0xa0, 0xff, 0xff ); /* bright turquoise */ +QColor expert_color_warn ( 0xf7, 0xf2, 0x53 ); /* yellow */ +QColor expert_color_error ( 0xff, 0x5c, 0x5c ); /* pale red */ +QColor expert_color_foreground ( 0x00, 0x00, 0x00 ); /* black */ +QColor hidden_proto_item ( 0x44, 0x44, 0x44 ); /* gray */ + +static void +proto_tree_draw_node(proto_node *node, gpointer data); + +void proto_tree_draw(proto_tree *protocol_tree, QTreeWidget *protoTree) { + // Clear out previous tree + protoTree->clear(); + protoTree->setFont(get_monospace_font()); + + proto_tree_children_foreach(protocol_tree, proto_tree_draw_node, protoTree->invisibleRootItem()); +} + +/* Fill a single protocol tree item with its string value and set its color. */ +static void +proto_tree_draw_node(proto_node *node, gpointer data) +{ + field_info *fi = PNODE_FINFO(node); + gchar label_str[ITEM_LABEL_LENGTH]; + gchar *label_ptr; + gboolean is_leaf, is_expanded; + + g_assert(fi && "dissection with an invisible proto tree?"); + + if (PROTO_ITEM_IS_HIDDEN(node) && !prefs.display_hidden_proto_items) + return; + + // Fill in our label + /* was a free format label produced? */ + if (fi->rep) { + label_ptr = fi->rep->representation; + } + else { /* no, make a generic label */ + label_ptr = label_str; + proto_item_fill_label(fi, label_str); + } + + if (node->first_child != NULL) { + is_leaf = FALSE; + g_assert(fi->tree_type >= 0 && fi->tree_type < num_tree_types); + if (tree_is_expanded[fi->tree_type]) { + is_expanded = TRUE; + } + else { + is_expanded = FALSE; + } + } + else { + is_leaf = TRUE; + is_expanded = FALSE; + } + + if (PROTO_ITEM_IS_GENERATED(node)) { + if (PROTO_ITEM_IS_HIDDEN(node)) { + label_ptr = g_strdup_printf("<[%s]>", label_ptr); + } else { + label_ptr = g_strdup_printf("[%s]", label_ptr); + } + } else if (PROTO_ITEM_IS_HIDDEN(node)) { + label_ptr = g_strdup_printf("<%s>", label_ptr); + } + + QTreeWidgetItem *parentItem = (QTreeWidgetItem *)data; + QTreeWidgetItem *item; + item = new QTreeWidgetItem(parentItem, 0); + + // Set our colors. + QPalette pal = QApplication::palette(); + if (fi && fi->hfinfo) { + if(fi->hfinfo->type == FT_PROTOCOL) { + item->setData(0, Qt::BackgroundRole, pal.alternateBase()); + } + + if((fi->hfinfo->type == FT_FRAMENUM) || + (FI_GET_FLAG(fi, FI_URL) && IS_FT_STRING(fi->hfinfo->type))) { + item->setData(0, Qt::ForegroundRole, pal.link()); + // XXX - Draw an underline? + } + } + + // XXX - Add routines to get our severity colors. + if(FI_GET_FLAG(fi, PI_SEVERITY_MASK)) { + switch(FI_GET_FLAG(fi, PI_SEVERITY_MASK)) { + case(PI_CHAT): + item->setData(0, Qt::BackgroundRole, expert_color_chat); + break; + case(PI_NOTE): + item->setData(0, Qt::BackgroundRole, expert_color_note); + break; + case(PI_WARN): + item->setData(0, Qt::BackgroundRole, expert_color_warn); + break; + case(PI_ERROR): + item->setData(0, Qt::BackgroundRole, expert_color_error); + break; + default: + g_assert_not_reached(); + } + item->setData(0, Qt::ForegroundRole, expert_color_foreground); + } + +// g_log(NULL, G_LOG_LEVEL_DEBUG, "new item %s", label_ptr); + item->setText(0, label_ptr); + item->setData(0, Qt::UserRole, qVariantFromValue((void *) fi)); + + if (PROTO_ITEM_IS_GENERATED(node) || PROTO_ITEM_IS_HIDDEN(node)) { + g_free(label_ptr); + } + + if (!is_leaf) { + proto_tree_children_foreach(node, proto_tree_draw_node, item); + } +} + +ProtoTree::ProtoTree(QWidget *parent) : + QTreeWidget(parent) +{ + setAccessibleName("Packet details"); +} diff --git a/ui/qt/proto_tree.h b/ui/qt/proto_tree.h new file mode 100644 index 0000000000..7afd278df9 --- /dev/null +++ b/ui/qt/proto_tree.h @@ -0,0 +1,47 @@ +/* proto_tree.h + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef PROTO_TREE_H +#define PROTO_TREE_H + +#include "config.h" + +#include <epan/proto.h> + +#include <QTreeWidget> + +void proto_tree_draw(proto_tree *protocol_tree, QTreeWidget *protoTree); + +class ProtoTree : public QTreeWidget +{ + Q_OBJECT +public: + explicit ProtoTree(QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // PROTO_TREE_H diff --git a/ui/qt/qrc_toolbar.cpp b/ui/qt/qrc_toolbar.cpp new file mode 100644 index 0000000000..d99f386dc0 --- /dev/null +++ b/ui/qt/qrc_toolbar.cpp @@ -0,0 +1,317 @@ +/**************************************************************************** +** Resource object code +** +** Created: Fri Dec 30 15:46:15 2011 +** by: The Resource Compiler for Qt version 4.6.2 +** +** WARNING! All changes made in this file will be lost! +*****************************************************************************/ + +#include <QtCore/qglobal.h> + +static const unsigned char qt_resource_data[] = { + // /home/gerald/devel/qtshark/qt/capture_start_24.png + 0x0,0x0,0x4,0xcc, + 0x89, + 0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0, + 0x0,0x0,0x18,0x0,0x0,0x0,0x18,0x8,0x6,0x0,0x0,0x0,0xe0,0x77,0x3d,0xf8, + 0x0,0x0,0x0,0x4,0x73,0x42,0x49,0x54,0x8,0x8,0x8,0x8,0x7c,0x8,0x64,0x88, + 0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xd,0xd7,0x0,0x0,0xd,0xd7, + 0x1,0x42,0x28,0x9b,0x78,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x53,0x6f,0x66, + 0x74,0x77,0x61,0x72,0x65,0x0,0x77,0x77,0x77,0x2e,0x69,0x6e,0x6b,0x73,0x63,0x61, + 0x70,0x65,0x2e,0x6f,0x72,0x67,0x9b,0xee,0x3c,0x1a,0x0,0x0,0x4,0x49,0x49,0x44, + 0x41,0x54,0x48,0x89,0x8d,0x96,0xcf,0x4b,0x9b,0x49,0x18,0xc7,0xbf,0x33,0xef,0xfb, + 0x8e,0xef,0xe6,0x4d,0xc,0xd1,0xb6,0x69,0x34,0xf1,0x7,0xc1,0x2d,0x22,0x98,0x84, + 0x4d,0xdc,0x42,0x41,0xa1,0x97,0x22,0x78,0x28,0x2c,0xb,0x3d,0x16,0xa,0x11,0xad, + 0xa7,0xed,0x79,0x9,0x1,0xa1,0xa7,0x7a,0x12,0xf,0xf9,0x1f,0x3c,0x15,0xc5,0x8b, + 0x48,0xa1,0xb4,0x34,0x8,0xa1,0x7,0x29,0x29,0x52,0x8a,0x2b,0x35,0xa9,0x6e,0x6b, + 0xdf,0x9a,0x18,0xe7,0x9d,0xf7,0x9d,0x3d,0x6c,0xdf,0x97,0xc4,0x24,0xbb,0x3e,0x30, + 0xcc,0x65,0xe6,0xfb,0x79,0xe6,0x99,0xe7,0x79,0x66,0x88,0x94,0x12,0xdd,0x6c,0x69, + 0x69,0xa9,0x9f,0x73,0x9e,0x56,0x14,0x65,0x8a,0x31,0x36,0x63,0xdb,0x76,0xa,0x0, + 0x14,0x45,0x29,0x35,0x1a,0x8d,0x17,0x52,0xca,0x22,0x63,0x6c,0x77,0x75,0x75,0xf5, + 0xef,0x6e,0x1a,0xa4,0x13,0x20,0x9f,0xcf,0xab,0xc7,0xc7,0xc7,0x39,0x0,0x4f,0xc2, + 0xe1,0x30,0x1f,0x1c,0x1c,0x34,0x6e,0xde,0xbc,0xa9,0xde,0xb8,0x71,0x3,0xb6,0x6d, + 0xe3,0xe8,0xe8,0x8,0x47,0x47,0x47,0xe2,0xd3,0xa7,0x4f,0xb5,0x2f,0x5f,0xbe,0x30, + 0x29,0xe5,0xb3,0x70,0x38,0x9c,0xcf,0xe5,0x72,0xe2,0x7f,0x1,0xd9,0x6c,0x76,0x42, + 0xd7,0xf5,0xf5,0x81,0x81,0x81,0xe8,0xfd,0xfb,0xf7,0x8d,0x40,0x20,0x0,0x29,0x25, + 0x1c,0xc7,0x81,0x6d,0xdb,0xb0,0x6d,0x1b,0x42,0x8,0x58,0x96,0x5,0x21,0x4,0xbe, + 0x7d,0xfb,0x86,0x9d,0x9d,0x9d,0xda,0xc9,0xc9,0xc9,0xa1,0x65,0x59,0xbf,0x15,0xa, + 0x85,0xbd,0xae,0x80,0xc5,0xc5,0xc5,0xac,0xaa,0xaa,0x2b,0xb3,0xb3,0xb3,0xbe,0x54, + 0x2a,0x45,0x28,0xa5,0x20,0x84,0x40,0x4a,0xd9,0x51,0xdc,0xb2,0x2c,0x58,0x96,0x5, + 0xce,0x39,0xca,0xe5,0xb2,0xdc,0xdd,0xdd,0xad,0x3b,0x8e,0xf3,0xc7,0xda,0xda,0x5a, + 0xa1,0xd,0xf0,0xc3,0xf3,0x37,0xb,0xb,0xb,0x46,0x7f,0x7f,0x3f,0x14,0x45,0x81, + 0xa2,0x28,0x0,0xe0,0x1,0x9a,0x45,0x9b,0x7,0xe7,0x1c,0x96,0x65,0xe1,0xf4,0xf4, + 0x14,0x5b,0x5b,0x5b,0x35,0xce,0xf9,0xaf,0xee,0x49,0xa8,0x1b,0x73,0x5d,0xd7,0xd7, + 0xef,0xdd,0xbb,0xe7,0xb,0x85,0x42,0x50,0x14,0x5,0x9a,0xa6,0x41,0xd3,0x34,0x30, + 0xc6,0xa0,0x69,0x1a,0x54,0x55,0xf5,0xa0,0x8a,0xa2,0x80,0x52,0xa,0xf7,0x84,0xee, + 0x6c,0x18,0x6,0x92,0xc9,0xa4,0x4f,0xd3,0xb4,0xf5,0x7c,0x3e,0xaf,0x2,0x80,0xa, + 0x0,0xd5,0x6a,0x35,0x17,0x8b,0xc5,0xa2,0xc9,0x64,0x92,0x50,0x4a,0x3d,0x11,0x4d, + 0xd3,0x40,0x8,0xc1,0xf3,0xe7,0xcf,0xf1,0xea,0xd5,0x2b,0xbc,0x7f,0xff,0x1e,0x8e, + 0xe3,0x60,0x64,0x64,0x4,0x89,0x44,0x2,0x77,0xee,0xdc,0x1,0x21,0xe4,0xdf,0x50, + 0x10,0x2,0x42,0x8,0x86,0x86,0x86,0xc8,0xc7,0x8f,0x1f,0xa3,0xd5,0x6a,0x35,0x7, + 0xe0,0x4f,0xf2,0xf8,0xf1,0xe3,0x7e,0x0,0x7f,0xcd,0xcf,0xcf,0xff,0xd4,0xd7,0xd7, + 0xe7,0x79,0xcc,0x18,0xc3,0xf7,0xef,0xdf,0xf1,0xf4,0xe9,0x53,0x94,0x4a,0x25,0xef, + 0xa2,0x9b,0xe7,0x5b,0xb7,0x6e,0xe1,0xd1,0xa3,0x47,0xf0,0xf9,0x7c,0xe0,0x9c,0x7b, + 0xa1,0x32,0x4d,0x13,0xdb,0xdb,0xdb,0xe7,0x94,0xd2,0x18,0xe5,0x9c,0xa7,0xaf,0x5f, + 0xbf,0xce,0xfd,0x7e,0x3f,0xa4,0x94,0xde,0xb0,0x6d,0x1b,0xcb,0xcb,0xcb,0x9e,0x78, + 0xa7,0x74,0x7e,0xf7,0xee,0x1d,0xa,0x85,0x82,0x7,0x74,0xef,0x4b,0xd7,0x75,0x4, + 0x2,0x1,0xce,0x39,0x4f,0x53,0x42,0xc8,0x54,0x24,0x12,0x31,0x1c,0xc7,0x69,0x49, + 0xc5,0xcd,0xcd,0x4d,0xbc,0x7d,0xfb,0xb6,0x5,0xda,0xc,0x72,0xe7,0x72,0xb9,0x8c, + 0x97,0x2f,0x5f,0xb6,0xad,0x9,0x85,0x42,0x6,0x21,0x64,0x8a,0xea,0xba,0x3e,0x13, + 0xe,0x87,0xd5,0xcb,0x79,0xfe,0xfa,0xf5,0x6b,0xb8,0xd0,0x6e,0x10,0x17,0xd4,0xc9, + 0x91,0xde,0xde,0x5e,0x55,0xd3,0xb4,0x19,0xd5,0xb6,0xed,0xd4,0xb5,0x6b,0xd7,0x20, + 0x84,0xf0,0x2e,0x4a,0x4a,0x89,0xfd,0xfd,0xfd,0x36,0xa1,0x6e,0xa0,0x83,0x83,0x3, + 0xcf,0x19,0x77,0x4,0x2,0x1,0xd8,0xb6,0x9d,0x52,0x1,0x78,0x9e,0xbb,0xe2,0xcd, + 0xb,0x9b,0xad,0x1b,0xe4,0xf2,0x9e,0xe6,0xbd,0x94,0x52,0x5a,0xaa,0x56,0xab,0x6d, + 0x15,0x3a,0x34,0x34,0xd4,0x26,0xd0,0x4d,0x3c,0x1a,0x8d,0x7a,0x4e,0xba,0xe2,0xa6, + 0x69,0x82,0x52,0x5a,0xa2,0x17,0x17,0x17,0x2f,0x2a,0x95,0x8a,0xb8,0x5c,0xfe,0x89, + 0x44,0xe2,0x4a,0xe2,0x52,0x4a,0x8c,0x8f,0x8f,0x7b,0x0,0x77,0x9c,0x9e,0x9e,0xa, + 0x21,0xc4,0xb,0x2a,0xa5,0x2c,0x56,0xab,0xd5,0xda,0xe5,0x36,0x70,0xfb,0xf6,0x6d, + 0x8c,0x8d,0x8d,0xb5,0x88,0x77,0x2,0xc5,0xe3,0x71,0xa4,0xd3,0x69,0x8,0x21,0x5a, + 0x0,0xa6,0x69,0xd6,0xa4,0x94,0x45,0xca,0x18,0xdb,0xfd,0xfa,0xf5,0x2b,0x33,0x4d, + 0xd3,0xeb,0x2b,0x9c,0x73,0x8,0x21,0xf0,0xf0,0xe1,0x43,0x8c,0x8d,0x8d,0x75,0x2c, + 0x32,0x57,0xfc,0xc1,0x83,0x7,0x2d,0xd9,0x67,0xdb,0x36,0xce,0xcf,0xcf,0x51,0xab, + 0xd5,0x18,0x63,0x6c,0x57,0x29,0x16,0x8b,0xe7,0x1b,0x1b,0x1b,0xfa,0xc9,0xc9,0xc9, + 0x2f,0xc3,0xc3,0xc3,0xac,0xd9,0x5b,0xc6,0x18,0x32,0x99,0xc,0x82,0xc1,0x20,0xa4, + 0x94,0x68,0x34,0x1a,0x60,0x8c,0x21,0x1e,0x8f,0x63,0x7a,0x7a,0x1a,0x73,0x73,0x73, + 0x50,0x14,0xa5,0x45,0x5c,0x8,0x81,0xbd,0xbd,0xbd,0x5a,0xa3,0xd1,0x58,0x59,0x5b, + 0x5b,0xdb,0x50,0x1,0x20,0x1c,0xe,0xe7,0x3f,0x7f,0xfe,0xfc,0xfb,0xfe,0xfe,0xfe, + 0xcf,0xa3,0xa3,0xa3,0xc4,0x4d,0x57,0xb7,0xcf,0x64,0x32,0x19,0xa4,0xd3,0xe9,0x96, + 0x6c,0xb9,0x2c,0xea,0xce,0x95,0x4a,0x45,0x9e,0x9d,0x9d,0x1d,0x46,0x22,0x91,0x7c, + 0x5b,0xbb,0x66,0x8c,0xbd,0xb9,0x7b,0xf7,0xae,0x61,0x18,0x46,0x4b,0x13,0xeb,0x96, + 0x8e,0xcd,0x31,0x17,0x42,0xa0,0x5e,0xaf,0xa3,0x54,0x2a,0xd5,0x84,0x10,0x5e,0xbb, + 0x6e,0x7b,0x70,0x28,0xa5,0x2b,0x13,0x13,0x13,0xbe,0x58,0x2c,0x46,0x5c,0x48,0x73, + 0xd,0x74,0x3,0x54,0x2a,0x15,0xf9,0xe1,0xc3,0x87,0x3a,0x80,0xce,0xf,0x8e,0x6b, + 0xd9,0x6c,0x76,0x42,0xd3,0xb4,0xf5,0x60,0x30,0x18,0x9d,0x9c,0x9c,0x34,0x7a,0x7a, + 0x7a,0xda,0x8a,0xac,0x19,0xd0,0x68,0x34,0x50,0x2e,0x97,0x6b,0x67,0x67,0x67,0x87, + 0x42,0x88,0xff,0x7e,0x32,0x5d,0xcb,0xe7,0xf3,0xea,0x8f,0x7e,0xfe,0xc4,0xef,0xf7, + 0xf3,0x60,0x30,0x68,0xf4,0xf6,0xf6,0xaa,0x81,0x40,0xc0,0x2b,0x22,0xd3,0x34,0x85, + 0x69,0x9a,0xb5,0x7a,0xbd,0xce,0x1c,0xc7,0x79,0x16,0x89,0x44,0xae,0xf6,0xe8,0x37, + 0x9b,0xfb,0x6d,0x21,0x84,0x4c,0xa9,0xaa,0x3a,0xe3,0x38,0x4e,0xea,0x47,0xf9,0x97, + 0x84,0x10,0x57,0xfa,0xb6,0xfc,0x3,0xc2,0x4c,0x17,0xcf,0x53,0xc8,0xbf,0x7f,0x0, + 0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82, + // /home/gerald/devel/qtshark/qt/capture_start_active_24.png + 0x0,0x0,0x4,0xc6, + 0x89, + 0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0, + 0x0,0x0,0x18,0x0,0x0,0x0,0x18,0x8,0x6,0x0,0x0,0x0,0xe0,0x77,0x3d,0xf8, + 0x0,0x0,0x0,0x4,0x73,0x42,0x49,0x54,0x8,0x8,0x8,0x8,0x7c,0x8,0x64,0x88, + 0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xd,0xd7,0x0,0x0,0xd,0xd7, + 0x1,0x42,0x28,0x9b,0x78,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x53,0x6f,0x66, + 0x74,0x77,0x61,0x72,0x65,0x0,0x77,0x77,0x77,0x2e,0x69,0x6e,0x6b,0x73,0x63,0x61, + 0x70,0x65,0x2e,0x6f,0x72,0x67,0x9b,0xee,0x3c,0x1a,0x0,0x0,0x4,0x43,0x49,0x44, + 0x41,0x54,0x48,0x89,0x8d,0x96,0xcf,0x4f,0x1b,0x47,0x14,0xc7,0xbf,0x33,0xbb,0x3b, + 0x2c,0xac,0x7f,0xd4,0xd8,0x60,0x1c,0x30,0x88,0x43,0x7a,0x28,0x15,0xc5,0x85,0xd2, + 0xde,0x50,0x73,0x28,0xe1,0x50,0x9,0xa9,0xca,0xb5,0xbd,0x19,0x41,0x72,0x6a,0xa4, + 0x1e,0x2a,0x55,0xd4,0x52,0xaf,0xc9,0x29,0xe2,0x80,0x2a,0xf5,0x2f,0x40,0x6d,0x55, + 0x51,0x71,0x89,0x22,0xd2,0x53,0x8,0xad,0x1b,0x55,0xa8,0xb2,0x44,0xa3,0x24,0xa0, + 0xd8,0x6b,0x9c,0x60,0x36,0xb6,0x31,0xb3,0x33,0x3b,0x3d,0x34,0xbb,0xb5,0xf9,0x11, + 0x78,0xd2,0x68,0x6f,0x9f,0xcf,0xdb,0xb7,0xef,0xbd,0x59,0xa2,0x94,0xc2,0x59,0x71, + 0xe3,0xc6,0x8d,0x38,0xe7,0x7c,0x42,0xd3,0xb4,0x49,0xc6,0xd8,0x94,0x94,0x32,0x3, + 0x0,0x9a,0xa6,0xe5,0x9b,0xcd,0xe6,0xba,0x52,0x6a,0x83,0x31,0xb6,0x79,0xe7,0xce, + 0x9d,0x17,0x67,0x31,0xc8,0x69,0x82,0x5c,0x2e,0xa7,0xef,0xed,0xed,0x2d,0x2,0xb8, + 0x99,0x4c,0x26,0x79,0x7f,0x7f,0xbf,0xd5,0xd7,0xd7,0xa7,0xf7,0xf6,0xf6,0x42,0x4a, + 0x89,0x62,0xb1,0x88,0x62,0xb1,0x28,0x9e,0x3f,0x7f,0x5e,0x7f,0xf9,0xf2,0x25,0x53, + 0x4a,0xdd,0x4a,0x26,0x93,0xb9,0xc5,0xc5,0x45,0x71,0xae,0x20,0x9b,0xcd,0x8e,0x98, + 0xa6,0xb9,0x72,0xe9,0xd2,0xa5,0x81,0xd9,0xd9,0x59,0x2b,0x1c,0xe,0x43,0x29,0x5, + 0xcf,0xf3,0x20,0xa5,0x84,0x94,0x12,0x42,0x8,0xb8,0xae,0xb,0x21,0x4,0xe,0xe, + 0xe,0x70,0xef,0xde,0xbd,0x7a,0xa5,0x52,0xd9,0x75,0x5d,0xf7,0xb3,0xe5,0xe5,0xe5, + 0xad,0x33,0x5,0xb,0xb,0xb,0x59,0x5d,0xd7,0x6f,0xcf,0xcc,0xcc,0x74,0x65,0x32, + 0x19,0x42,0x29,0x5,0x21,0x4,0x4a,0xa9,0x53,0xe1,0xae,0xeb,0xc2,0x75,0x5d,0x70, + 0xce,0x51,0x28,0x14,0xd4,0xe6,0xe6,0x66,0xc3,0xf3,0xbc,0x2f,0x97,0x96,0x96,0x96, + 0x4f,0x8,0x5e,0x67,0xfe,0x60,0x7e,0x7e,0xde,0x8a,0xc7,0xe3,0xd0,0x34,0xd,0x9a, + 0xa6,0x1,0x40,0x20,0x68,0x85,0xb6,0x1e,0xce,0x39,0x5c,0xd7,0x45,0xb5,0x5a,0xc5, + 0xda,0xda,0x5a,0x9d,0x73,0xfe,0xa1,0xff,0x26,0xd4,0xaf,0xb9,0x69,0x9a,0x2b,0xd3, + 0xd3,0xd3,0x5d,0xb1,0x58,0xc,0x9a,0xa6,0xc1,0x30,0xc,0x18,0x86,0x1,0xc6,0x18, + 0xc,0xc3,0x80,0xae,0xeb,0x81,0x54,0xd3,0x34,0x50,0x4a,0xe1,0xbf,0xa1,0xff,0xb4, + 0x2c,0xb,0x63,0x63,0x63,0x5d,0x86,0x61,0xac,0xe4,0x72,0x39,0x1d,0x0,0x74,0x0, + 0xb0,0x6d,0x7b,0x31,0x9d,0x4e,0xf,0x8c,0x8d,0x8d,0x11,0x4a,0x69,0x0,0x31,0xc, + 0x3,0x84,0x12,0xfc,0xa1,0xbe,0x47,0xa1,0xe3,0x17,0xd8,0xf4,0x4f,0x28,0xa5,0x10, + 0xe7,0xef,0xa2,0xbf,0xf6,0x31,0x6,0x5f,0xcc,0x82,0x10,0xf2,0x5f,0x29,0x8,0x1, + 0x21,0x4,0x83,0x83,0x83,0xe4,0xc9,0x93,0x27,0x3,0xb6,0x6d,0x2f,0x2,0xf8,0x86, + 0x5c,0xbf,0x7e,0x3d,0xe,0x60,0x67,0x6e,0x6e,0xae,0xb3,0xbb,0xbb,0x3b,0xc8,0x98, + 0x31,0x86,0x23,0x56,0xc1,0x4f,0xf4,0xb,0x3c,0x25,0xf7,0x4f,0x6d,0xc1,0xde,0xc6, + 0x7,0x18,0x7f,0xfa,0x1d,0xb4,0xc6,0x5b,0xe0,0x9c,0x7,0xa5,0x72,0x1c,0x7,0x77, + 0xef,0xde,0x3d,0xa4,0x94,0xa6,0x29,0xe7,0x7c,0xa2,0xa7,0xa7,0x87,0x87,0x42,0x21, + 0x28,0xa5,0x82,0x23,0x3d,0x89,0x1f,0xc9,0xe7,0x67,0xc2,0x1,0xa0,0xdc,0xf5,0x10, + 0xf,0xd3,0x5f,0xc3,0x53,0x1e,0xfc,0x6f,0xa9,0x94,0x82,0x69,0x9a,0x8,0x87,0xc3, + 0x9c,0x73,0x3e,0x41,0x9,0x21,0x93,0xa9,0x54,0xca,0xf2,0x3c,0xaf,0xad,0x15,0x1f, + 0xd1,0x1f,0xf0,0x8c,0xfe,0x76,0x26,0xdc,0x8f,0x4a,0xe8,0x77,0xec,0x24,0x7e,0x6e, + 0x4b,0x4e,0x29,0x85,0x58,0x2c,0x66,0x11,0x42,0x26,0xa9,0x69,0x9a,0x53,0xc9,0x64, + 0x52,0x3f,0xde,0xe7,0xdb,0xda,0xaf,0xe7,0xc2,0xfd,0x28,0x45,0xef,0x9f,0x10,0x44, + 0x22,0x11,0xdd,0x30,0x8c,0x29,0x5d,0x4a,0x99,0x49,0x24,0x12,0x10,0x42,0x4,0x1f, + 0x4a,0x29,0x85,0xb2,0xf6,0xe8,0xc2,0x2,0xc7,0x2a,0xc0,0xaf,0x80,0x7f,0xc2,0xe1, + 0x30,0xa4,0x94,0x19,0x1d,0x40,0x90,0xb9,0xf,0xf7,0x3c,0xef,0xc2,0x70,0x3f,0x8e, + 0xb,0x7c,0x6,0xa5,0x94,0xe6,0x6d,0xdb,0x3e,0x31,0xa1,0xb1,0xe6,0x3b,0x17,0x86, + 0x87,0x5e,0x5d,0xe,0x92,0xf4,0xe1,0x8e,0xe3,0x80,0x52,0x9a,0xa7,0x47,0x47,0x47, + 0xeb,0xa5,0x52,0x49,0x1c,0x1f,0xff,0x94,0x33,0x75,0x61,0x41,0xf7,0xde,0x47,0x81, + 0xc0,0x3f,0xd5,0x6a,0x55,0x8,0x21,0xd6,0xa9,0x52,0x6a,0xc3,0xb6,0xed,0xfa,0xf1, + 0x35,0xd0,0x5f,0xfe,0x14,0x89,0xda,0xf8,0xb9,0xf0,0xe8,0xfe,0x28,0x12,0x3b,0x9f, + 0x40,0x8,0xd1,0x26,0x70,0x1c,0xa7,0xae,0x94,0xda,0xa0,0x8c,0xb1,0xcd,0xfd,0xfd, + 0x7d,0xe6,0x38,0x4e,0xb0,0x57,0x38,0xe7,0x10,0xae,0xc0,0x7b,0xff,0x7c,0x8b,0xf8, + 0xab,0xf7,0xdf,0x8,0xbf,0xfc,0xd7,0x57,0x90,0xe2,0xff,0xee,0x93,0x52,0xe2,0xf0, + 0xf0,0x10,0xf5,0x7a,0x9d,0x31,0xc6,0x36,0xb5,0x8d,0x8d,0x8d,0xc3,0xd5,0xd5,0x55, + 0xb3,0x52,0xa9,0x8c,0xf,0xd,0xd,0x31,0xbf,0xcd,0x3c,0xcf,0x3,0x15,0x9d,0x48, + 0x95,0xaf,0xc2,0xe4,0x9,0x28,0x28,0x48,0xed,0x10,0x9a,0xe8,0x44,0xb4,0x3a,0x8a, + 0x81,0x67,0xd7,0x30,0xf8,0x77,0x16,0xaa,0xc9,0xda,0xe0,0x42,0x8,0x6c,0x6d,0x6d, + 0xd5,0x9b,0xcd,0xe6,0xed,0xa5,0xa5,0xa5,0x55,0x1d,0x0,0x92,0xc9,0x64,0xae,0x5c, + 0x2e,0x5f,0xdb,0xde,0xde,0x7e,0x7b,0x78,0x78,0x98,0xf8,0xed,0xea,0xef,0x99,0xde, + 0xdd,0xab,0xe8,0xd9,0x99,0xe,0xc4,0xfe,0xcc,0x8,0x29,0x4e,0xc0,0x4b,0xa5,0x92, + 0xaa,0xd5,0x6a,0xbb,0xa9,0x54,0x2a,0x7,0x1c,0x5b,0xd7,0x8c,0xb1,0x7,0x57,0xae, + 0x5c,0xb1,0x2c,0xcb,0x6a,0x5b,0x62,0xad,0x3,0xd4,0xda,0x86,0xad,0x35,0x17,0x42, + 0xa0,0xd1,0x68,0x20,0x9f,0xcf,0xd7,0x85,0x10,0xc1,0xba,0x3e,0x71,0xe1,0x50,0x4a, + 0x6f,0x8f,0x8c,0x8c,0x74,0xa5,0xd3,0x69,0xe2,0x4b,0x0,0x9c,0x2b,0x28,0x95,0x4a, + 0xea,0xf1,0xe3,0xc7,0xd,0x0,0xa7,0x5f,0x38,0x7e,0x64,0xb3,0xd9,0x11,0xc3,0x30, + 0x56,0xa2,0xd1,0xe8,0xc0,0xe8,0xe8,0xa8,0xd5,0xd1,0xd1,0xd1,0x26,0x38,0x5e,0xa6, + 0x66,0xb3,0x89,0x42,0xa1,0x50,0xaf,0xd5,0x6a,0xbb,0x42,0x88,0x37,0x5f,0x99,0x7e, + 0xe4,0x72,0x39,0xfd,0xf5,0x3e,0xbf,0x19,0xa,0x85,0x78,0x34,0x1a,0xb5,0x22,0x91, + 0x88,0x1e,0xe,0x87,0x83,0x21,0x72,0x1c,0x47,0x38,0x8e,0x53,0x6f,0x34,0x1a,0xcc, + 0xf3,0xbc,0x5b,0xa9,0x54,0xea,0x62,0x97,0x7e,0x6b,0xf8,0xbf,0x2d,0x84,0x90,0x49, + 0x5d,0xd7,0xa7,0x3c,0xcf,0xcb,0x0,0x0,0xa5,0x34,0x2f,0x84,0xb8,0xd0,0x6f,0xcb, + 0xbf,0x53,0x8a,0x4b,0x24,0x7f,0xe4,0xe8,0x65,0x0,0x0,0x0,0x0,0x49,0x45,0x4e, + 0x44,0xae,0x42,0x60,0x82, + // /home/gerald/devel/qtshark/qt/capture_stop_24.png + 0x0,0x0,0x3,0xd9, + 0x89, + 0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0, + 0x0,0x0,0x18,0x0,0x0,0x0,0x18,0x8,0x6,0x0,0x0,0x0,0xe0,0x77,0x3d,0xf8, + 0x0,0x0,0x0,0x4,0x73,0x42,0x49,0x54,0x8,0x8,0x8,0x8,0x7c,0x8,0x64,0x88, + 0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xd,0xd7,0x0,0x0,0xd,0xd7, + 0x1,0x42,0x28,0x9b,0x78,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x53,0x6f,0x66, + 0x74,0x77,0x61,0x72,0x65,0x0,0x77,0x77,0x77,0x2e,0x69,0x6e,0x6b,0x73,0x63,0x61, + 0x70,0x65,0x2e,0x6f,0x72,0x67,0x9b,0xee,0x3c,0x1a,0x0,0x0,0x3,0x56,0x49,0x44, + 0x41,0x54,0x48,0x89,0xb5,0x56,0x3d,0x4b,0x2b,0x5b,0x14,0x5d,0x67,0xce,0x1c,0x93, + 0x30,0xc9,0x28,0x31,0x24,0xa6,0x30,0x90,0xce,0x47,0x82,0xd8,0x3c,0x6c,0x52,0xa4, + 0xb6,0xd0,0x46,0x52,0xdb,0xd8,0xf8,0x7,0x2e,0xcf,0x5b,0x88,0xc5,0xbb,0xf,0xff, + 0x41,0x40,0xfc,0x3,0x62,0xf7,0x40,0x2d,0xb5,0x94,0xb,0x82,0x5a,0x58,0x68,0xa3, + 0xc4,0x8f,0xb1,0x18,0x9,0xf3,0x42,0x72,0x66,0xce,0xc7,0x6b,0xee,0xc,0x33,0x99, + 0x1b,0xb9,0x3c,0x9e,0x7,0x36,0xc,0xe7,0x63,0xad,0xb3,0xd7,0xde,0x67,0xef,0x21, + 0x5a,0x6b,0x7c,0xe6,0x30,0x3e,0x15,0x1d,0x80,0xf9,0xd1,0x62,0xa7,0xd3,0xa1,0xc5, + 0x62,0x71,0x85,0x10,0xb2,0xcc,0x18,0x6b,0xb,0x21,0x16,0x1,0x80,0x52,0x7a,0x2d, + 0x84,0x38,0xd3,0x5a,0x5f,0xb8,0xae,0x7b,0x7c,0x78,0x78,0x28,0x27,0x61,0x90,0x49, + 0x12,0x6d,0x6e,0x6e,0xfe,0x96,0xcd,0x66,0x8f,0xf2,0xf9,0x7c,0x6d,0x7e,0x7e,0x3e, + 0x57,0x2e,0x97,0x69,0xa9,0x54,0x82,0xd6,0x1a,0x8e,0xe3,0xe0,0xed,0xed,0x4d,0x3e, + 0x3d,0x3d,0xd,0x7,0x83,0xc1,0x23,0xe7,0x7c,0x7d,0x7f,0x7f,0xff,0xf6,0x97,0x8, + 0x76,0x77,0x77,0xd,0xc7,0x71,0xbe,0x50,0x4a,0xbf,0xb6,0x5a,0xad,0x5c,0xb3,0xd9, + 0x34,0x0,0x40,0x6b,0xd,0xad,0x35,0x94,0x52,0x90,0x52,0x42,0x4a,0x9,0x21,0x4, + 0x6e,0x6f,0x6f,0xd5,0xe5,0xe5,0xe5,0x50,0x29,0xf5,0x67,0xa5,0x52,0xd9,0xdb,0xd9, + 0xd9,0x51,0x1f,0x4a,0xe4,0x38,0xce,0x97,0xd9,0xd9,0xd9,0xed,0xd5,0xd5,0x55,0xcb, + 0xb6,0x6d,0x10,0x42,0x30,0x4e,0x60,0x18,0x46,0x34,0xbf,0xb0,0xb0,0x60,0x54,0xab, + 0x55,0xeb,0xfc,0xfc,0x7c,0xdb,0x71,0x1c,0x0,0xf8,0x6b,0xa2,0x7,0x3f,0x64,0xf9, + 0xbe,0xb1,0xb1,0x61,0x4d,0x4f,0x4f,0x27,0x80,0xe2,0x4,0x42,0x8,0x8,0x21,0x10, + 0x4,0x1,0x82,0x20,0x80,0xef,0xfb,0xe8,0xf7,0xfb,0x38,0x3d,0x3d,0x1d,0x70,0xce, + 0x7f,0x8f,0xcb,0x15,0x65,0x51,0xa7,0xd3,0xa1,0xd9,0x6c,0xf6,0xa8,0xdd,0x6e,0xe7, + 0x66,0x66,0x66,0x60,0x9a,0x26,0x4c,0xd3,0x4,0x63,0xc,0x8c,0x31,0x4c,0x4d,0x4d, + 0x81,0x31,0x16,0xcd,0x85,0xeb,0x94,0x52,0x18,0x86,0x1,0xcb,0xb2,0xd0,0x6c,0x36, + 0x73,0x8c,0xb1,0xa3,0x4e,0xa7,0x43,0x53,0x12,0x15,0x8b,0xc5,0x95,0x42,0xa1,0x50, + 0x5b,0x5a,0x5a,0x32,0x28,0xa5,0xd1,0xe1,0xf5,0xf5,0xf5,0x84,0x84,0x71,0x4f,0xb4, + 0xd6,0xe8,0x76,0xbb,0x91,0xa7,0xf5,0x7a,0xdd,0xb8,0xbb,0xbb,0xab,0x15,0x8b,0xc5, + 0x15,0x0,0x7f,0x27,0x3c,0x20,0x84,0x2c,0xd7,0xeb,0xf5,0x9c,0x61,0x18,0xa0,0x94, + 0x22,0x24,0x21,0x84,0x4c,0xb4,0x1f,0xe7,0xa2,0x6f,0x0,0x28,0x97,0xcb,0x39,0xad, + 0xf5,0x72,0xca,0x83,0x4c,0x26,0xd3,0xae,0x56,0xab,0x94,0x10,0x82,0x38,0x49,0x1c, + 0x20,0x8c,0x97,0xd6,0x3a,0x45,0x14,0xce,0xdb,0xb6,0x4d,0x19,0x63,0xed,0x54,0xc, + 0x82,0x20,0x58,0x9c,0x9b,0x9b,0x4b,0xdc,0x2a,0x4e,0x30,0x7e,0xeb,0x38,0xa8,0x52, + 0x2a,0x32,0xdb,0xb6,0x21,0xa5,0x5c,0x4c,0x11,0xc4,0x75,0x8d,0x67,0xd6,0xa4,0x9b, + 0x86,0x26,0xa5,0x4c,0xbc,0xd,0x29,0x93,0x8f,0x3a,0x22,0x30,0x4d,0xf3,0xfa,0xe5, + 0xe5,0x25,0xb1,0x51,0x4a,0x99,0x0,0xfb,0x99,0x85,0x29,0x1b,0xda,0xfb,0xfb,0x3b, + 0x8,0x21,0xd7,0x3f,0x93,0xe8,0xec,0xf9,0xf9,0x59,0xc6,0xf3,0x9b,0x73,0x9e,0xb8, + 0x5d,0x28,0x43,0x9c,0x20,0xdc,0x1b,0x5a,0xbf,0xdf,0x97,0x52,0xca,0xb3,0x54,0x90, + 0xb5,0xd6,0x17,0xf,0xf,0xf,0x43,0xdf,0xf7,0xf3,0x21,0x90,0x69,0x9a,0x9,0x97, + 0xc7,0x53,0x54,0x29,0x5,0xce,0x39,0x38,0xe7,0xf0,0x7d,0x1f,0xbe,0xef,0xc3,0x75, + 0xdd,0x21,0x21,0xe4,0x22,0x45,0xe0,0xba,0xee,0xb1,0x69,0x9a,0x8f,0x57,0x57,0x57, + 0xb,0x8d,0x46,0xc3,0x10,0x42,0x80,0x52,0x8a,0x83,0x83,0x3,0x10,0x42,0x22,0x4f, + 0x84,0x10,0x11,0x18,0xe7,0x1c,0xa3,0xd1,0x8,0xa3,0xd1,0x8,0x9c,0x73,0xf4,0x7a, + 0x3d,0xc5,0x39,0x7f,0x74,0x5d,0xf7,0x38,0x8a,0xe1,0x78,0xa9,0xc8,0x64,0x32,0xdf, + 0xd7,0xd6,0xd6,0xac,0x42,0xa1,0x90,0x28,0x15,0xa1,0x57,0xa1,0x84,0x71,0x12,0xce, + 0x39,0x3c,0xcf,0xc3,0xcd,0xcd,0xcd,0x20,0x8,0x82,0x44,0xa9,0x48,0x55,0xd3,0xad, + 0xad,0xad,0x3f,0x6c,0xdb,0xde,0x6e,0xb5,0x5a,0x79,0xcb,0xb2,0x40,0x8,0x49,0x64, + 0x4c,0xbc,0xe,0x85,0x24,0x9e,0xe7,0xe1,0xfe,0xfe,0xfe,0x9f,0xe1,0x70,0xf8,0xad, + 0xdb,0xed,0x26,0x8a,0x5d,0xaa,0x9a,0x56,0x2a,0x95,0x3d,0xc7,0x71,0x70,0x72,0x72, + 0xf2,0xb5,0xd1,0x68,0xe4,0x6a,0xb5,0x9a,0x11,0x27,0x8,0x49,0xc2,0xa0,0xbe,0xbe, + 0xbe,0xaa,0x5e,0xaf,0x37,0x54,0x4a,0x7d,0xab,0x56,0xab,0x7b,0xe3,0x78,0x1f,0x36, + 0x1c,0xc6,0xd8,0x51,0x26,0x93,0xa9,0x95,0x4a,0xa5,0x5c,0x3e,0x9f,0xa7,0x96,0x65, + 0x41,0x8,0x1,0xcf,0xf3,0xe0,0x79,0x9e,0xec,0xf7,0xfb,0x43,0xdf,0xf7,0x1f,0x85, + 0x10,0xbf,0xde,0x70,0xe2,0x23,0x6c,0x99,0x5a,0xeb,0x65,0x4a,0x69,0x5b,0x6b,0xbd, + 0x8,0x0,0x84,0x90,0x6b,0x29,0xe5,0x19,0x21,0xe4,0xbf,0xb7,0xcc,0xff,0x6b,0x7c, + 0xfa,0x5f,0xc5,0xbf,0xb,0x1c,0x87,0x37,0xff,0x2c,0x5b,0xa6,0x0,0x0,0x0,0x0, + 0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82, + +}; + +static const unsigned char qt_resource_name[] = { + // toolbar + 0x0,0x7, + 0xb,0x66,0x28,0x62, + 0x0,0x74, + 0x0,0x6f,0x0,0x6f,0x0,0x6c,0x0,0x62,0x0,0x61,0x0,0x72, + // main + 0x0,0x4, + 0x0,0x7,0x37,0xfe, + 0x0,0x6d, + 0x0,0x61,0x0,0x69,0x0,0x6e, + // capture_start_24.png + 0x0,0x14, + 0xe,0xed,0x52,0x7, + 0x0,0x63, + 0x0,0x61,0x0,0x70,0x0,0x74,0x0,0x75,0x0,0x72,0x0,0x65,0x0,0x5f,0x0,0x73,0x0,0x74,0x0,0x61,0x0,0x72,0x0,0x74,0x0,0x5f,0x0,0x32,0x0,0x34,0x0,0x2e, + 0x0,0x70,0x0,0x6e,0x0,0x67, + // capture_start_active_24.png + 0x0,0x1b, + 0xa,0x41,0xe4,0x47, + 0x0,0x63, + 0x0,0x61,0x0,0x70,0x0,0x74,0x0,0x75,0x0,0x72,0x0,0x65,0x0,0x5f,0x0,0x73,0x0,0x74,0x0,0x61,0x0,0x72,0x0,0x74,0x0,0x5f,0x0,0x61,0x0,0x63,0x0,0x74, + 0x0,0x69,0x0,0x76,0x0,0x65,0x0,0x5f,0x0,0x32,0x0,0x34,0x0,0x2e,0x0,0x70,0x0,0x6e,0x0,0x67, + // capture_stop_24.png + 0x0,0x13, + 0x2,0x9c,0xc9,0x67, + 0x0,0x63, + 0x0,0x61,0x0,0x70,0x0,0x74,0x0,0x75,0x0,0x72,0x0,0x65,0x0,0x5f,0x0,0x73,0x0,0x74,0x0,0x6f,0x0,0x70,0x0,0x5f,0x0,0x32,0x0,0x34,0x0,0x2e,0x0,0x70, + 0x0,0x6e,0x0,0x67, + +}; + +static const unsigned char qt_resource_struct[] = { + // : + 0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x1, + // :/toolbar + 0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x2, + // :/toolbar/main + 0x0,0x0,0x0,0x14,0x0,0x2,0x0,0x0,0x0,0x3,0x0,0x0,0x0,0x3, + // :/toolbar/main/capture_stop_24.png + 0x0,0x0,0x0,0x8c,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x9,0x9a, + // :/toolbar/main/capture_start_active_24.png + 0x0,0x0,0x0,0x50,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x4,0xd0, + // :/toolbar/main/capture_start_24.png + 0x0,0x0,0x0,0x22,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0, + +}; + +QT_BEGIN_NAMESPACE + +extern Q_CORE_EXPORT bool qRegisterResourceData + (int, const unsigned char *, const unsigned char *, const unsigned char *); + +extern Q_CORE_EXPORT bool qUnregisterResourceData + (int, const unsigned char *, const unsigned char *, const unsigned char *); + +QT_END_NAMESPACE + + +int QT_MANGLE_NAMESPACE(qInitResources_toolbar)() +{ + QT_PREPEND_NAMESPACE(qRegisterResourceData) + (0x01, qt_resource_struct, qt_resource_name, qt_resource_data); + return 1; +} + +Q_CONSTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qInitResources_toolbar)) + +int QT_MANGLE_NAMESPACE(qCleanupResources_toolbar)() +{ + QT_PREPEND_NAMESPACE(qUnregisterResourceData) + (0x01, qt_resource_struct, qt_resource_name, qt_resource_data); + return 1; +} + +Q_DESTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qCleanupResources_toolbar)) + diff --git a/ui/qt/qt_ui_utils.cpp b/ui/qt/qt_ui_utils.cpp new file mode 100644 index 0000000000..5f694265e8 --- /dev/null +++ b/ui/qt/qt_ui_utils.cpp @@ -0,0 +1,157 @@ +/* qt_ui_utils.cpp + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include <string.h> +#include <stdlib.h> + +#include "qt_ui_utils.h" + +#include "gtk/recent.h" + +// XXX - Copied from gtk/gui_utils.c + +#define WINDOW_GEOM_KEY "window_geom" + +/* load the geometry values for a window from previously saved values */ +static gboolean window_geom_load(const gchar *name, window_geometry_t *geom); + +/* the geometry hashtable for all known window classes, + * the window name is the key, and the geometry struct is the value */ +static GHashTable *window_geom_hash = NULL; + +/* save the window and it's current geometry into the geometry hashtable */ +static void +window_geom_save(const gchar *name, window_geometry_t *geom) +{ + gchar *key; + window_geometry_t *work; + + /* init hashtable, if not already done */ + if(!window_geom_hash) { + window_geom_hash = g_hash_table_new (g_str_hash, g_str_equal); + } + /* if we have an old one, remove and free it first */ + work = (window_geometry_t *) g_hash_table_lookup(window_geom_hash, name); + if(work) { + g_hash_table_remove(window_geom_hash, name); + g_free(work->key); + g_free(work); + } + + /* g_malloc and insert the new one */ + work = (window_geometry_t *) g_malloc(sizeof(*geom)); + *work = *geom; + key = g_strdup(name); + work->key = key; + g_hash_table_insert(window_geom_hash, key, work); +} + + +/* load the desired geometry for this window from the geometry hashtable */ +static gboolean +window_geom_load(const gchar *name, window_geometry_t *geom) +{ + window_geometry_t *p; + + /* init hashtable, if not already done */ + if(!window_geom_hash) { + window_geom_hash = g_hash_table_new (g_str_hash, g_str_equal); + } + + p = (window_geometry_t *) g_hash_table_lookup(window_geom_hash, name); + if(p) { + *geom = *p; + return TRUE; + } else { + return FALSE; + } +} + + +/* read in a single key value pair from the recent file into the geometry hashtable */ +void +window_geom_recent_read_pair(const char *name, const char *key, const char *value) +{ + window_geometry_t geom; + + + /* find window geometry maybe already in hashtable */ + if(!window_geom_load(name, &geom)) { + /* not in table, init geom with "basic" values */ + geom.key = NULL; /* Will be set in window_geom_save () */ + geom.set_pos = FALSE; + geom.x = -1; + geom.y = -1; + geom.set_size = FALSE; + geom.width = -1; + geom.height = -1; + + geom.set_maximized = FALSE;/* this is valid in GTK2 only */ + geom.maximized = FALSE; /* this is valid in GTK2 only */ + } + + if (strcmp(key, "x") == 0) { + geom.x = strtol(value, NULL, 10); + geom.set_pos = TRUE; + } else if (strcmp(key, "y") == 0) { + geom.y = strtol(value, NULL, 10); + geom.set_pos = TRUE; + } else if (strcmp(key, "width") == 0) { + geom.width = strtol(value, NULL, 10); + geom.set_size = TRUE; + } else if (strcmp(key, "height") == 0) { + geom.height = strtol(value, NULL, 10); + geom.set_size = TRUE; + } else if (strcmp(key, "maximized") == 0) { + if (g_ascii_strcasecmp(value, "true") == 0) { + geom.maximized = TRUE; + } + else { + geom.maximized = FALSE; + } + geom.set_maximized = TRUE; + } else { + /* + * Silently ignore the bogus key. We shouldn't abort here, + * as this could be due to a corrupt recent file. + * + * XXX - should we print a message about this? + */ + return; + } + + /* save / replace geometry in hashtable */ + window_geom_save(name, &geom); +} + +/* write all geometry values of all windows from the hashtable to the recent file */ +void +window_geom_recent_write_all(gpointer rf) +{ + /* init hashtable, if not already done */ + if(!window_geom_hash) { + window_geom_hash = g_hash_table_new (g_str_hash, g_str_equal); + } + + g_hash_table_foreach(window_geom_hash, write_recent_geom, rf); +} diff --git a/ui/qt/qt_ui_utils.h b/ui/qt/qt_ui_utils.h new file mode 100644 index 0000000000..50b0808f8c --- /dev/null +++ b/ui/qt/qt_ui_utils.h @@ -0,0 +1,149 @@ +/* qt_gui_utils.h + * Declarations of GTK+-specific UI utility routines + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __QT_UI_UTILS_H__ +#define __QT_UI_UTILS_H__ + +// xxx - copied from gtk/gui_utils.h + +#include <stdio.h> + +#include "config.h" + +#include <glib.h> +#include <epan/timestamp.h> +//#include <packet_list.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +// These are defined elsewhere in ../gtk/ +#define RECENT_KEY_COL_WIDTH "column.width" +#define RECENT_KEY_CAPTURE_FILTER "recent.capture_filter" +#define RECENT_KEY_CAPTURE_FILE "recent.capture_file" +#define RECENT_KEY_REMOTE_HOST "recent.remote_host" + +extern gboolean dfilter_combo_add_recent(gchar *filter); +extern gboolean cfilter_combo_add_recent(gchar *filter); +extern void dfilter_recent_combo_write_all(FILE *rf); +extern void cfilter_combo_recent_write_all(FILE *rf); +extern void new_packet_list_recent_write_all(FILE *rf); +/** Get the latest opened directory. + * + * @return the dirname + */ +extern char *get_last_open_dir(void); +/* Add a new recent capture filename to the "Recent Files" submenu + (duplicates will be ignored) */ +extern void add_menu_recent_capture_file(gchar *cf_name); +/** Write all recent capture filenames to the user's recent file. + * @param rf recent file + */ +extern void menu_recent_file_write_all(FILE *rf); + + +/* Type of capture source */ +typedef enum { + CAPTURE_IFLOCAL, /**< Local network interface */ + CAPTURE_IFREMOTE /**< Remote network interface */ +} capture_source; + +/* Type of RPCAPD Authentication */ +typedef enum { + CAPTURE_AUTH_NULL, /**< No authentication */ + CAPTURE_AUTH_PWD /**< User/password authentication */ +} capture_auth; + +struct remote_host_t { + gchar *remote_host; /**< Host name or network address for remote capturing */ + gchar *remote_port; /**< TCP port of remote RPCAP server */ + gint auth_type; /**< Authentication type */ + gchar *auth_username; /**< Remote authentication parameters */ + gchar *auth_password; /**< Remote authentication parameters */ + gboolean datatx_udp; + gboolean nocap_rpcap; + gboolean nocap_local; +}; + +/** Write all remote hosts to the recent file + * + * @param rf recent file + */ +void +capture_remote_combo_recent_write_all(FILE *rf); + +/** Add a new remote host from the recent file + * + * @param s string with hostname,port,auth_type + * @return TRUE if correctly added + */ +gboolean +capture_remote_combo_add_recent(gchar *s); + + + +/** @file + * Utilities for Windows and other user interface functions. + */ + +/** @name Window Functions + * @todo Move these window functions to a new file win_utils.h? + * @{ */ + + +/** geometry values for use in window_get_geometry() and window_set_geometry() */ +typedef struct window_geometry_s { + gchar *key; /**< current key in hashtable (internally used only) */ + gboolean set_pos; /**< set the x and y position values */ + gint x; /**< the windows x position */ + gint y; /**< the windows y position */ + gboolean set_size; /**< set the width and height values */ + gint width; /**< the windows width */ + gint height; /**< the windows height */ + + gboolean set_maximized; /**< set the maximized state (GTK2 only) */ + gboolean maximized; /**< the windows maximized state (GTK2 only) */ +} window_geometry_t; + +/** Write all geometry values of all windows to the recent file. + * Will call write_recent_geom() for every existing window type. + * + * @param rf recent file handle from caller + */ +extern void window_geom_recent_write_all(gpointer rf); + +/** Read in a single geometry key value pair from the recent file. + * + * @param name the geom_name of the window + * @param key the subkey of this pair (e.g. "x") + * @param value the new value (e.g. "123") + */ +extern void window_geom_recent_read_pair(const char *name, const char *key, const char *value); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __QT_UI_UTILS__H__ */ diff --git a/ui/qt/recent_file_status.cpp b/ui/qt/recent_file_status.cpp new file mode 100644 index 0000000000..d725b4d94d --- /dev/null +++ b/ui/qt/recent_file_status.cpp @@ -0,0 +1,46 @@ +/* recent_file_status.cpp + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "recent_file_status.h" + +#include <QFileInfo> + +// Sigh. The Qt 4 documentation says we should subclass QThread here. Other sources +// insist that we should subclass QObject, then move it to a newly created QThread. +RecentFileStatus::RecentFileStatus(const QString &filename, QObject *parent) : + QObject(parent) +{ + m_filename = filename; +} + +void RecentFileStatus::start(void) { + QFileInfo fi; + + fi.setFile(m_filename); + + if (fi.isFile() && fi.isReadable()) { + emit statusFound(m_filename, fi.size(), true); + } else { + emit statusFound(m_filename, 0, false); + } +} diff --git a/ui/qt/recent_file_status.h b/ui/qt/recent_file_status.h new file mode 100644 index 0000000000..9ca7005d88 --- /dev/null +++ b/ui/qt/recent_file_status.h @@ -0,0 +1,52 @@ +/* recent_file_status.h + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef RECENT_FILE_STATUS_H +#define RECENT_FILE_STATUS_H + +#include <QObject> + +class RecentFileStatus : public QObject +{ + Q_OBJECT +public: + RecentFileStatus(const QString &filename, QObject *parent = 0); + + QString getFilename() const { return (m_filename); } + size_t getSize() const { return (m_size); } + void quit() { emit finished(); } + +private: + QString m_filename; + size_t m_size; + +signals: + void statusFound(const QString &filename = *new QString(), qint64 size = 0, bool accessible = false); + void finished(); + +public slots: + void start(); + +}; + +#endif // RECENT_FILE_STATUS_H diff --git a/ui/qt/simple_dialog_qt.cpp b/ui/qt/simple_dialog_qt.cpp new file mode 100644 index 0000000000..fc7754f6b3 --- /dev/null +++ b/ui/qt/simple_dialog_qt.cpp @@ -0,0 +1,144 @@ +/* simple_dialog_qt.cpp + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <stdio.h> + +#include <glib.h> + +#include <epan/strutil.h> + +#include "simple_dialog_qt.h" +#include "simple_dialog.h" + +/* Simple dialog function - Displays a dialog box with the supplied message + * text. + * + * Args: + * type : One of ESD_TYPE_*. + * btn_mask : The value passed in determines which buttons are displayed. + * msg_format : Sprintf-style format of the text displayed in the dialog. + * ... : Argument list for msg_format + */ + +gpointer +vsimple_dialog(ESD_TYPE_E type, gint btn_mask, const gchar *msg_format, va_list ap) +{ + + gchar *vmessage; + gchar *message; + SimpleDialog *dlg = NULL; +// queued_message_t *queued_message; +// GtkWidget *win; +// GdkWindowState state = 0; + + /* Format the message. */ + vmessage = g_strdup_vprintf(msg_format, ap); + + /* convert character encoding from locale to UTF8 (using iconv) */ + message = g_locale_to_utf8(vmessage, -1, NULL, NULL, NULL); + g_free(vmessage); + + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: vsimple_dialog t: %d bm: %d m: %s", type, btn_mask, message); + + +// if (top_level != NULL) { +// state = gdk_window_get_state(top_level->window); +// } + +// /* If we don't yet have a main window or it's iconified, don't show the +// dialog. If showing up a dialog, while main window is iconified, program +// will become unresponsive! */ +// if (top_level == NULL || state & GDK_WINDOW_STATE_ICONIFIED) { + +// queued_message = g_malloc(sizeof (queued_message_t)); +// queued_message->type = type; +// queued_message->btn_mask = btn_mask; +// queued_message->message = message; +// message_queue = g_slist_append(message_queue, queued_message); +// return NULL; +// } + +// /* +// * Do we have any queued up messages? If so, pop them up. +// */ +// display_queued_messages(); + +// win = display_simple_dialog(type, btn_mask, message); + + g_free(message); + + return dlg; +} + +gpointer +simple_dialog(ESD_TYPE_E type, gint btn_mask, const gchar *msg_format, ...) +{ + va_list ap; + gpointer ret; + + va_start(ap, msg_format); + ret = vsimple_dialog(type, btn_mask, msg_format, ap); + va_end(ap); + return ret; +} + +char * +simple_dialog_primary_start(void) { + return "<span weight=\"bold\" size=\"larger\">"; +} + +char * +simple_dialog_primary_end(void) { + return "</span>"; +} + +char * +simple_dialog_format_message(const char *msg) +{ + char *str; + + if (msg) { + str = xml_escape(msg); + } else { + str = NULL; + } + return str; +} + +void simple_dialog_set_cb(gpointer dialog, simple_dialog_cb_t callback_fct, gpointer data) +{ + g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: simple_dialog_set_cb d: %p cf: %p d: %p", dialog, callback_fct, data); + +// g_object_set_data(G_OBJECT(GTK_WIDGET(dialog)), CALLBACK_FCT_KEY, callback_fct); +// g_object_set_data(G_OBJECT(GTK_WIDGET(dialog)), CALLBACK_DATA_KEY, data); +} + + +SimpleDialog::SimpleDialog(QWidget *parent) : + QErrorMessage(parent) +{ +} diff --git a/ui/qt/simple_dialog_qt.h b/ui/qt/simple_dialog_qt.h new file mode 100644 index 0000000000..ccc2828289 --- /dev/null +++ b/ui/qt/simple_dialog_qt.h @@ -0,0 +1,41 @@ +/* simple_dialog_qt.h + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef SIMPLE_DIALOG_QT_H +#define SIMPLE_DIALOG_QT_H + +#include <QErrorMessage> + +class SimpleDialog : public QErrorMessage +{ + Q_OBJECT +public: + explicit SimpleDialog(QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // SIMPLE_DIALOG_QT_H diff --git a/ui/qt/toolbar.qrc b/ui/qt/toolbar.qrc new file mode 100644 index 0000000000..9b777c32e8 --- /dev/null +++ b/ui/qt/toolbar.qrc @@ -0,0 +1,7 @@ +<RCC> + <qresource prefix="/toolbar/main"> + <file>capture_start_24.png</file> + <file>capture_stop_24.png</file> + <file>capture_start_active_24.png</file> + </qresource> +</RCC> diff --git a/ui/qt/toolbar_24.svg b/ui/qt/toolbar_24.svg new file mode 100644 index 0000000000..d55b2573f2 --- /dev/null +++ b/ui/qt/toolbar_24.svg @@ -0,0 +1,374 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="720" + height="24" + id="svg2" + version="1.1" + inkscape:version="0.48.0 r9654" + sodipodi:docname="toolbar_24.svg" + inkscape:export-filename="/Users/gerald/Development/wxshark/image/toolbar/capture_start_24.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <defs + id="defs4"> + <linearGradient + id="linearGradient3855"> + <stop + style="stop-color:#ffffff;stop-opacity:0.77083331;" + offset="0" + id="stop3857" /> + <stop + style="stop-color:#ffffff;stop-opacity:0;" + offset="1" + id="stop3859" /> + </linearGradient> + <linearGradient + id="linearGradient3622"> + <stop + style="stop-color:#ffffff;stop-opacity:1;" + offset="0" + id="stop3624" /> + <stop + style="stop-color:#999999;stop-opacity:1;" + offset="1" + id="stop3626" /> + </linearGradient> + <inkscape:perspective + sodipodi:type="inkscape:persp3d" + inkscape:vp_x="0 : 526.18109 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_z="744.09448 : 526.18109 : 1" + inkscape:persp3d-origin="372.04724 : 350.78739 : 1" + id="perspective10" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient3622" + id="radialGradient3644" + gradientUnits="userSpaceOnUse" + cx="9.8919125" + cy="11.134647" + fx="11.346226" + fy="14.609268" + r="9" + gradientTransform="matrix(1.6712597,-3.7402904e-6,3.3840172e-6,1.5131578,-5.6767279,-6.2299573)" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient3622" + id="radialGradient3617" + cx="11.478261" + cy="10.956548" + fx="11.478261" + fy="10.956548" + r="9.391304" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(1.5,4.4485238e-8,-4.4485238e-8,1.5,-5.1521738,-5.1521876)" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient3855" + id="radialGradient3861" + cx="10.383852" + cy="7.6142039" + fx="10.383852" + fy="7.6142039" + r="12" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.39585463,0.00788241,-0.00767096,0.38523527,5.8229123,4.7348906)" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient3622" + id="radialGradient3876" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(1.5,4.4485238e-8,-4.4485238e-8,1.5,-5.1521738,-5.1521876)" + cx="11.478261" + cy="10.956548" + fx="11.478261" + fy="10.956548" + r="9.391304" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient3855" + id="radialGradient3878" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.39585463,0.00788241,-0.00767096,0.38523527,5.8229123,4.7348906)" + cx="10.383852" + cy="7.6142039" + fx="10.383852" + fy="7.6142039" + r="12" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient3855" + id="radialGradient3881" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.39585463,0.00788241,-0.00767096,0.38523527,29.822912,1033.0971)" + cx="10.383852" + cy="7.6142039" + fx="10.383852" + fy="7.6142039" + r="12" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient3855" + id="radialGradient3888" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.39585463,0.00788241,-0.00767096,0.38523527,29.822912,1033.0971)" + cx="10.383852" + cy="7.6142039" + fx="10.383852" + fy="7.6142039" + r="12" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient3855" + id="radialGradient3891" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.39585463,0.00788241,-0.00767096,0.38523527,29.822912,1033.0971)" + cx="10.383852" + cy="7.6142039" + fx="10.383852" + fy="7.6142039" + r="12" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient3622" + id="radialGradient3893" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(1.5,4.4485238e-8,-4.4485238e-8,1.5,-5.1521738,-5.1521876)" + cx="11.478261" + cy="10.956548" + fx="11.478261" + fy="10.956548" + r="9.391304" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient3855" + id="radialGradient3895" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.39585463,0.00788241,-0.00767096,0.38523527,5.8229123,4.7348906)" + cx="10.383852" + cy="7.6142039" + fx="10.383852" + fy="7.6142039" + r="12" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient3855" + id="radialGradient3898" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.39585463,0.00788241,-0.00767096,0.38523527,5.8229123,1033.0971)" + cx="10.383852" + cy="7.6142039" + fx="10.383852" + fy="7.6142039" + r="12" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient3622" + id="radialGradient3902" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(1.5,4.4485238e-8,-4.4485238e-8,1.5,-5.1521738,-5.1521876)" + cx="11.478261" + cy="10.956548" + fx="11.478261" + fy="10.956548" + r="9.391304" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient3855" + id="radialGradient3906" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.39585463,0.00788241,-0.00767096,0.38523527,53.822912,1033.0971)" + cx="10.383852" + cy="7.6142039" + fx="10.383852" + fy="7.6142039" + r="12" /> + </defs> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="8" + inkscape:cx="31.363152" + inkscape:cy="33.958939" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="true" + inkscape:window-width="1130" + inkscape:window-height="793" + inkscape:window-x="223" + inkscape:window-y="808" + inkscape:window-maximized="0" + objecttolerance="2" + guidetolerance="5" + gridtolerance="4"> + <inkscape:grid + type="xygrid" + id="grid2812" + empspacing="4" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" + spacingx="6px" + spacingy="6px" + color="#7fffff" + opacity="0.49803922" + empcolor="#007fff" + empopacity="0.49803922" /> + </sodipodi:namedview> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-1028.3622)"> + <rect + style="fill:none;stroke:none" + id="rect3660" + width="24" + height="24" + x="48" + y="1028.3622" + inkscape:export-filename="/Users/gerald/Development/wxshark/image/toolbar/capture_stop_24.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" /> + <flowRoot + xml:space="preserve" + id="flowRoot2835" + style="font-size:1.5px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + transform="translate(5.8681641,1025.9527)"><flowRegion + id="flowRegion2837"><rect + id="rect2839" + width="36" + height="6" + x="-11.868164" + y="32.4095" + style="font-size:1.5px;text-align:center;text-anchor:middle" /></flowRegion><flowPara + id="flowPara2841">Start Capture</flowPara><flowPara + id="flowPara3648">capture_start_24.png</flowPara></flowRoot> <path + style="fill:url(#radialGradient3644);fill-opacity:1;stroke:#666666;stroke-width:0.94736838;stroke-opacity:1" + transform="matrix(1.0555556,0,0,1.0555556,44.166666,1024.5288)" + d="M 24,15 A 9,9 0 1 1 6,15 9,9 0 1 1 24,15 z" + sodipodi:ry="9" + sodipodi:rx="9" + sodipodi:cy="15" + sodipodi:cx="15" + id="path3640" + sodipodi:type="arc" + inkscape:export-filename="/Users/gerald/Development/wxshark/image/toolbar/capture_stop_24.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" /> + <rect + style="fill:#000000;fill-opacity:0.74910398;stroke:none" + id="rect3646" + width="8" + height="8" + x="56" + y="1036.3622" + inkscape:export-filename="/Users/gerald/Development/wxshark/image/toolbar/capture_stop_24.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" /> + <flowRoot + transform="translate(53.868164,1025.9527)" + style="font-size:1.5px;font-style:normal;font-weight:normal;text-align:center;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + id="flowRoot3650" + xml:space="preserve"><flowRegion + id="flowRegion3652"><rect + style="font-size:1.5px;text-align:center;text-anchor:middle" + y="32.4095" + x="-11.868164" + height="6" + width="36" + id="rect3654" /></flowRegion><flowPara + id="flowPara3656">Stop Capture</flowPara><flowPara + id="flowPara3658">capture_stop_24.png</flowPara></flowRoot> <flowRoot + xml:space="preserve" + id="flowRoot3619" + style="font-size:1.5px;font-style:normal;font-weight:normal;text-align:start;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + transform="translate(23.868164,983.9527)"><flowRegion + id="flowRegion3621"><rect + id="rect3623" + width="36" + height="6" + x="-11.868164" + y="32.4095" + style="font-size:1.5px;text-align:start;text-anchor:start" /></flowRegion><flowPara + id="flowPara3627">To export: Select an entire 24x24 square,</flowPara><flowPara + id="flowPara3631">including its invisible border.</flowPara></flowRoot> <path + sodipodi:type="arc" + id="path2845" + sodipodi:cx="15" + sodipodi:cy="15" + sodipodi:rx="9" + sodipodi:ry="9" + d="M 24,15 A 9,9 0 1 1 6,15 9,9 0 1 1 24,15 z" + transform="matrix(1.2777778,0,0,1.2777778,-7.166667,1021.1955)" + style="fill:url(#radialGradient3902);fill-opacity:1;stroke:#666666;stroke-width:0.78260869;stroke-opacity:1" + inkscape:export-filename="/Users/gcombs/Development/qtshark/image/toolbar/capture_start_24.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" /> + <path + sodipodi:type="arc" + style="fill:#000000;fill-opacity:0.74910398;stroke:none" + id="path3630" + sodipodi:cx="12" + sodipodi:cy="12" + sodipodi:rx="6" + sodipodi:ry="6" + d="M 18,12 A 6,6 0 1 1 6,12 6,6 0 1 1 18,12 z" + transform="translate(0,1028.3622)" + inkscape:export-filename="/Users/gcombs/Development/qtshark/image/toolbar/capture_start_24.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90" /> + <path + inkscape:export-ydpi="90" + inkscape:export-xdpi="90" + inkscape:export-filename="/Users/gcombs/Development/qtshark/image/toolbar/capture_start_active_24.png" + style="fill:url(#radialGradient3876);fill-opacity:1;stroke:#666666;stroke-width:0.78260869;stroke-opacity:1" + transform="matrix(1.2777778,0,0,1.2777778,16.833333,1021.1955)" + d="M 24,15 A 9,9 0 1 1 6,15 9,9 0 1 1 24,15 z" + sodipodi:ry="9" + sodipodi:rx="9" + sodipodi:cy="15" + sodipodi:cx="15" + id="path3870" + sodipodi:type="arc" /> + <path + inkscape:export-ydpi="90" + inkscape:export-xdpi="90" + inkscape:export-filename="/Users/gcombs/Development/qtshark/image/toolbar/capture_start_active_24.png" + transform="translate(24,1028.3622)" + d="M 18,12 A 6,6 0 1 1 6,12 6,6 0 1 1 18,12 z" + sodipodi:ry="6" + sodipodi:rx="6" + sodipodi:cy="12" + sodipodi:cx="12" + id="path3872" + style="fill:#7efe00;fill-opacity:0.9911111;stroke:none" + sodipodi:type="arc" /> + </g> +</svg> diff --git a/ui/qt/welcome.qrc b/ui/qt/welcome.qrc new file mode 100644 index 0000000000..6a6bfa655d --- /dev/null +++ b/ui/qt/welcome.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/welcome"> + <file>wslogo-blue-131x36.png</file> + </qresource> +</RCC> diff --git a/ui/qt/wireshark_application.cpp b/ui/qt/wireshark_application.cpp new file mode 100644 index 0000000000..2918a4d20f --- /dev/null +++ b/ui/qt/wireshark_application.cpp @@ -0,0 +1,234 @@ +/* wireshark_application.cpp + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "wireshark_application.h" + +#include "config.h" + +#include "glib.h" + +#include <epan/prefs.h> + +#include "qt_ui_utils.h" + +#include "recent_file_status.h" + +#include <QDir> +#include <QTimer> + +WiresharkApplication *wsApp = NULL; + +// XXX - Copied from gtk/file_dlg.c + +static char *last_open_dir = NULL; +static bool updated_last_open_dir = FALSE; +static QList<recent_item_status *> recent_items; + +void +set_last_open_dir(const char *dirname) +{ + qint64 len; + gchar *new_last_open_dir; + + if (dirname) { + len = strlen(dirname); + if (dirname[len-1] == G_DIR_SEPARATOR) { + new_last_open_dir = g_strconcat(dirname, NULL); + } + else { + new_last_open_dir = g_strconcat(dirname, + G_DIR_SEPARATOR_S, NULL); + } + + if (last_open_dir == NULL || + strcmp(last_open_dir, new_last_open_dir) != 0) + updated_last_open_dir = TRUE; + } + else { + new_last_open_dir = NULL; + if (last_open_dir != NULL) + updated_last_open_dir = TRUE; + } + + g_free(last_open_dir); + last_open_dir = new_last_open_dir; +} + +char * +get_last_open_dir(void) +{ + return last_open_dir; +} + +/* + * Add the capture filename to the application-wide "Recent Files" list. + * Contrary to the name this isn't limited to the "recent" menu. + */ +/* + * XXX - We might want to call SHAddToRecentDocs under Windows 7: + * http://stackoverflow.com/questions/437212/how-do-you-register-a-most-recently-used-list-with-windows-in-preparation-for-win + */ +void +add_menu_recent_capture_file(gchar *cf_name) { + QString normalized_cf_name = QString::fromUtf8(cf_name); +// QDir cf_path; + +// cf_path.setPath(normalized_cf_name); +// normalized_cf_name = cf_path.absolutePath(); + normalized_cf_name = QDir::cleanPath(normalized_cf_name); + normalized_cf_name = QDir::toNativeSeparators(normalized_cf_name); + + recent_item_status *ri; + + /* Iterate through the recent items list, removing duplicate entries and every + * item above count_max + */ + unsigned int cnt = 1; + foreach (ri, wsApp->recent_item_list()) { + /* if this element string is one of our special items (seperator, ...) or + * already in the list or + * this element is above maximum count (too old), remove it + */ + if (ri->filename.length() < 1 || +#ifdef _WIN32 + /* do a case insensitive compare on win32 */ + ri->filename.compare(normalized_cf_name, Qt::CaseInsensitive) == 0 || +#else /* _WIN32 */ + /* do a case sensitive compare on unix */ + ri->filename.compare(normalized_cf_name) == 0 || +#endif + cnt >= prefs.gui_recent_files_count_max) { + wsApp->recent_item_list().removeOne(ri); + delete(ri); + cnt--; + } + cnt++; + } + wsApp->addRecentItem(normalized_cf_name, 0, false); +} + +/* write all capture filenames of the menu to the user's recent file */ +void menu_recent_file_write_all(FILE *rf) { + + /* we have to iterate backwards through the children's list, + * so we get the latest item last in the file. + */ + QListIterator<recent_item_status *> rii(recent_items); + rii.toBack(); + while (rii.hasPrevious()) { + QString cf_name; + /* get capture filename from the menu item label */ + cf_name = rii.previous()->filename; + if (cf_name != NULL) { +// if(u3_active()) +// fprintf (rf, RECENT_KEY_CAPTURE_FILE ": %s\n", u3_contract_device_path(cf_name)); +// else + fprintf (rf, RECENT_KEY_CAPTURE_FILE ": %s\n", cf_name.toUtf8().constData()); + } + } +} + + +// +void WiresharkApplication::refreshRecentFiles(void) { + recent_item_status *ri; + RecentFileStatus *rf_status; + QThread *rf_thread; + + foreach (ri, recent_items) { + if (ri->in_thread) { + continue; + } + + rf_thread = new QThread; + rf_status = new RecentFileStatus(ri->filename); + + rf_status->moveToThread(rf_thread); + + connect(rf_thread, SIGNAL(started()), rf_status, SLOT(start())); + + connect(rf_status, SIGNAL(statusFound(QString, qint64, bool)), this, SLOT(itemStatusFinished(QString, qint64, bool))); + connect(rf_status, SIGNAL(finished()), rf_thread, SLOT(quit())); + connect(rf_status, SIGNAL(finished()), rf_status, SLOT(deleteLater())); +// connect(rf_status, SIGNAL(finished()), rf_thread, SLOT(deleteLater())); + + rf_thread->start(); + } +} + +void WiresharkApplication::clearRecentItems() { + recent_item_status *ri; + + foreach (ri, recent_items) { + recent_items.removeOne(ri); + delete(ri); + } + emit updateRecentItemStatus(NULL, 0, false); +} + +void WiresharkApplication::itemStatusFinished(const QString &filename, qint64 size, bool accessible) { + recent_item_status *ri; + RecentFileStatus *rf_status = qobject_cast<RecentFileStatus *>(QObject::sender());; + +// g_log(NULL, G_LOG_LEVEL_DEBUG, "rf isf %d", recent_items.count()); + foreach (ri, recent_items) { + if (filename == ri->filename && (size != ri->size || accessible != ri->accessible)) { + ri->size = size; + ri->accessible = accessible; + ri->in_thread = false; + +// g_log(NULL, G_LOG_LEVEL_DEBUG, "rf update %s", filename.toUtf8().constData()); + emit updateRecentItemStatus(filename, size, accessible); + } + } + + if (rf_status) { + rf_status->quit(); + } +} + +WiresharkApplication::WiresharkApplication(int &argc, char **argv) : + QApplication(argc, argv) +{ + wsApp = this; + + recentTimer = new QTimer(this); + connect(recentTimer, SIGNAL(timeout()), this, SLOT(refreshRecentFiles())); + recentTimer->start(2000); +} + +QList<recent_item_status *> WiresharkApplication::recent_item_list() const { + return recent_items; +} + +void WiresharkApplication::addRecentItem(const QString &filename, qint64 size, bool accessible) { + recent_item_status *ri = new(recent_item_status); + + ri->filename = filename; + ri->size = size; + ri->accessible = accessible; + ri->in_thread = false; + recent_items.prepend(ri); + + itemStatusFinished(filename, size, accessible); +} diff --git a/ui/qt/wireshark_application.h b/ui/qt/wireshark_application.h new file mode 100644 index 0000000000..f4601076c9 --- /dev/null +++ b/ui/qt/wireshark_application.h @@ -0,0 +1,69 @@ +/* wireshark_application.c + * + * $Id$ + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef WIRESHARK_APPLICATION_H +#define WIRESHARK_APPLICATION_H + +#include <QApplication> +#include <QList> +#include <QFileInfo> +#include <QThread> + +// 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); + QList<recent_item_status *> recent_item_list() const; + void addRecentItem(const QString &filename, qint64 size, bool accessible); + +private: + QTimer *recentTimer; + +signals: + void updateRecentItemStatus(const QString &filename, qint64 size, bool accessible); + +public slots: + void clearRecentItems(); + +private slots: + void itemStatusFinished(const QString &filename = "", qint64 size = 0, bool accessible = false); + void refreshRecentFiles(void); +}; + +extern WiresharkApplication *wsApp; + +#endif // WIRESHARK_APPLICATION_H |