forked from osmocom/wireshark
Gtk: Remove source code
Removing all gtk source code, except for main.? which will remain for the official removal during SFUS18 Change-Id: I4273baf207df1eaaa4b94623cfd10bf74b1fc4a4 Reviewed-on: https://code.wireshark.org/review/26937 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com>
This commit is contained in:
parent
f533016339
commit
9c5049a80b
|
@ -1541,7 +1541,6 @@ if(WIN32)
|
|||
set(PLATFORM_UI_SRC
|
||||
ui/win32/console_win32.c
|
||||
ui/win32/file_dlg_win32.c
|
||||
ui/win32/print_win32.c
|
||||
)
|
||||
set(PLATFORM_UI_RC_FILES
|
||||
image/file_dlg_win32.rc
|
||||
|
|
|
@ -2786,8 +2786,6 @@ AC_CONFIG_FILES(
|
|||
codecs/Makefile
|
||||
ui/Makefile
|
||||
ui/doxygen.cfg
|
||||
ui/gtk/Makefile
|
||||
ui/gtk/doxygen.cfg
|
||||
ui/cli/Makefile
|
||||
ui/qt/Makefile
|
||||
ui/qt/doxygen.cfg
|
||||
|
|
|
@ -3,12 +3,9 @@ Section: net
|
|||
Priority: optional
|
||||
Maintainer: Balint Reczey <balint@balintreczey.hu>
|
||||
Standards-Version: 3.9.7
|
||||
Build-Depends: libgtk-3-dev, lsb-release,
|
||||
# enable Qt 5 related dependencies for Qt 5-enabled build
|
||||
Build-Depends: lsb-release,
|
||||
qtbase5-dev, qtbase5-dev-tools, qttools5-dev, qttools5-dev-tools,
|
||||
qtmultimedia5-dev, libqt5svg5-dev,
|
||||
# enable Qt 4 related dependencies for Qt 4-enabled build
|
||||
# qt4-qmake, libqt4-dev,
|
||||
libpcap0.8-dev, flex, libz-dev, debhelper (>= 9), po-debconf, libtool,
|
||||
python (>= 2.6.6-3~), python-ply, libc-ares-dev, xsltproc,
|
||||
docbook-xsl (>= 1.64.1.0-0), docbook-xml, libxml2-utils, libpcre3-dev,
|
||||
|
@ -44,8 +41,7 @@ Description: network traffic analyzer - common files
|
|||
packets off the wire. Wireshark can decode too many protocols to list
|
||||
here.
|
||||
.
|
||||
This package provides files common to both wireshark (the GTK+ version)
|
||||
and tshark (the console version).
|
||||
This package provides files common to both wireshark and tshark (the console version).
|
||||
|
||||
Package: wireshark
|
||||
Architecture: any
|
||||
|
|
|
@ -2,17 +2,6 @@ Description: Change location of license file in about dialog
|
|||
Forwarded: not-needed
|
||||
Author: Frederic Peters <fpeters@debian.org>
|
||||
|
||||
--- a/ui/gtk/about_dlg.c
|
||||
+++ b/ui/gtk/about_dlg.c
|
||||
@@ -522,7 +522,7 @@
|
||||
#if defined(_WIN32)
|
||||
absolute_path = get_datafile_path("COPYING.txt");
|
||||
#else
|
||||
- absolute_path = get_datafile_path("COPYING");
|
||||
+ absolute_path = get_datafile_path("ABOUT.GPL");
|
||||
#endif
|
||||
page = text_page_new(absolute_path);
|
||||
|
||||
--- a/ui/qt/about_dialog.cpp
|
||||
+++ b/ui/qt/about_dialog.cpp
|
||||
@@ -335,7 +335,7 @@
|
||||
|
@ -22,5 +11,5 @@ Author: Frederic Peters <fpeters@debian.org>
|
|||
- f_license.setFileName(get_datafile_path("COPYING"));
|
||||
+ f_license.setFileName(get_datafile_path("ABOUT.GPL"));
|
||||
#endif
|
||||
|
||||
|
||||
f_license.open(QFile::ReadOnly | QFile::Text);
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
debian/README.Debian
|
|
@ -1,2 +0,0 @@
|
|||
usr/bin/wireshark-gtk
|
||||
usr/share/applications/wireshark-gtk.desktop
|
|
@ -1,2 +0,0 @@
|
|||
# the wireshark manpage covers wireshark-gtk, too
|
||||
wireshark-gtk: binary-without-manpage usr/bin/wireshark-gtk
|
|
@ -1,217 +0,0 @@
|
|||
#
|
||||
# Editor configuration
|
||||
#
|
||||
# http://editorconfig.org/
|
||||
#
|
||||
|
||||
[about_dlg.[ch]]
|
||||
indent_size = 2
|
||||
|
||||
[bytes_view.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[capture_dlg.[ch]]
|
||||
indent_size = 2
|
||||
|
||||
[capture_file_dlg.[ch]]
|
||||
indent_size = 2
|
||||
|
||||
[capture_if_dlg.[ch]]
|
||||
indent_size = 2
|
||||
|
||||
[capture_info_dlg.[ch]]
|
||||
indent_size = 2
|
||||
|
||||
[color_dlg.[ch]]
|
||||
indent_size = 2
|
||||
|
||||
[color_edit_dlg.[ch]]
|
||||
indent_size = 2
|
||||
|
||||
[color_utils.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[compare_stat.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[dcerpc_stat.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[edit_packet_comment_dlg.[ch]]
|
||||
indent_size = 2
|
||||
|
||||
[export_object_dlg.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[filter_autocomplete.[ch]]
|
||||
indent_size = 2
|
||||
|
||||
[filter_expression_save_dlg.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[filter_utils.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[find_dlg.[ch]]
|
||||
indent_size = 2
|
||||
|
||||
[flow_graph.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[goto_dlg.[ch]]
|
||||
indent_size = 2
|
||||
|
||||
[graph_analysis.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[gsm_map_summary.[ch]]
|
||||
indent_size = 2
|
||||
|
||||
[gui_stat_util.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[iax2_analysis.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[macros_dlg.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[manual_addr_resolv.[ch]]
|
||||
indent_size = 2
|
||||
|
||||
[packet_list.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[packet_list_store.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[packet_win.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[pixmap_save.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[prefs_capture.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[prefs_dlg.[ch]]
|
||||
indent_size = 2
|
||||
|
||||
[prefs_font_color.[ch]]
|
||||
indent_size = 2
|
||||
|
||||
[prefs_gui.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[print_dlg.[ch]]
|
||||
indent_size = 2
|
||||
|
||||
[profile_dlg.[ch]]
|
||||
indent_size = 2
|
||||
|
||||
[proto_dlg.[ch]]
|
||||
indent_size = 2
|
||||
|
||||
[proto_hier_tree_model.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[proto_tree_model.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[range_utils.[ch]]
|
||||
indent_size = 2
|
||||
|
||||
[response_time_delay_table.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[rpc_stat.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[rtp_analysis.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[rtp_player.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[sctp_assoc_analyse.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[sctp_byte_graph_dlg.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[sctp_chunk_stat.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[sctp_error_dlg.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[sctp_graph_dlg.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[sctp_stat_dlg.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[service_response_time_table.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[simple_dialog.[ch]]
|
||||
indent_size = 2
|
||||
|
||||
[simple_stattable.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[stats_tree_stat.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[summary_dlg.[ch]]
|
||||
indent_size = 2
|
||||
|
||||
[supported_protos_dlg.[ch]]
|
||||
indent_size = 2
|
||||
|
||||
[time_shift_dlg.[ch]]
|
||||
indent_size = 2
|
||||
|
||||
[uat_gui.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[voip_calls_dlg.[ch]]
|
||||
indent_style = tab
|
||||
indent_size = tab
|
||||
|
||||
[webbrowser.[ch]]
|
||||
indent_size = 2
|
|
@ -1,349 +0,0 @@
|
|||
# CMakeLists.txt
|
||||
#
|
||||
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
|
||||
ADD_CUSTOM_CMAKE_INCLUDE()
|
||||
|
||||
set(WIRESHARK_GTK_SRC
|
||||
about_dlg.c
|
||||
addr_resolution_dlg.c
|
||||
bytes_view.c
|
||||
capture_dlg.c
|
||||
capture_file_dlg.c
|
||||
capture_if_dlg.c
|
||||
capture_info_dlg.c
|
||||
color_dlg.c
|
||||
color_edit_dlg.c
|
||||
color_utils.c
|
||||
conversation_hastables_dlg.c
|
||||
conversations_table.c
|
||||
decode_as_dlg.c
|
||||
dfilter_expr_dlg.c
|
||||
dissector_tables_dlg.c
|
||||
dlg_utils.c
|
||||
drag_and_drop.c
|
||||
edit_packet_comment_dlg.c
|
||||
expert_comp_table.c
|
||||
export_object_dlg.c
|
||||
export_pdu_dlg.c
|
||||
export_sslkeys.c
|
||||
extcap_gtk.c
|
||||
filter_autocomplete.c
|
||||
file_dlg.c
|
||||
file_import_dlg.c
|
||||
fileset_dlg.c
|
||||
filter_dlg.c
|
||||
filter_expression_save_dlg.c
|
||||
filter_utils.c
|
||||
find_dlg.c
|
||||
firewall_dlg.c
|
||||
follow_stream.c
|
||||
font_utils.c
|
||||
goto_dlg.c
|
||||
graph_analysis.c
|
||||
gtk_iface_monitor.c
|
||||
gui_stat_util.c
|
||||
gui_utils.c
|
||||
help_dlg.c
|
||||
hostlist_table.c
|
||||
macros_dlg.c
|
||||
main.c
|
||||
main_80211_toolbar.c
|
||||
main_filter_toolbar.c
|
||||
main_menubar.c
|
||||
main_statusbar.c
|
||||
main_titlebar.c
|
||||
main_toolbar.c
|
||||
main_welcome.c
|
||||
manual_addr_resolv.c
|
||||
packet_history.c
|
||||
packet_list_store.c
|
||||
packet_list.c
|
||||
packet_panes.c
|
||||
packet_win.c
|
||||
pixmap_save.c
|
||||
plugins_dlg.c
|
||||
prefs_capture.c
|
||||
prefs_column.c
|
||||
prefs_dlg.c
|
||||
prefs_filter_expressions.c
|
||||
prefs_gui.c
|
||||
prefs_layout.c
|
||||
prefs_font_color.c
|
||||
print_dlg.c
|
||||
profile_dlg.c
|
||||
progress_dlg.c
|
||||
proto_dlg.c
|
||||
proto_hier_stats_dlg.c
|
||||
proto_hier_tree_model.c
|
||||
proto_tree_model.c
|
||||
range_utils.c
|
||||
response_time_delay_table.c
|
||||
sctp_byte_graph_dlg.c
|
||||
sctp_error_dlg.c
|
||||
sctp_graph_dlg.c
|
||||
service_response_time_table.c
|
||||
simple_dialog.c
|
||||
simple_stattable.c
|
||||
stock_icons.c
|
||||
summary_dlg.c
|
||||
supported_protos_dlg.c
|
||||
tap_param_dlg.c
|
||||
text_page_utils.c
|
||||
time_shift_dlg.c
|
||||
uat_gui.c
|
||||
webbrowser.c
|
||||
${WIRESHARK_CUSTOM_GTK_SRC}
|
||||
)
|
||||
|
||||
if (AIRPCAP_FOUND)
|
||||
set(WIRESHARK_GTK_SRC
|
||||
${WIRESHARK_GTK_SRC}
|
||||
airpcap_dlg.c
|
||||
airpcap_gui_utils.c
|
||||
main_airpcap_toolbar.c
|
||||
)
|
||||
endif()
|
||||
|
||||
if(PORTAUDIO_FOUND)
|
||||
set(WIRESHARK_GTK_SRC
|
||||
${WIRESHARK_GTK_SRC}
|
||||
rtp_player.c
|
||||
)
|
||||
|
||||
# For Win32, there is no PortAudio lib, we compile the files locally
|
||||
if(WIN32)
|
||||
add_definitions(
|
||||
-DPA_NO_DS
|
||||
-DPA_NO_ASIO
|
||||
)
|
||||
set(PORTAUDIO_SRC
|
||||
${PORTAUDIO_SRC_DIR}/common/pa_allocation.c
|
||||
${PORTAUDIO_SRC_DIR}/common/pa_converters.c
|
||||
${PORTAUDIO_SRC_DIR}/common/pa_cpuload.c
|
||||
${PORTAUDIO_SRC_DIR}/common/pa_dither.c
|
||||
${PORTAUDIO_SRC_DIR}/common/pa_front.c
|
||||
${PORTAUDIO_SRC_DIR}/common/pa_process.c
|
||||
${PORTAUDIO_SRC_DIR}/common/pa_skeleton.c
|
||||
${PORTAUDIO_SRC_DIR}/common/pa_stream.c
|
||||
${PORTAUDIO_SRC_DIR}/common/pa_trace.c
|
||||
${PORTAUDIO_SRC_DIR}/os/win/pa_win_hostapis.c
|
||||
${PORTAUDIO_SRC_DIR}/os/win/pa_win_util.c
|
||||
${PORTAUDIO_SRC_DIR}/os/win/pa_x86_plain_converters.c
|
||||
${PORTAUDIO_SRC_DIR}/os/win/pa_win_waveformat.c
|
||||
${PORTAUDIO_SRC_DIR}/hostapi/wmme/pa_win_wmme.c
|
||||
)
|
||||
add_library(portaudio OBJECT
|
||||
${PORTAUDIO_SRC}
|
||||
)
|
||||
set_target_properties(portaudio PROPERTIES
|
||||
INCLUDE_DIRECTORIES "${PORTAUDIO_INCLUDE_DIRS}"
|
||||
FOLDER "UI")
|
||||
|
||||
# Portaudio has some warnings, annoyingly the combination of CMake
|
||||
# and MSBuild means that just disabling the warnings on the specific
|
||||
# source files doesn't work, so set them to level 4 for the target
|
||||
#set_source_files_properties(${PORTAUDIO_SRC_DIR}/common/pa_front.c
|
||||
# PROPERTIES
|
||||
# COMPILE_FLAGS "/wd4189"
|
||||
#)
|
||||
#set_source_files_properties(${PORTAUDIO_SRC_DIR}/os/win/pa_x86_plain_converters.c
|
||||
# PROPERTIES
|
||||
# COMPILE_FLAGS "/wd4305"
|
||||
#)
|
||||
target_compile_options(portaudio
|
||||
PUBLIC "/w44189"
|
||||
PUBLIC "/w44305"
|
||||
)
|
||||
|
||||
# Portaudio has some size_t > long warnings as a result of using strlen()
|
||||
# and other warnings on x64.
|
||||
if ("${WIRESHARK_TARGET_PLATFORM}" STREQUAL "win64")
|
||||
#set_source_files_properties(${PORTAUDIO_SRC_DIR}/hostapi/wmme/pa_win_wmme.c
|
||||
# PROPERTIES
|
||||
# COMPILE_FLAGS "/wd4267"
|
||||
#)
|
||||
target_compile_options(portaudio
|
||||
PUBLIC "/w44267"
|
||||
PUBLIC "/w44311"
|
||||
PUBLIC "/w44312"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(WIRESHARK_TAP_SRC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compare_stat.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/dcerpc_stat.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/expert_comp_dlg.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/flow_graph.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/funnel_stat.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gsm_map_summary.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/iax2_analysis.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/io_stat.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/lbm_stream_dlg.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mac_lte_stat_dlg.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mcast_stream_dlg.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mtp3_summary.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rlc_lte_graph.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rlc_lte_stat_dlg.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rpc_stat.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rtp_analysis.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rtp_stream_dlg.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sctp_assoc_analyse.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sctp_chunk_stat.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sctp_chunk_stat_dlg.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sctp_stat_dlg.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/stats_tree_stat.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tcp_graph.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/voip_calls_dlg.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wlan_stat_dlg.c
|
||||
${WIRESHARK_CUSTOM_TAP_SRC}
|
||||
)
|
||||
|
||||
if (ENABLE_GTK3)
|
||||
add_definitions(
|
||||
${GTK3_DEFINITIONS}
|
||||
-DGDK_DISABLE_DEPRECATION_WARNINGS
|
||||
)
|
||||
else()
|
||||
add_definitions(
|
||||
# We are only allowed to include gtk/gtk.h, no other files. When
|
||||
# violating this with gtk3 the compiler will complain anyway.
|
||||
-DGTK_DISABLE_SINGLE_INCLUDES
|
||||
|
||||
# GTK+ 3 removes many implementation details and struct members from its
|
||||
# public headers. Make the compiler catch all uses of direct access to
|
||||
# struct fields so that you can go through them one by one and replace
|
||||
# them with a call to an accessor function instead.
|
||||
-DGSEAL_ENABLE
|
||||
|
||||
# To verify that your program does not use any deprecated symbols,
|
||||
# you can use defines to remove deprecated symbols from the header files
|
||||
# -DGDK_DISABLE_DEPRECATED
|
||||
-DGTK_DISABLE_DEPRECATED
|
||||
)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set(PLATFORM_UI_SRC
|
||||
capture_if_details_dlg_win32.c
|
||||
)
|
||||
endif()
|
||||
|
||||
set(GTKUI_FILES
|
||||
${WIRESHARK_GTK_SRC}
|
||||
${WIRESHARK_TAP_SRC}
|
||||
${PLATFORM_UI_SRC}
|
||||
)
|
||||
|
||||
set_source_files_properties(
|
||||
${GTKUI_FILES}
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "${WERROR_COMMON_FLAGS} ${NO_ERROR_DEPRECATED_DECLARATIONS_COMPILE_FLAGS}"
|
||||
)
|
||||
|
||||
register_tap_files(wireshark-tap-register.c
|
||||
${WIRESHARK_TAP_SRC}
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
set(PORTAUDIO_OBJ $<TARGET_OBJECTS:portaudio>)
|
||||
endif()
|
||||
|
||||
find_program(GLIB_COMPILE_RESOURCES_EXECUTABLE
|
||||
glib-compile-resources
|
||||
HINTS
|
||||
"${GLIB2_HINTS}/bin"
|
||||
)
|
||||
|
||||
pkg_check_modules(GRESOURCE QUIET gio-2.0>=2.32 gdk-pixbuf-2.0>=2.26)
|
||||
|
||||
macro(WIRESHARK_GRESOURCES _outputfile _resourcefile)
|
||||
add_custom_command(
|
||||
OUTPUT ${_outputfile}
|
||||
COMMAND ${GLIB_COMPILE_RESOURCES_EXECUTABLE} --sourcedir=${CMAKE_SOURCE_DIR} --target=${_outputfile} --generate --manual-register ${CMAKE_CURRENT_SOURCE_DIR}/${_resourcefile}
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_resourcefile}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
endmacro(WIRESHARK_GRESOURCES)
|
||||
|
||||
WIRESHARK_GRESOURCES(wireshark-gresources.h main.gresources.xml)
|
||||
|
||||
WIRESHARK_GRESOURCES(wireshark-gresources.c main.gresources.xml)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
if(GRESOURCE_FOUND AND NOT WIN32)
|
||||
set(PIXBUF_SRC
|
||||
wireshark-gresources.c
|
||||
wireshark-gresources.h
|
||||
)
|
||||
add_definitions(-DHAVE_GDK_GRESOURCE)
|
||||
else()
|
||||
set(PIXBUF_SRC
|
||||
pixbuf-csource.c
|
||||
)
|
||||
endif()
|
||||
|
||||
add_library(gtkui STATIC
|
||||
${GTKUI_FILES}
|
||||
${PORTAUDIO_OBJ}
|
||||
wireshark-tap-register.c
|
||||
${PIXBUF_SRC}
|
||||
)
|
||||
set_target_properties(gtkui PROPERTIES
|
||||
LINK_FLAGS "${WS_LINK_FLAGS}"
|
||||
FOLDER "UI"
|
||||
)
|
||||
|
||||
CHECKAPI(
|
||||
NAME
|
||||
gtk-base
|
||||
SWITCHES
|
||||
-g deprecated-gtk
|
||||
SOURCES
|
||||
${WIRESHARK_GTK_SRC}
|
||||
${WIRESHARK_TAP_SRC}
|
||||
${PLATFORM_UI_SRC}
|
||||
)
|
||||
CHECKAPI(
|
||||
NAME
|
||||
gtk-todo
|
||||
SWITCHES
|
||||
-M -g deprecated-gtk-todo
|
||||
SOURCES
|
||||
${WIRESHARK_GTK_SRC}
|
||||
${WIRESHARK_TAP_SRC}
|
||||
${PLATFORM_UI_SRC}
|
||||
)
|
||||
|
||||
#
|
||||
# Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
#
|
||||
# Local variables:
|
||||
# c-basic-offset: 8
|
||||
# tab-width: 8
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
#
|
||||
# vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
||||
# :indentSize=8:tabSize=8:noTabs=false:
|
||||
#
|
|
@ -1,31 +0,0 @@
|
|||
# CMakeListsCustom.txt
|
||||
#
|
||||
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# You can add custom GUI files here by replacing the commented out file foo with your file.
|
||||
|
||||
#Add GUI source files here
|
||||
set(WIRESHARK_CUSTOM_GTK_SRC
|
||||
# foo.c
|
||||
)
|
||||
|
||||
#Add your tap source files here:
|
||||
set(WIRESHARK_CUSTOM_TAP_SRC
|
||||
# tap_foo.c
|
||||
)
|
|
@ -1,440 +0,0 @@
|
|||
# Makefile.am
|
||||
# Automake file for the GTK interface routines for Wireshark
|
||||
#
|
||||
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
include $(top_srcdir)/Makefile.am.inc
|
||||
include Makefile_custom.common
|
||||
|
||||
# Generated C source files that we want in the distribution.
|
||||
GENERATED_FILES =
|
||||
|
||||
# Generated C source files that we don't want in the distribution.
|
||||
NODIST_GENERATED_FILES = \
|
||||
wireshark-tap-register.c
|
||||
|
||||
# Files that generate compileable files
|
||||
GENERATOR_FILES = \
|
||||
main.gresources.xml
|
||||
|
||||
WIRESHARK_COMMON_GTK_SRC = \
|
||||
about_dlg.c \
|
||||
addr_resolution_dlg.c \
|
||||
bytes_view.c \
|
||||
capture_dlg.c \
|
||||
capture_file_dlg.c \
|
||||
capture_if_dlg.c \
|
||||
capture_info_dlg.c \
|
||||
color_dlg.c \
|
||||
color_edit_dlg.c \
|
||||
color_utils.c \
|
||||
conversation_hastables_dlg.c \
|
||||
conversations_table.c \
|
||||
decode_as_dlg.c \
|
||||
dfilter_expr_dlg.c \
|
||||
dissector_tables_dlg.c \
|
||||
dlg_utils.c \
|
||||
drag_and_drop.c \
|
||||
edit_packet_comment_dlg.c \
|
||||
expert_comp_table.c \
|
||||
export_object_dlg.c \
|
||||
export_sslkeys.c \
|
||||
extcap_gtk.c \
|
||||
filter_autocomplete.c \
|
||||
file_dlg.c \
|
||||
file_import_dlg.c \
|
||||
fileset_dlg.c \
|
||||
filter_dlg.c \
|
||||
filter_expression_save_dlg.c \
|
||||
filter_utils.c \
|
||||
find_dlg.c \
|
||||
firewall_dlg.c \
|
||||
follow_stream.c \
|
||||
font_utils.c \
|
||||
goto_dlg.c \
|
||||
graph_analysis.c \
|
||||
gtk_iface_monitor.c \
|
||||
gui_stat_util.c \
|
||||
gui_utils.c \
|
||||
help_dlg.c \
|
||||
hostlist_table.c \
|
||||
macros_dlg.c \
|
||||
main.c \
|
||||
main_80211_toolbar.c \
|
||||
main_filter_toolbar.c \
|
||||
main_menubar.c \
|
||||
manual_addr_resolv.c \
|
||||
packet_panes.c \
|
||||
main_statusbar.c \
|
||||
main_titlebar.c \
|
||||
main_toolbar.c \
|
||||
main_welcome.c \
|
||||
packet_history.c \
|
||||
packet_list_store.c \
|
||||
packet_list.c \
|
||||
packet_win.c \
|
||||
pixmap_save.c \
|
||||
plugins_dlg.c \
|
||||
prefs_capture.c \
|
||||
prefs_column.c \
|
||||
prefs_dlg.c \
|
||||
prefs_filter_expressions.c \
|
||||
prefs_gui.c \
|
||||
prefs_layout.c \
|
||||
prefs_font_color.c \
|
||||
print_dlg.c \
|
||||
profile_dlg.c \
|
||||
progress_dlg.c \
|
||||
proto_dlg.c \
|
||||
proto_hier_stats_dlg.c \
|
||||
proto_hier_tree_model.c \
|
||||
proto_tree_model.c \
|
||||
range_utils.c \
|
||||
response_time_delay_table.c \
|
||||
rtp_player.c \
|
||||
sctp_byte_graph_dlg.c \
|
||||
sctp_error_dlg.c \
|
||||
sctp_graph_dlg.c \
|
||||
service_response_time_table.c \
|
||||
simple_dialog.c \
|
||||
simple_stattable.c \
|
||||
stock_icons.c \
|
||||
summary_dlg.c \
|
||||
supported_protos_dlg.c \
|
||||
tap_param_dlg.c \
|
||||
text_page_utils.c \
|
||||
time_shift_dlg.c \
|
||||
uat_gui.c \
|
||||
webbrowser.c \
|
||||
$(WIRESHARK_CUSTOM_GTK_SRC)
|
||||
|
||||
WIRESHARK_TAP_SRC = \
|
||||
compare_stat.c \
|
||||
dcerpc_stat.c \
|
||||
expert_comp_dlg.c \
|
||||
export_pdu_dlg.c \
|
||||
flow_graph.c \
|
||||
funnel_stat.c \
|
||||
gsm_map_summary.c \
|
||||
iax2_analysis.c \
|
||||
io_stat.c \
|
||||
lbm_stream_dlg.c \
|
||||
mac_lte_stat_dlg.c \
|
||||
mcast_stream_dlg.c \
|
||||
mtp3_summary.c \
|
||||
rlc_lte_graph.c \
|
||||
rlc_lte_stat_dlg.c \
|
||||
rpc_stat.c \
|
||||
rtp_analysis.c \
|
||||
rtp_stream_dlg.c \
|
||||
sctp_assoc_analyse.c \
|
||||
sctp_chunk_stat.c \
|
||||
sctp_chunk_stat_dlg.c \
|
||||
sctp_stat_dlg.c \
|
||||
stats_tree_stat.c \
|
||||
tcp_graph.c \
|
||||
voip_calls_dlg.c \
|
||||
wlan_stat_dlg.c \
|
||||
$(WIRESHARK_CUSTOM_TAP_SRC)
|
||||
|
||||
WIRESHARK_COMMON_GTK_HDRS = \
|
||||
about_dlg.h \
|
||||
addr_resolution_dlg.h \
|
||||
bytes_view.h \
|
||||
capture_dlg.h \
|
||||
capture_file_dlg.h \
|
||||
capture_if_dlg.h \
|
||||
cfilter_combo_utils.h \
|
||||
color_dlg.h \
|
||||
color_edit_dlg.h \
|
||||
color_utils.h \
|
||||
conversation_hastables_dlg.h \
|
||||
conversations_table.h \
|
||||
decode_as_dlg.h \
|
||||
dfilter_expr_dlg.h \
|
||||
dissector_tables_dlg.h \
|
||||
dlg_utils.h \
|
||||
drag_and_drop.h \
|
||||
edit_packet_comment_dlg.h \
|
||||
expert_comp_dlg.h \
|
||||
expert_comp_table.h \
|
||||
export_object_dlg.h \
|
||||
export_pdu_dlg.h \
|
||||
export_sslkeys.h \
|
||||
extcap_gtk.h \
|
||||
file_dlg.h \
|
||||
file_import_dlg.h \
|
||||
fileset_dlg.h \
|
||||
filter_autocomplete.h \
|
||||
filter_dlg.h \
|
||||
filter_expression_save_dlg.h \
|
||||
filter_utils.h \
|
||||
find_dlg.h \
|
||||
firewall_dlg.h \
|
||||
follow_stream.h \
|
||||
font_utils.h \
|
||||
goto_dlg.h \
|
||||
graph_analysis.h \
|
||||
gtk_iface_monitor.h \
|
||||
gtkglobals.h \
|
||||
gui_stat_menu.h \
|
||||
gui_stat_util.h \
|
||||
gui_utils.h \
|
||||
help_dlg.h \
|
||||
hostlist_table.h \
|
||||
keys.h \
|
||||
lbm_stream_dlg.h \
|
||||
macros_dlg.h \
|
||||
main.h \
|
||||
main_filter_toolbar.h \
|
||||
main_menubar_private.h \
|
||||
main_80211_toolbar.h \
|
||||
menus.h \
|
||||
packet_panes.h \
|
||||
main_statusbar_private.h \
|
||||
main_titlebar.h \
|
||||
main_toolbar.h \
|
||||
main_toolbar_private.h \
|
||||
main_welcome.h \
|
||||
main_welcome_private.h \
|
||||
manual_addr_resolv.h \
|
||||
mcast_stream_dlg.h \
|
||||
old-gtk-compat.h \
|
||||
packet_history.h \
|
||||
packet_list_store.h \
|
||||
packet_list.h \
|
||||
packet_win.h \
|
||||
pixmap_save.h \
|
||||
plugins_dlg.h \
|
||||
prefs_capture.h \
|
||||
prefs_column.h \
|
||||
prefs_dlg.h \
|
||||
prefs_filter_expressions.h \
|
||||
prefs_gui.h \
|
||||
prefs_layout.h \
|
||||
prefs_font_color.h \
|
||||
profile_dlg.h \
|
||||
proto_dlg.h \
|
||||
proto_hier_stats_dlg.h \
|
||||
proto_hier_tree_model.h \
|
||||
proto_tree_model.h \
|
||||
range_utils.h \
|
||||
response_time_delay_table.h \
|
||||
rtp_player.h \
|
||||
rtp_stream_dlg.h \
|
||||
sctp_stat_gtk.h \
|
||||
service_response_time_table.h \
|
||||
simple_stattable.h \
|
||||
time_shift_dlg.h \
|
||||
simple_dialog.h \
|
||||
stock_icons.h \
|
||||
summary_dlg.h \
|
||||
supported_protos_dlg.h \
|
||||
tap_param_dlg.h \
|
||||
text_page_utils.h \
|
||||
uat_gui.h \
|
||||
voip_calls_dlg.h \
|
||||
webbrowser.h \
|
||||
$(WIRESHARK_CUSTOM_HDRS)
|
||||
|
||||
if HAVE_GRESOURCE_PIXBUF
|
||||
NODIST_GENERATED_FILES += \
|
||||
wireshark-gresources.h \
|
||||
wireshark-gresources.c
|
||||
else
|
||||
BUILD_PIXBUF_CSOURCE = \
|
||||
pixbuf-csource.h \
|
||||
pixbuf-csource.c
|
||||
endif
|
||||
|
||||
AM_CPPFLAGS = $(INCLUDEDIRS) $(WS_CPPFLAGS) $(GTK_CFLAGS) \
|
||||
$(PORTAUDIO_INCLUDES)
|
||||
|
||||
DISTCLEANFILES = \
|
||||
$(NODIST_GENERATED_FILES)
|
||||
|
||||
MAINTAINERCLEANFILES = \
|
||||
$(GENERATED_FILES)
|
||||
|
||||
EXTRA_DIST = \
|
||||
.editorconfig \
|
||||
$(GENERATOR_FILES) \
|
||||
airpcap_dlg.c \
|
||||
airpcap_dlg.h \
|
||||
airpcap_gui_utils.c \
|
||||
airpcap_gui_utils.h \
|
||||
capture_if_details_dlg_win32.c \
|
||||
capture_if_details_dlg_win32.h \
|
||||
CMakeLists.txt \
|
||||
doxygen.cfg.in \
|
||||
main_airpcap_toolbar.c \
|
||||
main_airpcap_toolbar.h \
|
||||
Makefile_custom.common \
|
||||
pixbuf-csource.c \
|
||||
pixbuf-csource.h
|
||||
|
||||
BUILT_SOURCES = \
|
||||
$(GENERATED_FILES) \
|
||||
$(NODIST_GENERATED_FILES)
|
||||
|
||||
noinst_LIBRARIES = libgtkui.a
|
||||
|
||||
libgtkui_a_SOURCES = \
|
||||
$(WIRESHARK_COMMON_GTK_SRC) \
|
||||
$(WIRESHARK_COMMON_GTK_HDRS) \
|
||||
$(WIRESHARK_TAP_SRC) \
|
||||
$(GENERATED_FILES)
|
||||
|
||||
nodist_libgtkui_a_SOURCES = \
|
||||
$(NODIST_GENERATED_FILES) \
|
||||
$(BUILD_PIXBUF_CSOURCE)
|
||||
|
||||
wireshark-tap-register.c: $(WIRESHARK_TAP_SRC) ../make-taps
|
||||
$(AM_V_GEN)../make-taps $@ $(filter %.c,$^)
|
||||
|
||||
wireshark-gresources.c: main.gresources.xml $(shell glib-compile-resources --sourcedir=$(top_srcdir) --generate-dependencies $(srcdir)/main.gresources.xml)
|
||||
@echo Making $@
|
||||
@glib-compile-resources --sourcedir=$(top_srcdir) --target=$@ --generate --manual-register $<
|
||||
|
||||
wireshark-gresources.h: main.gresources.xml
|
||||
@echo Making $@
|
||||
@glib-compile-resources --sourcedir=$(top_srcdir) --target=$@ --generate --manual-register $<
|
||||
|
||||
imagedir = $(top_srcdir)/image
|
||||
|
||||
pixbuf_csource_data = \
|
||||
expert_chat_pb_data \
|
||||
$(imagedir)/stock_icons/14x14/x-expert-chat.png \
|
||||
expert_error_pb_data \
|
||||
$(imagedir)/stock_icons/14x14/x-expert-error.png \
|
||||
expert_none_pb_data \
|
||||
$(imagedir)/stock_icons/14x14/x-expert-none.png \
|
||||
expert_note_pb_data \
|
||||
$(imagedir)/stock_icons/14x14/x-expert-note.png \
|
||||
expert_warn_pb_data \
|
||||
$(imagedir)/stock_icons/14x14/x-expert-warn.png \
|
||||
expert_ok_pb_data \
|
||||
$(imagedir)/expert_ok.png \
|
||||
capture_comment_add_pb_data \
|
||||
$(imagedir)/capture_comment_add.png \
|
||||
capture_comment_update_pb_data \
|
||||
$(imagedir)/capture_comment_update.png \
|
||||
capture_comment_disabled_pb_data \
|
||||
$(imagedir)/capture_comment_disabled.png \
|
||||
network_bluetooth_pb_data \
|
||||
$(imagedir)/toolbar/network_bluetooth_16.png \
|
||||
network_usb_pb_data \
|
||||
$(imagedir)/toolbar/network_usb_16.png \
|
||||
network_wired_pb_data \
|
||||
$(imagedir)/toolbar/network_wired_16.png \
|
||||
network_wireless_pb_data \
|
||||
$(imagedir)/toolbar/network_wireless_16.png \
|
||||
remote_arrow_pb_data \
|
||||
$(imagedir)/toolbar/remote_arrow_16.png \
|
||||
remote_globe_pb_data \
|
||||
$(imagedir)/toolbar/remote_globe_16.png \
|
||||
remote_sat_pb_data \
|
||||
$(imagedir)/toolbar/remote_sat_16.png \
|
||||
pipe_pb_data \
|
||||
$(imagedir)/toolbar/pipe_16.png \
|
||||
capture_interfaces_16_pb_data \
|
||||
$(imagedir)/toolbar/capture_interfaces_16.png \
|
||||
capture_interfaces_24_pb_data \
|
||||
$(imagedir)/toolbar/capture_interfaces_24.png \
|
||||
gnome_emblem_web_16_pb_data \
|
||||
$(imagedir)/toolbar/gnome_emblem_web_16.png \
|
||||
gnome_emblem_web_24_pb_data \
|
||||
$(imagedir)/toolbar/gnome_emblem_web_24.png \
|
||||
toolbar_wireshark_file_16_pb_data \
|
||||
$(imagedir)/stock_icons/16x16/x-capture-file-save.png \
|
||||
toolbar_wireshark_file_24_pb_data \
|
||||
$(imagedir)/stock_icons/24x24/x-capture-file-save.png \
|
||||
capture_options_alt1_16_pb_data \
|
||||
$(imagedir)/stock_icons/16x16/x-capture-options.png \
|
||||
capture_options_alt1_24_pb_data \
|
||||
$(imagedir)/stock_icons/24x24/x-capture-options.png \
|
||||
capture_restart_16_pb_data \
|
||||
$(imagedir)/stock_icons/16x16/x-capture-restart.png \
|
||||
capture_restart_24_pb_data \
|
||||
$(imagedir)/stock_icons/24x24/x-capture-restart.png \
|
||||
capture_start_16_pb_data \
|
||||
$(imagedir)/stock_icons/16x16/x-capture-start.png \
|
||||
capture_start_24_pb_data \
|
||||
$(imagedir)/stock_icons/24x24/x-capture-start.png \
|
||||
capture_stop_16_pb_data \
|
||||
$(imagedir)/stock_icons/16x16/x-capture-stop.png \
|
||||
capture_stop_24_pb_data \
|
||||
$(imagedir)/stock_icons/24x24/x-capture-stop.png \
|
||||
layout_1_pb_data \
|
||||
$(imagedir)/layout_1.png \
|
||||
layout_2_pb_data \
|
||||
$(imagedir)/layout_2.png \
|
||||
layout_3_pb_data \
|
||||
$(imagedir)/layout_3.png \
|
||||
layout_4_pb_data \
|
||||
$(imagedir)/layout_4.png \
|
||||
layout_5_pb_data \
|
||||
$(imagedir)/layout_5.png \
|
||||
layout_6_pb_data \
|
||||
$(imagedir)/layout_6.png \
|
||||
wsicon_16_pb_data \
|
||||
$(imagedir)/wsicon16.png \
|
||||
wsicon_24_pb_data \
|
||||
$(imagedir)/wsicon24.png \
|
||||
wsicon_32_pb_data \
|
||||
$(imagedir)/wsicon32.png \
|
||||
wsicon_48_pb_data \
|
||||
$(imagedir)/wsicon48.png \
|
||||
wsicon_64_pb_data \
|
||||
$(imagedir)/wsicon64.png \
|
||||
wsiconcap_16_pb_data \
|
||||
$(imagedir)/wsiconcap16.png \
|
||||
wsiconcap_24_pb_data \
|
||||
$(imagedir)/wsiconcap24.png \
|
||||
wsiconcap_32_pb_data \
|
||||
$(imagedir)/wsiconcap32.png \
|
||||
wsiconcap_48_pb_data \
|
||||
$(imagedir)/wsiconcap48.png \
|
||||
wsiconcap_64_pb_data \
|
||||
$(imagedir)/wsiconcap64.png \
|
||||
wssplash_pb_data \
|
||||
$(imagedir)/wssplash_dev.png
|
||||
|
||||
pixbuf-csource:
|
||||
$(PERL) $(top_srcdir)/tools/make-pixbuf-csource.pl $@ $(pixbuf_csource_data)
|
||||
|
||||
doxygen:
|
||||
if HAVE_DOXYGEN
|
||||
$(DOXYGEN) doxygen.cfg
|
||||
endif
|
||||
|
||||
checkapi: checkapi-base checkapi-todo
|
||||
|
||||
checkapi-base:
|
||||
$(PERL) $(top_srcdir)/tools/checkAPIs.pl -g deprecated-gtk -build \
|
||||
-sourcedir=$(srcdir) \
|
||||
$(WIRESHARK_CLEAN_LIBGTKUI_SRC) \
|
||||
capture_if_details_dlg_win32.c
|
||||
|
||||
checkapi-todo:
|
||||
$(PERL) $(top_srcdir)/tools/checkAPIs.pl -M -g deprecated-gtk-todo -build \
|
||||
-sourcedir=$(srcdir) \
|
||||
$(WIRESHARK_GTK_SRC) \
|
||||
$(WIRESHARK_TAP_SRC) \
|
||||
capture_if_details_dlg_win32.c
|
|
@ -1,12 +0,0 @@
|
|||
#
|
||||
# You can add custom GUI files here
|
||||
#
|
||||
|
||||
#Add GUI source files here
|
||||
WIRESHARK_CUSTOM_GTK_SRC =
|
||||
|
||||
#Add your tap source files here:
|
||||
WIRESHARK_CUSTOM_TAP_SRC =
|
||||
|
||||
#Add headers here:
|
||||
WIRESHARK_CUSTOM_HDRS =
|
|
@ -1,41 +0,0 @@
|
|||
Status of the GTK+ 3 port :
|
||||
===========================
|
||||
|
||||
The port is done. We used the methods described in the "Migrating from
|
||||
GTK+ 2.x to GTK+ 3" document at:
|
||||
http://developer.gnome.org/gtk3/stable/gtk-migrating-2-to-3.html
|
||||
|
||||
To build Wireshark with GTK3 instead of GTK2, use:
|
||||
|
||||
- cmake: ENABLE_GTK3=ON
|
||||
- configure: --with-gtk3
|
||||
This will only work if building without gtkvumeter.c (which is used on Windows
|
||||
only and only in the WLAN code). It also requires GTK3 to be installed.
|
||||
GTK3 for Windows (32 and 64 bit) is now available the same way as GTK2 for
|
||||
Windows: Via the svn repo for Wireshark for windows builds.
|
||||
|
||||
Except in one place we are building on GTK2 using the compat flags
|
||||
-DGTK_DISABLE_SINGLE_INCLUDES
|
||||
-DGSEAL_ENABLE
|
||||
-DGDK_DISABLE_DEPRECATED
|
||||
-DGTK_DISABLE_DEPRECATED
|
||||
|
||||
Summary: The only known files that cause some sort of problems (or lost
|
||||
functionality) are:
|
||||
- gtkvumeter.c (removed, only used for wlan on windows)
|
||||
- tcp-graph: the crosshairs are not right
|
||||
- audiograph doesn't work
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
March 11, 2013:
|
||||
|
||||
Various Gtk widgets (GtkTable, GtkColorSelection, ...) deprecated in versions
|
||||
of Gtk3 newer than Gtk 3.0.0 have been replaced as appropriate.
|
||||
|
||||
Wireshark Gtk3 builds with Gtk 3.6.4 without any "deprecated" warnings.
|
||||
|
||||
Fixes to handling of 'expand' in GTK3 have been completed.
|
||||
(Essentially: When adding a widget to a [V|H]Box, use gtk_box_pack_start()
|
||||
with appropriate args instead of gtk_container_add().
|
||||
|
|
@ -1,628 +0,0 @@
|
|||
/* about_dlg.c
|
||||
*
|
||||
* Ulf Lamping <ulf.lamping@web.de>
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <wsutil/filesystem.h>
|
||||
#include <wsutil/copyright_info.h>
|
||||
#include <version_info.h>
|
||||
#ifdef HAVE_LIBSMI
|
||||
#include <epan/oids.h>
|
||||
#endif
|
||||
#ifdef HAVE_GEOIP
|
||||
#include <epan/geoip_db.h>
|
||||
#endif
|
||||
#ifdef HAVE_LUA
|
||||
#include <epan/wslua/init_wslua.h>
|
||||
#endif
|
||||
#include "extcap.h"
|
||||
|
||||
#include "../../log.h"
|
||||
#include "epan/register.h"
|
||||
|
||||
#include "ui/last_open_dir.h"
|
||||
|
||||
#include "ui/gtk/about_dlg.h"
|
||||
#include "ui/gtk/gui_utils.h"
|
||||
#include "ui/gtk/dlg_utils.h"
|
||||
#include "ui/gtk/file_dlg.h"
|
||||
#include "ui/gtk/text_page_utils.h"
|
||||
#include "ui/gtk/gtkglobals.h"
|
||||
#include "ui/gtk/main.h"
|
||||
#include "ui/gtk/plugins_dlg.h"
|
||||
#include "ui/gtk/stock_icons.h"
|
||||
#ifndef HAVE_GDK_GRESOURCE
|
||||
#include "ui/gtk/pixbuf-csource.h"
|
||||
#endif
|
||||
|
||||
#include "webbrowser.h"
|
||||
|
||||
/*
|
||||
* Update frequence for the splash screen, given in milliseconds.
|
||||
*/
|
||||
int info_update_freq = 100;
|
||||
|
||||
static void about_wireshark_destroy_cb(GtkWidget *, gpointer);
|
||||
|
||||
|
||||
/*
|
||||
* Keep a static pointer to the current "About Wireshark" window, if any, so
|
||||
* that if somebody tries to do "About Wireshark" while there's already an
|
||||
* "About Wireshark" window up, we just pop up the existing one, rather than
|
||||
* creating a new one.
|
||||
*/
|
||||
static GtkWidget *about_wireshark_w;
|
||||
|
||||
|
||||
static void
|
||||
about_wireshark(GtkWidget *parent _U_, GtkWidget *main_vb)
|
||||
{
|
||||
GtkWidget *msg_label, *icon;
|
||||
gchar *message;
|
||||
const char *title = "Network Protocol Analyzer";
|
||||
|
||||
/*icon = xpm_to_widget_from_parent(parent, wssplash_xpm);*/
|
||||
#ifdef HAVE_GDK_GRESOURCE
|
||||
icon = pixbuf_to_widget("/org/wireshark/image/wssplash_dev.png");
|
||||
#else
|
||||
icon = pixbuf_to_widget(wssplash_pb_data);
|
||||
#endif
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(main_vb), icon, TRUE, TRUE, 0);
|
||||
|
||||
|
||||
msg_label = gtk_label_new(title);
|
||||
message = g_strdup_printf("<span size=\"x-large\" weight=\"bold\">%s</span>", title);
|
||||
gtk_label_set_markup(GTK_LABEL(msg_label), message);
|
||||
g_free(message);
|
||||
gtk_box_pack_start(GTK_BOX(main_vb), msg_label, TRUE, TRUE, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
splash_update_label(GtkWidget *win, const char *message)
|
||||
{
|
||||
GtkWidget *main_lb;
|
||||
|
||||
if (win == NULL) return;
|
||||
|
||||
main_lb = (GtkWidget *)g_object_get_data(G_OBJECT(win), "splash_label");
|
||||
gtk_label_set_text(GTK_LABEL(main_lb), message);
|
||||
|
||||
/* Process all pending GUI events before continuing, so that
|
||||
the splash screen window gets updated. */
|
||||
while (gtk_events_pending()) gtk_main_iteration();
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
splash_new(const char *message)
|
||||
{
|
||||
GtkWidget *win;
|
||||
GtkWidget *main_lb;
|
||||
|
||||
GtkWidget *main_box;
|
||||
GtkWidget *percentage_box;
|
||||
GtkWidget *prog_bar;
|
||||
GtkWidget *percentage_lb;
|
||||
|
||||
win = splash_window_new();
|
||||
|
||||
/* When calling about_wireshark(), we must realize the top-level
|
||||
widget for the window, otherwise GTK will throw a warning
|
||||
because we don't have a colormap associated with that window and
|
||||
can't handle the pixmap. */
|
||||
gtk_widget_realize(win);
|
||||
|
||||
main_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(main_box), 24);
|
||||
gtk_container_add(GTK_CONTAINER(win), main_box);
|
||||
|
||||
|
||||
about_wireshark(win, main_box);
|
||||
|
||||
main_lb = gtk_label_new(message);
|
||||
gtk_box_pack_start(GTK_BOX(main_box), main_lb, TRUE, TRUE, 0);
|
||||
g_object_set_data(G_OBJECT(win), "splash_label", main_lb);
|
||||
|
||||
main_lb = gtk_label_new("");
|
||||
gtk_box_pack_start(GTK_BOX(main_box), main_lb, TRUE, TRUE, 0);
|
||||
g_object_set_data(G_OBJECT(win), "protocol_label", main_lb);
|
||||
|
||||
percentage_box = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1, FALSE);
|
||||
gtk_box_pack_start(GTK_BOX(main_box), percentage_box, TRUE, TRUE, 3);
|
||||
|
||||
prog_bar = gtk_progress_bar_new();
|
||||
gtk_box_pack_start(GTK_BOX(percentage_box), prog_bar, TRUE, TRUE, 3);
|
||||
g_object_set_data(G_OBJECT(win), "progress_bar", prog_bar);
|
||||
|
||||
percentage_lb = gtk_label_new(" 0%");
|
||||
gtk_misc_set_alignment(GTK_MISC(percentage_lb), 0.0f, 0.0f);
|
||||
gtk_box_pack_start(GTK_BOX(percentage_box), percentage_lb, FALSE, TRUE, 3);
|
||||
g_object_set_data(G_OBJECT(win), "percentage_label", percentage_lb);
|
||||
|
||||
gtk_widget_show_all(win);
|
||||
|
||||
splash_update_label(win, message);
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
void
|
||||
splash_update(register_action_e action, const char *message, gpointer client_data)
|
||||
{
|
||||
GtkWidget *win;
|
||||
GtkWidget *main_lb;
|
||||
GtkWidget *prog_bar;
|
||||
GtkWidget *percentage_lb;
|
||||
gfloat percentage;
|
||||
gulong ul_percentage;
|
||||
gchar tmp[100];
|
||||
const char *action_msg;
|
||||
|
||||
static gulong ul_sofar = 0;
|
||||
static gulong ul_count = 0;
|
||||
|
||||
static register_action_e last_action = RA_NONE;
|
||||
|
||||
static GTimeVal cur_tv;
|
||||
static GTimeVal next_tv = {0, 0};
|
||||
|
||||
win = (GtkWidget *)client_data;
|
||||
|
||||
if (win == NULL) return;
|
||||
|
||||
g_get_current_time(&cur_tv);
|
||||
if (last_action == action && cur_tv.tv_sec <= next_tv.tv_sec && cur_tv.tv_usec <= next_tv.tv_usec && ul_sofar < ul_count - 1) {
|
||||
/* Only update every splash_register_freq milliseconds */
|
||||
ul_sofar++;
|
||||
return;
|
||||
}
|
||||
memcpy(&next_tv, &cur_tv, sizeof(next_tv));
|
||||
next_tv.tv_usec += info_update_freq * 1000;
|
||||
if (next_tv.tv_usec >= 1000000) {
|
||||
next_tv.tv_sec++;
|
||||
next_tv.tv_usec -= 1000000;
|
||||
}
|
||||
|
||||
if(last_action != action) {
|
||||
/* the action has changed */
|
||||
switch(action) {
|
||||
case RA_DISSECTORS:
|
||||
action_msg = "Initializing dissectors ...";
|
||||
break;
|
||||
case RA_LISTENERS:
|
||||
action_msg = "Initializing tap listeners ...";
|
||||
break;
|
||||
case RA_EXTCAP:
|
||||
action_msg = "Initializing extcap ...";
|
||||
break;
|
||||
case RA_REGISTER:
|
||||
action_msg = "Registering dissector ...";
|
||||
break;
|
||||
case RA_PLUGIN_REGISTER:
|
||||
action_msg = "Registering plugins ...";
|
||||
break;
|
||||
case RA_HANDOFF:
|
||||
action_msg = "Handing off dissector ...";
|
||||
break;
|
||||
case RA_PLUGIN_HANDOFF:
|
||||
action_msg = "Handing off plugins ...";
|
||||
break;
|
||||
case RA_LUA_PLUGINS:
|
||||
action_msg = "Loading Lua plugins ...";
|
||||
break;
|
||||
case RA_PREFERENCES:
|
||||
action_msg = "Loading module preferences ...";
|
||||
break;
|
||||
case RA_INTERFACES:
|
||||
action_msg = "Finding local interfaces ...";
|
||||
break;
|
||||
default:
|
||||
action_msg = "(Unknown action)";
|
||||
break;
|
||||
}
|
||||
splash_update_label(win, action_msg);
|
||||
last_action = action;
|
||||
}
|
||||
|
||||
if(ul_count == 0) { /* get the count of dissectors */
|
||||
ul_count = register_count() + 6; /* additional 6 for:
|
||||
dissectors, listeners,
|
||||
registering plugins, handingoff plugins,
|
||||
preferences, and interfaces */
|
||||
#ifdef HAVE_LUA
|
||||
ul_count += wslua_count_plugins (); /* get count of lua plugins */
|
||||
#endif
|
||||
ul_count += extcap_count() + 1; /* Count of extcap binaries + registration message */
|
||||
}
|
||||
|
||||
main_lb = (GtkWidget *)g_object_get_data(G_OBJECT(win), "protocol_label");
|
||||
/* make_dissector_reg.py changed -
|
||||
so we need to strip off the leading elements to get back to the protocol */
|
||||
if(message) {
|
||||
if(!strncmp(message, "proto_register_", 15))
|
||||
message += 15;
|
||||
else if(!strncmp(message, "proto_reg_handoff_", 18))
|
||||
message += 18;
|
||||
}
|
||||
gtk_label_set_text(GTK_LABEL(main_lb), message ? message : "");
|
||||
|
||||
ul_sofar++;
|
||||
|
||||
g_assert (ul_sofar <= ul_count);
|
||||
|
||||
percentage = (gfloat)ul_sofar/(gfloat)ul_count;
|
||||
ul_percentage = (gulong)(percentage * 100);
|
||||
|
||||
/* update progress bar */
|
||||
prog_bar = (GtkWidget *)g_object_get_data(G_OBJECT(win), "progress_bar");
|
||||
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(prog_bar), percentage);
|
||||
|
||||
percentage_lb = (GtkWidget *)g_object_get_data(G_OBJECT(win), "percentage_label");
|
||||
g_snprintf(tmp, sizeof(tmp), "%lu%%", ul_percentage);
|
||||
gtk_label_set_text((GtkLabel*)percentage_lb, tmp);
|
||||
|
||||
/* Process all pending GUI events before continuing, so that
|
||||
the splash screen window gets updated. */
|
||||
while (gtk_events_pending()) gtk_main_iteration();
|
||||
|
||||
}
|
||||
|
||||
gboolean
|
||||
splash_destroy(GtkWidget *win)
|
||||
{
|
||||
if (win == NULL)
|
||||
return FALSE;
|
||||
|
||||
gtk_widget_destroy(win);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
about_wireshark_page_new(void)
|
||||
{
|
||||
GtkWidget *main_box, *msg_label /*, *icon*/;
|
||||
gchar *message;
|
||||
GString *comp_info_str, *runtime_info_str;
|
||||
|
||||
main_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(main_box), 12);
|
||||
|
||||
g_object_set(gtk_widget_get_settings(main_box),
|
||||
"gtk-label-select-on-focus", FALSE, NULL);
|
||||
|
||||
about_wireshark(top_level, main_box);
|
||||
|
||||
comp_info_str = get_compiled_version_info(get_wireshark_gtk_compiled_info,
|
||||
get_gui_compiled_info);
|
||||
runtime_info_str = get_runtime_version_info(get_wireshark_runtime_info);
|
||||
|
||||
/* Construct the message string */
|
||||
message = g_strdup_printf(
|
||||
"Version %s\n"
|
||||
"\n"
|
||||
"%s"
|
||||
"\n"
|
||||
"%s"
|
||||
"\n"
|
||||
"%s"
|
||||
"\n"
|
||||
"Wireshark is Open Source Software released under the GNU General Public License.\n"
|
||||
"\n"
|
||||
"Check the man page and http://www.wireshark.org for more information.",
|
||||
get_ws_vcs_version_info(), get_copyright_info(), comp_info_str->str,
|
||||
runtime_info_str->str);
|
||||
|
||||
msg_label = gtk_label_new(message);
|
||||
g_free(message);
|
||||
gtk_label_set_justify(GTK_LABEL(msg_label), GTK_JUSTIFY_FILL);
|
||||
gtk_label_set_selectable(GTK_LABEL(msg_label), TRUE);
|
||||
gtk_box_pack_start(GTK_BOX (main_box), msg_label, TRUE, TRUE, 0);
|
||||
|
||||
|
||||
return main_box;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
about_authors_page_new(void)
|
||||
{
|
||||
GtkWidget *page;
|
||||
char *absolute_path;
|
||||
|
||||
absolute_path = get_datafile_path("AUTHORS-SHORT");
|
||||
page = text_page_new(absolute_path);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
static gboolean about_folders_callback(GtkWidget *widget, GdkEventButton *event, gint id _U_)
|
||||
{
|
||||
GtkTreeSelection *tree_selection;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
gchar *path;
|
||||
|
||||
tree_selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
|
||||
|
||||
if(gtk_tree_selection_count_selected_rows(tree_selection) == 0)
|
||||
return FALSE;
|
||||
|
||||
if(event->type != GDK_2BUTTON_PRESS)
|
||||
/* not a double click */
|
||||
return FALSE;
|
||||
|
||||
if(gtk_tree_selection_get_selected (tree_selection, &model, &iter)) {
|
||||
gtk_tree_model_get(model, &iter, 1, &path, -1);
|
||||
filemanager_open_directory(path);
|
||||
g_free(path);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
about_folders_row(GtkWidget *table, const char *label, const char *dir, const char *tip)
|
||||
{
|
||||
simple_list_append(table, 0, label, 1, dir, 2, tip, -1);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
about_folders_page_new(void)
|
||||
{
|
||||
GtkWidget *table;
|
||||
const char *constpath;
|
||||
char *path;
|
||||
static const gchar *titles[] = { "Name", "Folder", "Typical Files"};
|
||||
GtkWidget *scrolledwindow;
|
||||
gint i;
|
||||
gchar **resultArray;
|
||||
#if 0
|
||||
const gchar *const *dirs;
|
||||
#endif
|
||||
|
||||
scrolledwindow = scrolled_window_new(NULL, NULL);
|
||||
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow),
|
||||
GTK_SHADOW_IN);
|
||||
|
||||
/* Container for our data */
|
||||
table = simple_list_new(3, titles);
|
||||
|
||||
/* connect a callback so we can spot a double-click */
|
||||
g_signal_connect(table, "button_press_event",
|
||||
G_CALLBACK(about_folders_callback), NULL);
|
||||
|
||||
simple_list_url_col(table, 1);
|
||||
|
||||
/* "file open" */
|
||||
about_folders_row(table, "\"File\" dialogs", get_last_open_dir(),
|
||||
"capture files");
|
||||
|
||||
/* temp */
|
||||
about_folders_row(table, "Temp", g_get_tmp_dir(),
|
||||
"untitled capture files");
|
||||
|
||||
/* pers conf */
|
||||
path = get_persconffile_path("", FALSE);
|
||||
about_folders_row(table, "Personal configuration", path,
|
||||
"\"dfilters\", \"preferences\", \"ethers\", ...");
|
||||
g_free(path);
|
||||
|
||||
/* global conf */
|
||||
constpath = get_datafile_dir();
|
||||
if (constpath != NULL) {
|
||||
about_folders_row(table, "Global configuration", constpath,
|
||||
"\"dfilters\", \"preferences\", \"manuf\", ...");
|
||||
}
|
||||
#if 0
|
||||
dirs = g_get_system_data_dirs ();
|
||||
for (i = 0; dirs[i]; i++){
|
||||
g_warning("glibs data path %u %s",i+1,dirs[i]);
|
||||
}
|
||||
#endif
|
||||
/* system */
|
||||
constpath = get_systemfile_dir();
|
||||
about_folders_row(table, "System", constpath,
|
||||
"\"ethers\", \"ipxnets\"");
|
||||
|
||||
/* program */
|
||||
constpath = get_progfile_dir();
|
||||
about_folders_row(table, "Program", constpath,
|
||||
"program files");
|
||||
|
||||
#ifdef HAVE_PLUGINS
|
||||
/* pers plugins */
|
||||
about_folders_row(table, "Personal Plugins", get_plugins_pers_dir_with_version(),
|
||||
"binary plugins");
|
||||
|
||||
/* global plugins */
|
||||
about_folders_row(table, "Global Plugins", get_plugins_dir_with_version(),
|
||||
"binary plugins");
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LUA
|
||||
/* pers plugins */
|
||||
about_folders_row(table, "Personal Lua Plugins", get_plugins_pers_dir(),
|
||||
"lua scripts");
|
||||
|
||||
/* global plugins */
|
||||
about_folders_row(table, "Global Lua Plugins", get_plugins_dir(),
|
||||
"lua scripts");
|
||||
#endif
|
||||
|
||||
/* extcap */
|
||||
constpath = get_extcap_dir();
|
||||
|
||||
resultArray = g_strsplit(constpath, G_SEARCHPATH_SEPARATOR_S, 10);
|
||||
|
||||
for(i = 0; resultArray[i]; i++)
|
||||
about_folders_row(table, "Extcap path", g_strstrip(resultArray[i]),
|
||||
"Extcap Plugins search path");
|
||||
g_strfreev(resultArray);
|
||||
|
||||
#ifdef HAVE_GEOIP
|
||||
/* GeoIP */
|
||||
path = geoip_db_get_paths();
|
||||
|
||||
resultArray = g_strsplit(path, G_SEARCHPATH_SEPARATOR_S, 10);
|
||||
|
||||
for(i = 0; resultArray[i]; i++)
|
||||
about_folders_row(table, "GeoIP path", g_strstrip(resultArray[i]),
|
||||
"GeoIP database search path");
|
||||
g_strfreev(resultArray);
|
||||
g_free(path);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBSMI
|
||||
/* SMI MIBs/PIBs */
|
||||
path = oid_get_default_mib_path();
|
||||
|
||||
resultArray = g_strsplit(path, G_SEARCHPATH_SEPARATOR_S, 20);
|
||||
|
||||
for(i = 0; resultArray[i]; i++)
|
||||
about_folders_row(table, "MIB/PIB path", g_strstrip(resultArray[i]),
|
||||
"SMI MIB/PIB search path");
|
||||
g_strfreev(resultArray);
|
||||
g_free(path);
|
||||
#endif
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(scrolledwindow), table);
|
||||
|
||||
return scrolledwindow;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
about_license_page_new(void)
|
||||
{
|
||||
GtkWidget *page;
|
||||
char *absolute_path;
|
||||
|
||||
#if defined(_WIN32)
|
||||
absolute_path = get_datafile_path("COPYING.txt");
|
||||
#else
|
||||
absolute_path = get_datafile_path("COPYING");
|
||||
#endif
|
||||
page = text_page_new(absolute_path);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
void
|
||||
about_wireshark_cb( GtkWidget *w _U_, gpointer data _U_ )
|
||||
{
|
||||
GtkWidget *main_box, *main_nb, *bbox, *ok_btn;
|
||||
GtkWidget *page_lb, *about_page, *folders_page;
|
||||
|
||||
#if defined(HAVE_PLUGINS) || defined(HAVE_LUA)
|
||||
GtkWidget *plugins_page;
|
||||
#endif
|
||||
|
||||
GtkWidget *authors_page, *license_page;
|
||||
|
||||
if (about_wireshark_w != NULL) {
|
||||
/* There's already an "About Wireshark" dialog box; reactivate it. */
|
||||
reactivate_window(about_wireshark_w);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX - use GtkDialog? The GNOME 2.x GnomeAbout widget does.
|
||||
* Should we use GtkDialog for simple_dialog() as well? Or
|
||||
* is the GTK+ 2.x GtkDialog appropriate but the 1.2[.x] one
|
||||
* not? (The GNOME 1.x GnomeAbout widget uses GnomeDialog.)
|
||||
*/
|
||||
about_wireshark_w = dlg_window_new("About Wireshark");
|
||||
/* set the initial position (must be done, before show is called!) */
|
||||
/* default position is not appropriate for the about dialog */
|
||||
gtk_window_set_position(GTK_WINDOW(about_wireshark_w), GTK_WIN_POS_CENTER_ON_PARENT);
|
||||
gtk_window_set_default_size(GTK_WINDOW(about_wireshark_w), 600, 400);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(about_wireshark_w), 6);
|
||||
|
||||
main_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 12, FALSE);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(main_box), 6);
|
||||
gtk_container_add(GTK_CONTAINER(about_wireshark_w), main_box);
|
||||
|
||||
main_nb = gtk_notebook_new();
|
||||
gtk_box_pack_start(GTK_BOX(main_box), main_nb, TRUE, TRUE, 0);
|
||||
|
||||
about_page = about_wireshark_page_new();
|
||||
page_lb = gtk_label_new("Wireshark");
|
||||
gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), about_page, page_lb);
|
||||
|
||||
authors_page = about_authors_page_new();
|
||||
page_lb = gtk_label_new("Authors");
|
||||
gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), authors_page, page_lb);
|
||||
|
||||
folders_page = about_folders_page_new();
|
||||
page_lb = gtk_label_new("Folders");
|
||||
gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), folders_page, page_lb);
|
||||
|
||||
#if defined(HAVE_PLUGINS) || defined(HAVE_LUA)
|
||||
plugins_page = about_plugins_page_new();
|
||||
page_lb = gtk_label_new("Plugins");
|
||||
gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), plugins_page, page_lb);
|
||||
#endif
|
||||
|
||||
license_page = about_license_page_new();
|
||||
page_lb = gtk_label_new("License");
|
||||
/* set a minmum width to avoid a lot of line breaks at the wrong places */
|
||||
gtk_widget_set_size_request(license_page, 600, -1);
|
||||
gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), license_page, page_lb);
|
||||
|
||||
/* Button row */
|
||||
bbox = dlg_button_row_new(GTK_STOCK_OK, NULL);
|
||||
gtk_box_pack_start(GTK_BOX(main_box), bbox, FALSE, FALSE, 0);
|
||||
|
||||
ok_btn = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
|
||||
gtk_widget_grab_focus(ok_btn);
|
||||
gtk_widget_grab_default(ok_btn);
|
||||
window_set_cancel_button(about_wireshark_w, ok_btn, window_cancel_button_cb);
|
||||
|
||||
g_signal_connect(about_wireshark_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
||||
g_signal_connect(about_wireshark_w, "destroy", G_CALLBACK(about_wireshark_destroy_cb), NULL);
|
||||
|
||||
gtk_widget_show_all(about_wireshark_w);
|
||||
window_present(about_wireshark_w);
|
||||
}
|
||||
|
||||
static void
|
||||
about_wireshark_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
|
||||
{
|
||||
/* Note that we no longer have an "About Wireshark" dialog box. */
|
||||
about_wireshark_w = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local Variables:
|
||||
* c-basic-offset: 2
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=2 tabstop=8 expandtab:
|
||||
* :indentSize=2:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -1,61 +0,0 @@
|
|||
/* about_dlg.h
|
||||
* Declarations of routines for the "About" dialog
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __ABOUT_DLG_H__
|
||||
#define __ABOUT_DLG_H__
|
||||
|
||||
/** @file
|
||||
* "About" dialog box.
|
||||
* @ingroup dialog_group
|
||||
*/
|
||||
|
||||
/** Create a splash screen showed when Wireshark is started.
|
||||
*
|
||||
* @param message the new message to be displayed
|
||||
* @return the newly created window handle
|
||||
*/
|
||||
extern GtkWidget *splash_new(const char *message);
|
||||
|
||||
/** Update the splash screen message when loading dissectors and handoffs
|
||||
*
|
||||
* @param action the initialisation action being performed
|
||||
* @param message additional information
|
||||
* @param call_data the window handle from splash_new()
|
||||
*/
|
||||
extern void splash_update(register_action_e action, const char *message, void *call_data);
|
||||
|
||||
/** Destroy the splash screen.
|
||||
*
|
||||
* @param win the window handle from splash_new()
|
||||
* @return always FALSE, so this function can be used as a callback for gtk_timeout_add()
|
||||
*/
|
||||
extern gboolean splash_destroy(GtkWidget *win);
|
||||
|
||||
/** User requested the "About" dialog box by menu or toolbar.
|
||||
*
|
||||
* @param widget parent widget (unused)
|
||||
* @param data unused
|
||||
*/
|
||||
extern void about_wireshark_cb( GtkWidget *widget, gpointer data);
|
||||
|
||||
|
||||
#endif /* __ABOUT_DLG_H__ */
|
|
@ -1,344 +0,0 @@
|
|||
/* addr_resolution_dlg.c
|
||||
* Show current address resolution as a hosts file
|
||||
*
|
||||
* Copyright 2012 Anders Broman <anders.broman@ericsson.com>
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <epan/addr_resolv.h>
|
||||
#include <epan/wmem/wmem.h>
|
||||
|
||||
#include "ui/gtk/dlg_utils.h"
|
||||
#include "ui/gtk/font_utils.h"
|
||||
#include "ui/gtk/gui_utils.h"
|
||||
#include "ui/gtk/main.h"
|
||||
#include "ui/gtk/addr_resolution_dlg.h"
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
static GtkWidget *addr_resolution_dlg_w = NULL;
|
||||
|
||||
|
||||
#define ADDRESS_STR_MAX 1024
|
||||
|
||||
static void
|
||||
eth_hash_to_texbuff(gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
gchar string_buff[ADDRESS_STR_MAX];
|
||||
GtkTextBuffer *buffer = (GtkTextBuffer*)user_data;
|
||||
guint8 *eth_addr = (guint8*)key;
|
||||
hashether_t* tp = (hashether_t*)value;
|
||||
|
||||
g_snprintf(string_buff, ADDRESS_STR_MAX, "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X Status: %u %s %s\n",
|
||||
eth_addr[0], eth_addr[1], eth_addr[2],
|
||||
eth_addr[3], eth_addr[4], eth_addr[5],
|
||||
get_hash_ether_status(tp),
|
||||
get_hash_ether_hexaddr(tp),
|
||||
get_hash_ether_resolved_name(tp));
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
|
||||
}
|
||||
static void
|
||||
manuf_hash_to_texbuff(gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
gchar string_buff[ADDRESS_STR_MAX];
|
||||
GtkTextBuffer *buffer = (GtkTextBuffer*)user_data;
|
||||
hashmanuf_t *manuf = (hashmanuf_t*)value;
|
||||
int eth_as_gint = *(int*)key;
|
||||
|
||||
g_snprintf(string_buff, ADDRESS_STR_MAX, "%.2X:%.2X:%.2X %s\n",eth_as_gint>>16, (eth_as_gint>>8)&0xff, eth_as_gint&0xff, get_hash_manuf_resolved_name(manuf));
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
wka_hash_to_texbuff(gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
gchar string_buff[ADDRESS_STR_MAX];
|
||||
GtkTextBuffer *buffer = (GtkTextBuffer*)user_data;
|
||||
gchar *name = (gchar *)value;
|
||||
guint8 *eth_addr = (guint8*)key;
|
||||
|
||||
g_snprintf(string_buff, ADDRESS_STR_MAX, "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X %s\n",
|
||||
eth_addr[0], eth_addr[1], eth_addr[2],
|
||||
eth_addr[3], eth_addr[4], eth_addr[5],
|
||||
name);
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
serv_port_hash_to_texbuff(gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
gchar string_buff[ADDRESS_STR_MAX];
|
||||
GtkTextBuffer *buffer = (GtkTextBuffer*)user_data;
|
||||
serv_port_t *serv_port_table = (serv_port_t *)value;
|
||||
int port = *(int*)key;
|
||||
|
||||
g_snprintf(string_buff, ADDRESS_STR_MAX, "Port %u \n"" TCP %s\n"" UDP %s\n"" SCTP %s\n"" DCCP %s\n",
|
||||
port,
|
||||
serv_port_table->tcp_name,
|
||||
serv_port_table->udp_name,
|
||||
serv_port_table->sctp_name,
|
||||
serv_port_table->dccp_name);
|
||||
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
ipv4_hash_table_to_texbuff(gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
gchar string_buff[ADDRESS_STR_MAX];
|
||||
GtkTextBuffer *buffer = (GtkTextBuffer*)user_data;
|
||||
hashipv4_t *ipv4_hash_table_entry = (hashipv4_t *)value;
|
||||
int addr = GPOINTER_TO_UINT(key);
|
||||
|
||||
g_snprintf(string_buff, ADDRESS_STR_MAX, "Key:0x%x IP: %s, Name: %s\n",
|
||||
addr,
|
||||
ipv4_hash_table_entry->ip,
|
||||
ipv4_hash_table_entry->name);
|
||||
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
ipv4_hash_table_resolved_to_texbuff(gpointer key _U_, gpointer value, gpointer user_data)
|
||||
{
|
||||
gchar string_buff[ADDRESS_STR_MAX];
|
||||
GtkTextBuffer *buffer = (GtkTextBuffer*)user_data;
|
||||
hashipv4_t *ipv4_hash_table_entry = (hashipv4_t *)value;
|
||||
|
||||
if((ipv4_hash_table_entry->flags & NAME_RESOLVED)){
|
||||
g_snprintf(string_buff, ADDRESS_STR_MAX, "%s\t%s\n",
|
||||
ipv4_hash_table_entry->ip,
|
||||
ipv4_hash_table_entry->name);
|
||||
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
ipv6_hash_table_to_texbuff(gpointer key _U_, gpointer value, gpointer user_data)
|
||||
{
|
||||
gchar string_buff[ADDRESS_STR_MAX];
|
||||
GtkTextBuffer *buffer = (GtkTextBuffer*)user_data;
|
||||
hashipv6_t *ipv6_hash_table_entry = (hashipv6_t *)value;
|
||||
|
||||
g_snprintf(string_buff, ADDRESS_STR_MAX, "IP: %s, Name: %s\n",
|
||||
ipv6_hash_table_entry->ip6,
|
||||
ipv6_hash_table_entry->name);
|
||||
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
ipv6_hash_table_resolved_to_texbuff(gpointer key _U_, gpointer value, gpointer user_data)
|
||||
{
|
||||
gchar string_buff[ADDRESS_STR_MAX];
|
||||
GtkTextBuffer *buffer = (GtkTextBuffer*)user_data;
|
||||
hashipv6_t *ipv6_hash_table_entry = (hashipv6_t *)value;
|
||||
|
||||
if((ipv6_hash_table_entry->flags & NAME_RESOLVED)){
|
||||
g_snprintf(string_buff, ADDRESS_STR_MAX, "%s\t%s\n",
|
||||
ipv6_hash_table_entry->ip6,
|
||||
ipv6_hash_table_entry->name);
|
||||
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
addres_resolution_to_texbuff(GtkTextBuffer *buffer)
|
||||
{
|
||||
gchar string_buff[ADDRESS_STR_MAX];
|
||||
wmem_map_t *manuf_hashtable;
|
||||
wmem_map_t *wka_hashtable;
|
||||
wmem_map_t *eth_hashtable;
|
||||
wmem_map_t *serv_port_hashtable;
|
||||
wmem_map_t *ipv4_hash_table;
|
||||
wmem_map_t *ipv6_hash_table;
|
||||
|
||||
g_snprintf(string_buff, ADDRESS_STR_MAX, "# Hosts information in Wireshark \n#\n");
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
g_snprintf(string_buff, ADDRESS_STR_MAX, "# Host data gathered from %s\n\n", cfile.filename);
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
|
||||
/* Dump the v4 addresses first, then v6 */
|
||||
ipv4_hash_table = get_ipv4_hash_table();
|
||||
if(ipv4_hash_table){
|
||||
wmem_map_foreach( ipv4_hash_table, ipv4_hash_table_resolved_to_texbuff, buffer);
|
||||
}
|
||||
|
||||
ipv6_hash_table = get_ipv6_hash_table();
|
||||
if(ipv6_hash_table){
|
||||
wmem_map_foreach( ipv6_hash_table, ipv6_hash_table_resolved_to_texbuff, buffer);
|
||||
}
|
||||
|
||||
g_snprintf(string_buff, ADDRESS_STR_MAX, "\n\n# Address resolution IPv4 Hash table \n#\n");
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
|
||||
if(ipv4_hash_table){
|
||||
g_snprintf(string_buff, ADDRESS_STR_MAX, "# With %i entries\n#\n", wmem_map_size(ipv4_hash_table));
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
wmem_map_foreach( ipv4_hash_table, ipv4_hash_table_to_texbuff, buffer);
|
||||
}
|
||||
|
||||
g_snprintf(string_buff, ADDRESS_STR_MAX, "\n\n# Address resolution IPv6 Hash table \n#\n");
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
|
||||
if(ipv6_hash_table){
|
||||
g_snprintf(string_buff, ADDRESS_STR_MAX, "# With %i entries\n#\n", wmem_map_size(ipv6_hash_table));
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
wmem_map_foreach( ipv6_hash_table, ipv6_hash_table_to_texbuff, buffer);
|
||||
}
|
||||
|
||||
|
||||
g_snprintf(string_buff, ADDRESS_STR_MAX, "\n\n# Port names information in Wireshark \n#\n");
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
|
||||
serv_port_hashtable = get_serv_port_hashtable();
|
||||
if(serv_port_hashtable){
|
||||
g_snprintf(string_buff, ADDRESS_STR_MAX, "# With %i entries\n#\n", wmem_map_size(serv_port_hashtable));
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
wmem_map_foreach( serv_port_hashtable, serv_port_hash_to_texbuff, buffer);
|
||||
}
|
||||
|
||||
g_snprintf(string_buff, ADDRESS_STR_MAX, "\n\n# Eth names information in Wireshark \n#\n");
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
|
||||
eth_hashtable = get_eth_hashtable();
|
||||
if(eth_hashtable){
|
||||
g_snprintf(string_buff, ADDRESS_STR_MAX, "# With %i entries\n#\n", wmem_map_size(eth_hashtable));
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
wmem_map_foreach( eth_hashtable, eth_hash_to_texbuff, buffer);
|
||||
}
|
||||
|
||||
g_snprintf(string_buff, ADDRESS_STR_MAX, "\n\n# Manuf information in Wireshark \n#\n");
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
|
||||
manuf_hashtable = get_manuf_hashtable();
|
||||
if(manuf_hashtable){
|
||||
g_snprintf(string_buff, ADDRESS_STR_MAX, "# With %i entries\n#\n", wmem_map_size(manuf_hashtable));
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
wmem_map_foreach( manuf_hashtable, manuf_hash_to_texbuff, buffer);
|
||||
}
|
||||
|
||||
g_snprintf(string_buff, ADDRESS_STR_MAX, "\n\n# wka information in Wireshark \n#\n");
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
|
||||
wka_hashtable = get_wka_hashtable();
|
||||
if(wka_hashtable){
|
||||
g_snprintf(string_buff, ADDRESS_STR_MAX, "# With %i entries\n#\n", wmem_map_size(wka_hashtable));
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
wmem_map_foreach( wka_hashtable, wka_hash_to_texbuff, buffer);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
addr_resolution_dlg (GtkAction *action _U_, gpointer data _U_)
|
||||
{
|
||||
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *view;
|
||||
GtkWidget *scroll;
|
||||
GtkWidget *bbox;
|
||||
GtkWidget *ok_bt, *cancel_bt, *help_bt;
|
||||
GtkTextBuffer *buffer;
|
||||
|
||||
addr_resolution_dlg_w = dlg_window_new ("Address Resolution");
|
||||
gtk_widget_set_size_request (addr_resolution_dlg_w, 750, 350);
|
||||
gtk_window_set_resizable (GTK_WINDOW (addr_resolution_dlg_w), TRUE);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (addr_resolution_dlg_w), DLG_OUTER_MARGIN);
|
||||
|
||||
vbox = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, DLG_UNRELATED_SPACING, FALSE);
|
||||
gtk_container_add (GTK_CONTAINER (addr_resolution_dlg_w), vbox);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
view = gtk_text_view_new ();
|
||||
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_WORD);
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
gtk_widget_override_font(view, user_font_get_regular());
|
||||
#else
|
||||
gtk_widget_modify_font(view, user_font_get_regular());
|
||||
#endif
|
||||
gtk_widget_show (view);
|
||||
|
||||
scroll = gtk_scrolled_window_new(NULL, NULL);
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
|
||||
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
||||
gtk_container_add(GTK_CONTAINER(scroll), view);
|
||||
gtk_widget_show(scroll);
|
||||
gtk_box_pack_start(GTK_BOX (vbox), scroll, TRUE, TRUE, 0);
|
||||
|
||||
/* Get the address list */
|
||||
addres_resolution_to_texbuff(buffer);
|
||||
|
||||
/* Button row. */
|
||||
bbox = dlg_button_row_new (GTK_STOCK_OK, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
|
||||
gtk_box_pack_end (GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
|
||||
|
||||
ok_bt = (GtkWidget *)g_object_get_data (G_OBJECT(bbox), GTK_STOCK_OK);
|
||||
g_signal_connect(ok_bt, "clicked", G_CALLBACK(window_cancel_button_cb), addr_resolution_dlg_w); /* act as cxl */
|
||||
gtk_widget_set_sensitive (ok_bt, TRUE);
|
||||
|
||||
cancel_bt = (GtkWidget *)g_object_get_data (G_OBJECT(bbox), GTK_STOCK_CANCEL);
|
||||
window_set_cancel_button (addr_resolution_dlg_w, cancel_bt, window_cancel_button_cb);
|
||||
|
||||
help_bt = (GtkWidget *)g_object_get_data (G_OBJECT(bbox), GTK_STOCK_HELP);
|
||||
#if 0
|
||||
g_signal_connect (help_bt, "clicked",/* G_CALLBACK(topic_cb)*/NULL, /*(gpointer)HELP_MANUAL_ADDR_RESOLVE_DIALOG*/NULL);
|
||||
#endif
|
||||
gtk_widget_set_sensitive (help_bt, FALSE);
|
||||
|
||||
gtk_widget_grab_default (ok_bt);
|
||||
/*g_signal_connect (addr_resolution_dlg_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);*/
|
||||
|
||||
|
||||
gtk_widget_show (addr_resolution_dlg_w);
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines
|
||||
*
|
||||
* Local Variables:
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* ex: set shiftwidth=4 tabstop=8 expandtab:
|
||||
* :indentSize=4:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -1,28 +0,0 @@
|
|||
/* addr_resolution_dlg.h
|
||||
* Show current addres resolution as a hosts file
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __ADDR_RESOLUTION_DLG_H__
|
||||
#define __ADDR_RESOLUTION_DLG_H__
|
||||
|
||||
void addr_resolution_dlg (GtkAction *action, gpointer data);
|
||||
|
||||
#endif /* __ADDR_RESOLUTION_DLG_H__ */
|
2697
ui/gtk/airpcap_dlg.c
2697
ui/gtk/airpcap_dlg.c
File diff suppressed because it is too large
Load Diff
|
@ -1,63 +0,0 @@
|
|||
/* airpcap_dlg.h
|
||||
* Declarations of routines for the "Airpcap" dialog
|
||||
*
|
||||
* Giorgio Tino <giorgio.tino@cacetech.com>
|
||||
* Copyright (c) CACE Technologies, LLC 2006
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __AIRPCAP_DLG_H__
|
||||
#define __AIRPCAP_DLG_H__
|
||||
|
||||
#define AIRPCAP_ADVANCED_FROM_TOOLBAR 0
|
||||
#define AIRPCAP_ADVANCED_FROM_OPTIONS 1
|
||||
|
||||
/*
|
||||
* Creates the list of available decryption modes, depending on the adapters found
|
||||
*/
|
||||
void update_decryption_mode_list(GtkWidget *w);
|
||||
|
||||
/*
|
||||
* Selects the current decryption mode in the given combo box
|
||||
*/
|
||||
void update_decryption_mode(GtkWidget *w);
|
||||
|
||||
/*
|
||||
* Turns the decryption on or off
|
||||
*/
|
||||
void on_decryption_mode_cb_changed(GtkWidget *w, gpointer data _U_);
|
||||
|
||||
/** Create a "Airpcap" dialog box caused by a button click.
|
||||
*
|
||||
* @param widget parent widget
|
||||
* @param construct_args_ptr parameters to construct the dialog (construct_args_t)
|
||||
*/
|
||||
void display_airpcap_advanced_cb(GtkWidget *widget, gpointer construct_args_ptr);
|
||||
|
||||
/* Called to create the key management window */
|
||||
void display_airpcap_key_management_cb(GtkWidget *w, gpointer data);
|
||||
|
||||
/**/
|
||||
/*
|
||||
* Dialog box that appears whenever keys are not consistent between wieshark and airpcap
|
||||
*/
|
||||
void airpcap_keys_check_w(GtkWidget *w, gpointer data);
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -1,305 +0,0 @@
|
|||
/* airpcap_utils.h
|
||||
* Declarations of utility routines for the "Airpcap" dialog widgets
|
||||
*
|
||||
* Giorgio Tino <giorgio.tino@cacetech.com>
|
||||
* Copyright (c) CACE Technologies, LLC 2006
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __AIRPCAP_GUI_UTILS_H__
|
||||
#define __AIRPCAP_GUI_UTILS_H__
|
||||
|
||||
#define AIRPCAP_VALIDATION_TYPE_NAME_ALL "All Frames"
|
||||
#define AIRPCAP_VALIDATION_TYPE_NAME_CORRECT "Valid Frames"
|
||||
#define AIRPCAP_VALIDATION_TYPE_NAME_CORRUPT "Invalid Frames"
|
||||
#define AIRPCAP_VALIDATION_TYPE_NAME_UNKNOWN "Unknown"
|
||||
|
||||
#define AIRPCAP_LINK_TYPE_NAME_802_11_ONLY "802.11 Only"
|
||||
#define AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_RADIO "802.11 + Radio"
|
||||
#define AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_PPI "802.11 + PPI"
|
||||
#define AIRPCAP_LINK_TYPE_NAME_UNKNOWN "Unknown"
|
||||
|
||||
#define AIRPCAP_LINK_TYPE_NUM_802_11_ONLY 0
|
||||
#define AIRPCAP_LINK_TYPE_NUM_802_11_PLUS_RADIO 1
|
||||
#define AIRPCAP_LINK_TYPE_NUM_802_11_PLUS_PPI 2
|
||||
|
||||
#define AIRPCAP_DECRYPTION_TYPE_STRING_WIRESHARK "Wireshark"
|
||||
#define AIRPCAP_DECRYPTION_TYPE_STRING_AIRPCAP "Driver"
|
||||
#define AIRPCAP_DECRYPTION_TYPE_STRING_NONE "None"
|
||||
|
||||
/* Key list columns */
|
||||
enum {
|
||||
KL_COL_TYPE,
|
||||
KL_COL_KEY,
|
||||
KL_COL_SSID,
|
||||
KL_NUM_COLS
|
||||
};
|
||||
|
||||
/* Controls the releay of settings back to the adapter. */
|
||||
extern gboolean change_airpcap_settings;
|
||||
|
||||
/*
|
||||
* set up the airpcap toolbar for the new capture interface
|
||||
*/
|
||||
void
|
||||
airpcap_set_toolbar_start_capture(airpcap_if_info_t* if_info);
|
||||
|
||||
/*
|
||||
* Set up the airpcap toolbar for the new capture interface
|
||||
*/
|
||||
void
|
||||
airpcap_set_toolbar_stop_capture(airpcap_if_info_t* if_info);
|
||||
|
||||
/*
|
||||
* Add a key (string) to the given list
|
||||
*/
|
||||
void
|
||||
airpcap_add_key_to_list(GtkListStore *key_list_store, gchar* type, gchar* key, gchar* ssid);
|
||||
|
||||
/*
|
||||
* Fill the list with the keys
|
||||
*/
|
||||
void
|
||||
airpcap_fill_key_list(GtkListStore *key_list_store);
|
||||
|
||||
/*
|
||||
* Function used to retrieve the AirpcapValidationType given the string name.
|
||||
*/
|
||||
AirpcapValidationType
|
||||
airpcap_get_validation_type(const gchar* name);
|
||||
|
||||
/*
|
||||
* Function used to retrieve the string name given an AirpcapValidationType.
|
||||
*/
|
||||
const gchar*
|
||||
airpcap_get_validation_name(AirpcapValidationType vt);
|
||||
|
||||
/*
|
||||
* Return an appropriate combo box entry number for the given an AirpcapValidationType.
|
||||
*/
|
||||
gint
|
||||
airpcap_get_validation_combo_entry(AirpcapValidationType vt);
|
||||
|
||||
/*
|
||||
* Returns the AirpcapLinkType corresponding to the given string name.
|
||||
*/
|
||||
AirpcapLinkType
|
||||
airpcap_get_link_type(const gchar* name);
|
||||
|
||||
/*
|
||||
* Returns the string name corresponding to the given AirpcapLinkType.
|
||||
*/
|
||||
const gchar*
|
||||
airpcap_get_link_name(AirpcapLinkType lt);
|
||||
|
||||
/*
|
||||
* Sets the entry of the validation combo using the AirpcapValidationType.
|
||||
*/
|
||||
void
|
||||
airpcap_validation_type_combo_set_by_type(GtkWidget* c,AirpcapValidationType type);
|
||||
|
||||
/*
|
||||
* Update channel offset combo box to 'offset'.
|
||||
*/
|
||||
void
|
||||
airpcap_update_channel_offset_combo(airpcap_if_info_t* if_info, guint32 ch_freq, GtkWidget *channel_offset_cb, gboolean set);
|
||||
|
||||
|
||||
/*
|
||||
* Retrieve the guint corresponding to the given string (channel only, handle with care!)
|
||||
*/
|
||||
gchar*
|
||||
airpcap_get_channel_name(guint n);
|
||||
|
||||
/*
|
||||
* Set the combo box entry string given an guint channel number
|
||||
*/
|
||||
void
|
||||
airpcap_channel_combo_set_by_frequency(GtkWidget* w,guint channel);
|
||||
|
||||
/** Respond to the user changing the channel combo box.
|
||||
* Update the active interface channel and update the offset
|
||||
* combo box.
|
||||
* Requires AirPcap globals.
|
||||
*
|
||||
* @param channel_cb The channel GtkComboBox
|
||||
* @param channel_offset_cb The channel offset GtkComboBox
|
||||
*/
|
||||
void
|
||||
airpcap_channel_changed_set_cb(GtkWidget *channel_cb, gpointer channel_offset_cb);
|
||||
|
||||
/** Respond to the user changing the channel combo box.
|
||||
* Update the offset combo box but not the channel.
|
||||
* Requires AirPcap globals.
|
||||
*
|
||||
* @param channel_cb The channel GtkComboBox
|
||||
* @param channel_offset_cb The channel offset GtkComboBox
|
||||
*/
|
||||
void
|
||||
airpcap_channel_changed_noset_cb(GtkWidget *channel_cb, gpointer channel_offset_cb);
|
||||
|
||||
/** Respond to the user changing the channel offset combo box.
|
||||
* Update the active interface channel offset.
|
||||
* Requires AirPcap globals.
|
||||
*
|
||||
* @param channel_offset_cb The channel offset GtkComboBox
|
||||
* @param data Unused
|
||||
*/
|
||||
void
|
||||
airpcap_channel_offset_changed_cb(GtkWidget *channel_offset_cb, gpointer data);
|
||||
|
||||
/*
|
||||
* Returns '1' if this is the "Any" adapter, '0' otherwise
|
||||
*/
|
||||
int
|
||||
airpcap_if_is_any(airpcap_if_info_t* if_info);
|
||||
|
||||
/*
|
||||
* Update channel combo box. If the airpcap interface is "Any", the combo box will be disabled.
|
||||
*/
|
||||
void
|
||||
airpcap_update_channel_combo(GtkWidget* channel_cb, airpcap_if_info_t* if_info);
|
||||
|
||||
/*
|
||||
* This function will take the current keys (widget list), specified for the
|
||||
* current adapter, and save them as default for ALL the others.
|
||||
*/
|
||||
void
|
||||
airpcap_read_and_save_decryption_keys_from_list_store(GtkListStore* key_list_store, airpcap_if_info_t* info_if, GList* if_list);
|
||||
|
||||
/*
|
||||
* This function will load from the preferences file ALL the
|
||||
* keys (WEP, WPA and WPA_BIN) and will set them as default for
|
||||
* each adapter. To do this, it will save the keys in the registry...
|
||||
*/
|
||||
void
|
||||
airpcap_load_decryption_keys(GList* if_list);
|
||||
|
||||
/*
|
||||
* This function will load from the preferences file ALL the
|
||||
* keys (WEP, WPA and WPA_BIN) and will set them as default for
|
||||
* each adapter. To do this, it will save the keys in the registry...
|
||||
*/
|
||||
gboolean
|
||||
airpcap_check_decryption_keys(GList* if_list);
|
||||
|
||||
/*
|
||||
* This function will set the gibven GList of decryption_key_t structures
|
||||
* as the defoult for both Wireshark and the AirPcap adapters...
|
||||
*/
|
||||
void
|
||||
airpcap_save_decryption_keys(GList* key_list, GList* adapters_list);
|
||||
|
||||
/*
|
||||
* This function is used to enable/disable the toolbar widgets
|
||||
* depending on the type of interface selected...
|
||||
*/
|
||||
void
|
||||
airpcap_enable_toolbar_widgets(GtkWidget* w, gboolean en);
|
||||
|
||||
/*
|
||||
* Returns the default airpcap interface of a list, NULL if list is empty
|
||||
*/
|
||||
airpcap_if_info_t*
|
||||
airpcap_get_default_if(GList* airpcap_if_list);
|
||||
|
||||
/*
|
||||
* DECRYPTION KEYS FUNCTIONS
|
||||
*/
|
||||
|
||||
/*
|
||||
* Retrieves a GList of decryption_key_t structures containing infos about the
|
||||
* keys for the given adapter... returns NULL if no keys are found.
|
||||
*/
|
||||
GList*
|
||||
get_airpcap_device_keys(airpcap_if_info_t* if_info);
|
||||
|
||||
/*
|
||||
* Retrieves a GList of decryption_key_t structures containing infos about the
|
||||
* keys for the global AirPcap driver... returns NULL if no keys are found.
|
||||
*/
|
||||
GList*
|
||||
get_airpcap_driver_keys(void);
|
||||
|
||||
/*
|
||||
* Returns the list of the decryption keys specified for wireshark, NULL if
|
||||
* no key is found
|
||||
*/
|
||||
GList*
|
||||
get_wireshark_keys(void);
|
||||
|
||||
/*
|
||||
* Tests if two collection of keys are equal or not, to be considered equals, they have to
|
||||
* contain the same keys in the SAME ORDER! (If both lists are NULL, which means empty will
|
||||
* return TRUE)
|
||||
*/
|
||||
gboolean
|
||||
key_lists_are_equal(GList* list1, GList* list2);
|
||||
|
||||
/*
|
||||
* Merges two lists of keys. If a key is found multiple times, it will just appear once!
|
||||
*/
|
||||
GList*
|
||||
merge_key_list(GList* list1, GList* list2);
|
||||
|
||||
/*
|
||||
* If the given key is contained in the list, returns TRUE.
|
||||
* Returns FALSE otherwise.
|
||||
*/
|
||||
gboolean
|
||||
key_is_in_list(decryption_key_t *dk,GList *list);
|
||||
|
||||
/*
|
||||
* Returns TRUE if keys are equals, FALSE otherwise
|
||||
*/
|
||||
gboolean
|
||||
keys_are_equals(decryption_key_t *k1,decryption_key_t *k2);
|
||||
|
||||
/*
|
||||
* Use this function to free a key list.
|
||||
*/
|
||||
void
|
||||
free_key_list(GList *list);
|
||||
|
||||
/*
|
||||
* Returns TRUE if the Wireshark decryption is active, FALSE otherwise
|
||||
*/
|
||||
gboolean
|
||||
wireshark_decryption_on(void);
|
||||
|
||||
/*
|
||||
* Returns TRUE if the AirPcap decryption for the current adapter is active, FALSE otherwise
|
||||
*/
|
||||
gboolean
|
||||
airpcap_decryption_on(void);
|
||||
|
||||
/*
|
||||
* Enables decryption for Wireshark if on_off is TRUE, disables it otherwise.
|
||||
*/
|
||||
void
|
||||
set_wireshark_decryption(gboolean on_off);
|
||||
|
||||
/*
|
||||
* Enables decryption for all the adapters if on_off is TRUE, disables it otherwise.
|
||||
*/
|
||||
gboolean
|
||||
set_airpcap_decryption(gboolean on_off);
|
||||
|
||||
#endif
|
1499
ui/gtk/bytes_view.c
1499
ui/gtk/bytes_view.c
File diff suppressed because it is too large
Load Diff
|
@ -1,51 +0,0 @@
|
|||
/* bytes_view.h
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*/
|
||||
|
||||
#ifndef __BYTES_VIEW_H__
|
||||
#define __BYTES_VIEW_H__
|
||||
|
||||
#define BYTES_VIEW_TYPE (bytes_view_get_type())
|
||||
#define BYTES_VIEW(object) (G_TYPE_CHECK_INSTANCE_CAST((object), BYTES_VIEW_TYPE, BytesView))
|
||||
|
||||
#define BYTE_VIEW_HIGHLIGHT_APPENDIX 1
|
||||
#define BYTE_VIEW_HIGHLIGHT_PROTOCOL 2
|
||||
|
||||
typedef struct _BytesView BytesView;
|
||||
|
||||
GType bytes_view_get_type(void);
|
||||
|
||||
GtkWidget *bytes_view_new(void);
|
||||
void bytes_view_set_font(BytesView *bv, PangoFontDescription *font);
|
||||
|
||||
void bytes_view_set_data(BytesView *bv, const guint8 *data, int len);
|
||||
void bytes_view_set_encoding(BytesView *bv, packet_char_enc enc);
|
||||
void bytes_view_set_format(BytesView *bv, int format);
|
||||
void bytes_view_set_highlight_style(BytesView *bv, gboolean bold);
|
||||
|
||||
void bytes_view_set_highlight(BytesView *bv, int start, int end, guint64 mask, int maskle);
|
||||
void bytes_view_set_highlight_extra(BytesView *bv, int id, int start, int end);
|
||||
|
||||
void bytes_view_refresh(BytesView *bv);
|
||||
int bytes_view_byte_from_xy(BytesView *bv, int x, int y);
|
||||
void bytes_view_scroll_to_byte(BytesView *bv, int byte);
|
||||
|
||||
#endif /* __BYTES_VIEW_H__ */
|
6243
ui/gtk/capture_dlg.c
6243
ui/gtk/capture_dlg.c
File diff suppressed because it is too large
Load Diff
|
@ -1,109 +0,0 @@
|
|||
/* capture_dlg.h
|
||||
* Definitions for the "Capture Options" dialog and dialog windows popped
|
||||
* up from it
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __CAPTURE_DLG_H__
|
||||
#define __CAPTURE_DLG_H__
|
||||
|
||||
/* extern GtkWidget* wireless_tb; */
|
||||
|
||||
/** @file
|
||||
* "Capture Options" dialog box.
|
||||
* @ingroup dialog_group
|
||||
*/
|
||||
#include "capture_opts.h"
|
||||
#include <gtk/gtk.h>
|
||||
#include "ws_attributes.h"
|
||||
|
||||
#define CR_MAIN_NB "compile_results_main_notebook"
|
||||
|
||||
/** Initialize background capture filter syntax checking
|
||||
*/
|
||||
void capture_filter_init(void);
|
||||
|
||||
/** User requested the "Capture Options" dialog box by menu or toolbar.
|
||||
*
|
||||
* @param widget parent widget (unused)
|
||||
* @param data unused
|
||||
*/
|
||||
void capture_prep_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
/** User requested capture start by menu or toolbar.
|
||||
*
|
||||
* @param widget parent widget (unused)
|
||||
* @param data unused
|
||||
*/
|
||||
void capture_start_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
/** User requested capture stop by menu or toolbar.
|
||||
*
|
||||
* @param widget parent widget (unused)
|
||||
* @param data unused
|
||||
*/
|
||||
void capture_stop_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
/** User requested capture restart by menu or toolbar.
|
||||
*
|
||||
* @param widget parent widget (unused)
|
||||
* @param data unused
|
||||
*/
|
||||
void capture_restart_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
/** User requested the "Capture Airpcap" dialog box by menu or toolbar.
|
||||
*
|
||||
* @param widget parent widget (unused)
|
||||
* @param data unused
|
||||
*/
|
||||
void
|
||||
capture_air_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
gboolean
|
||||
capture_dlg_window_present(void);
|
||||
|
||||
void
|
||||
enable_selected_interface(gchar *name, gboolean selected);
|
||||
|
||||
void
|
||||
options_interface_cb(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *column _U_, gpointer userdata);
|
||||
|
||||
void
|
||||
capture_dlg_refresh_if(void);
|
||||
|
||||
void
|
||||
update_visible_columns_menu (void);
|
||||
|
||||
void
|
||||
update_visible_tree_view_columns(void);
|
||||
|
||||
/*
|
||||
* Refresh everything visible that shows an interface list that
|
||||
* includes local interfaces.
|
||||
*/
|
||||
extern void refresh_local_interface_lists(void);
|
||||
|
||||
/*
|
||||
* Refresh everything visible that shows an interface list that
|
||||
* includes non-local interfaces.
|
||||
*/
|
||||
extern void refresh_non_local_interface_lists(void);
|
||||
|
||||
#endif /* capture_dlg.h */
|
File diff suppressed because it is too large
Load Diff
|
@ -1,117 +0,0 @@
|
|||
/* capture_file_dlg.h
|
||||
* Definitions for dialog boxes for handling files
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __CAPTURE_FILE_DLG_H__
|
||||
#define __CAPTURE_FILE_DLG_H__
|
||||
|
||||
#include "cfile.h"
|
||||
|
||||
/** @file
|
||||
* "Open" / "Close" / "Save" / "Save As" / etc dialog boxes.
|
||||
* @ingroup dialog_group
|
||||
*/
|
||||
|
||||
/** If there are unsaved changes, ask the user whether to save them,
|
||||
* discard them, or cancel the operation that would cause the changes
|
||||
* to be lost if not saved.
|
||||
*
|
||||
* @param cf the capture_file structure for the file to be closed
|
||||
* @param from_quit TRUE if this is from a quit operation
|
||||
* @param before_what description of the operation, or a null string
|
||||
* for an explicit close operation
|
||||
*
|
||||
* @return TRUE if the user didn't cancel the operation, FALSE if they did
|
||||
*/
|
||||
gboolean do_file_close(capture_file *cf, gboolean from_quit, const char *before_what);
|
||||
|
||||
/** User requested the "Open" dialog box.
|
||||
*
|
||||
* @param widget parent widget
|
||||
* @param data unused
|
||||
*/
|
||||
void file_open_cmd_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
/** User requested the "Merge" dialog box.
|
||||
*
|
||||
* @param widget parent widget
|
||||
* @param data unused
|
||||
*/
|
||||
void file_merge_cmd_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
/** User requested the "Save" dialog box.
|
||||
*
|
||||
* @param widget parent widget
|
||||
* @param data unused
|
||||
*/
|
||||
void file_save_cmd_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
/** User requested the "Save As" dialog box.
|
||||
*
|
||||
* @param widget parent widget
|
||||
* @param data unused
|
||||
*/
|
||||
void file_save_as_cmd_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
/** User requested "Close".
|
||||
*
|
||||
* @param widget parent widget
|
||||
* @param data unused
|
||||
*/
|
||||
void file_close_cmd_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
/** User requested the "Export Specified Packets" dialog box.
|
||||
*
|
||||
* @param widget parent widget
|
||||
* @param data unused
|
||||
*/
|
||||
void file_export_specified_packets_cmd_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
/** User requested the "Export PDUs to file" dialogue box
|
||||
* and pressed OK to start the export
|
||||
*
|
||||
* @param widget parent widget
|
||||
* @param data pointer to internal data used by the export pdu part
|
||||
*/
|
||||
void file_export_pdu_ok_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
/** User requested "Reload".
|
||||
*
|
||||
* @param widget parent widget
|
||||
* @param data unused
|
||||
*/
|
||||
void file_reload_cmd_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
/** User requested "Import". Currently only called from the color dialog.
|
||||
*
|
||||
* @param widget parent widget
|
||||
* @param data unused
|
||||
*/
|
||||
void file_color_import_cmd_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
/** User requested "Export". Currently only called from the color dialog.
|
||||
*
|
||||
* @param widget parent widget
|
||||
* @param data unused
|
||||
*/
|
||||
void file_color_export_cmd_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
#endif /* capture_file_dlg.h */
|
File diff suppressed because it is too large
Load Diff
|
@ -1,43 +0,0 @@
|
|||
/* capture_if_details_dlg.h
|
||||
* Definitions for capture interface details window (only Win32!)
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __CAPTURE_IF_DETAILS_DLG_H__
|
||||
#define __CAPTURE_IF_DETAILS_DLG_H__
|
||||
|
||||
/** @file
|
||||
* Capture "Interface Details" dialog box
|
||||
* @ingroup dialog_group
|
||||
*/
|
||||
|
||||
/** Open the dialog box.
|
||||
*
|
||||
* @param iface the interface name to show
|
||||
*/
|
||||
extern void capture_if_details_open(char *iface);
|
||||
|
||||
/** See if we have a detail-able interface.
|
||||
*
|
||||
* @param iface the interface name to test
|
||||
*/
|
||||
extern gboolean capture_if_has_details(char *iface);
|
||||
|
||||
#endif /* __CAPTURE_IF_DETAILS_DLG_H__ */
|
|
@ -1,978 +0,0 @@
|
|||
/* capture_if_dlg.c
|
||||
* Routines for the capture interface dialog
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "ws_attributes.h"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#ifdef HAVE_LIBPCAP
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <epan/prefs.h>
|
||||
#include <epan/to_str.h>
|
||||
|
||||
#include "../../capture_opts.h"
|
||||
#include <capchild/capture_session.h>
|
||||
#include "caputils/capture_ifinfo.h"
|
||||
#include "ui/capture.h"
|
||||
#include "caputils/capture-pcap-util.h"
|
||||
#include "wsutil/file_util.h"
|
||||
#include <wiretap/wtap.h>
|
||||
|
||||
#include "ui/capture_ui_utils.h"
|
||||
#include "ui/capture_globals.h"
|
||||
#include "ui/recent.h"
|
||||
#include "ui/simple_dialog.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "ui/gtk/capture_if_details_dlg_win32.h"
|
||||
#include "caputils/capture-wpcap.h"
|
||||
#endif
|
||||
|
||||
#include "ui/gtk/stock_icons.h"
|
||||
#ifndef HAVE_GDK_GRESOURCE
|
||||
#include "ui/gtk/pixbuf-csource.h"
|
||||
#endif
|
||||
#include "ui/gtk/capture_dlg.h"
|
||||
#include "ui/gtk/capture_if_dlg.h"
|
||||
#include "ui/gtk/gui_utils.h"
|
||||
#include "ui/gtk/dlg_utils.h"
|
||||
#include "ui/gtk/main.h"
|
||||
#include "ui/gtk/main_toolbar.h"
|
||||
#include "ui/gtk/help_dlg.h"
|
||||
#include "ui/gtk/keys.h"
|
||||
#include "ui/gtk/webbrowser.h"
|
||||
#include "ui/gtk/main_welcome.h"
|
||||
|
||||
#include "ui/gtk/old-gtk-compat.h"
|
||||
|
||||
#ifdef HAVE_AIRPCAP
|
||||
#include "../../image/toolbar/capture_airpcap_16.xpm"
|
||||
#endif
|
||||
|
||||
#include "../../image/toolbar/modem_16.xpm"
|
||||
|
||||
#include "../../image/toolbar/network_virtual_16.xpm"
|
||||
|
||||
/* new buttons to be used instead of labels for 'Capture','Prepare',' */
|
||||
/*#include "../../image/toolbar/capture_capture_16.xpm"*/
|
||||
/*#include "../../image/toolbar/capture_prepare_16.xpm"*/
|
||||
/*#include "../../image/toolbar/capture_details_16.xpm"*/
|
||||
|
||||
|
||||
#ifdef HAVE_AIRPCAP
|
||||
#include <caputils/airpcap.h>
|
||||
#include <caputils/airpcap_loader.h>
|
||||
#include "airpcap_gui_utils.h"
|
||||
#include "airpcap_dlg.h"
|
||||
#endif
|
||||
|
||||
#define CAPTURE_IF_IP_ADDR_LABEL "capture_if_ip_addr_label"
|
||||
#define CAPTURE_IF_SELECTED_IP_ADDR "capture_if_selected_ip_addr"
|
||||
#define SOFT_LABEL_LEN 50
|
||||
|
||||
/*
|
||||
* Keep a static pointer to the current "Capture Interfaces" window, if
|
||||
* any, so that if somebody tries to do "Capture:Start" while there's
|
||||
* already a "Capture Interfaces" window up, we just pop up the existing
|
||||
* one, rather than creating a new one.
|
||||
*/
|
||||
static GtkWidget *cap_if_w;
|
||||
|
||||
static guint timer_id;
|
||||
|
||||
static GtkWidget *close_bt, *stop_bt, *capture_bt, *options_bt;
|
||||
|
||||
static GArray *if_array;
|
||||
|
||||
static if_stat_cache_t *sc;
|
||||
static GtkWidget *cap_if_top_vb, *cap_if_sw;
|
||||
|
||||
/* the "runtime" data of one interface */
|
||||
typedef struct if_dlg_data_s {
|
||||
gchar *device;
|
||||
GtkWidget *device_lb;
|
||||
GtkWidget *descr_lb;
|
||||
GtkWidget *ip_lb;
|
||||
GtkWidget *curr_lb;
|
||||
GtkWidget *last_lb;
|
||||
GtkWidget *choose_bt;
|
||||
#ifdef _WIN32
|
||||
GtkWidget *details_bt;
|
||||
#endif
|
||||
gboolean hidden;
|
||||
} if_dlg_data_t;
|
||||
|
||||
static gboolean gbl_capture_in_progress = FALSE;
|
||||
|
||||
#if 0
|
||||
void
|
||||
add_interface(void)
|
||||
{
|
||||
if_dlg_data_t data;
|
||||
|
||||
data.device_lb = NULL;
|
||||
data.descr_lb = NULL;
|
||||
data.ip_lb = NULL;
|
||||
data.curr_lb = NULL;
|
||||
data.last_lb = NULL;
|
||||
data.choose_bt = NULL;
|
||||
#ifdef _WIN32
|
||||
data.details_bt = NULL;
|
||||
#endif
|
||||
data.hidden = FALSE;
|
||||
g_array_append_val(if_array, data);
|
||||
refresh_if_window();
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
update_selected_interface(gchar *name)
|
||||
{
|
||||
guint i;
|
||||
interface_t device;
|
||||
if_dlg_data_t data;
|
||||
|
||||
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
||||
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
|
||||
data = g_array_index(if_array, if_dlg_data_t, i);
|
||||
if (strcmp(name, device.name) == 0) {
|
||||
gtk_toggle_button_set_active((GtkToggleButton *)data.choose_bt, device.selected);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
store_selected(GtkWidget *choose_bt, gpointer name)
|
||||
{
|
||||
interface_t device;
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
||||
device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
|
||||
if (strcmp((char *)name, device.if_info.name) == 0) {
|
||||
device.selected ^= 1;
|
||||
if (device.selected) {
|
||||
global_capture_opts.num_selected++;
|
||||
} else {
|
||||
global_capture_opts.num_selected--;
|
||||
}
|
||||
global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
|
||||
g_array_insert_val(global_capture_opts.all_ifaces, i, device);
|
||||
if (gtk_widget_is_focus(choose_bt) && get_welcome_window()) {
|
||||
change_interface_selection(device.name, device.selected);
|
||||
}
|
||||
if (gtk_widget_is_focus(choose_bt) && capture_dlg_window_present()) {
|
||||
enable_selected_interface(device.name, device.selected);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cap_if_w) {
|
||||
gtk_widget_set_sensitive(capture_bt, !gbl_capture_in_progress && (global_capture_opts.num_selected > 0));
|
||||
}
|
||||
}
|
||||
|
||||
/* start capture button was pressed */
|
||||
static void
|
||||
capture_do_cb(GtkWidget *capture_bt_arg _U_, gpointer if_data _U_)
|
||||
{
|
||||
if_dlg_data_t data;
|
||||
guint ifs;
|
||||
|
||||
for (ifs = 0; ifs < if_array->len; ifs++) {
|
||||
data = g_array_index(if_array, if_dlg_data_t, ifs);
|
||||
if (data.hidden) {
|
||||
continue;
|
||||
}
|
||||
gtk_widget_set_sensitive(data.choose_bt, FALSE);
|
||||
if_array = g_array_remove_index(if_array, ifs);
|
||||
g_array_insert_val(if_array, ifs, data);
|
||||
#ifdef HAVE_AIRPCAP
|
||||
airpcap_if_active = get_airpcap_if_from_name(g_airpcap_if_list, gtk_label_get_text(GTK_LABEL(data.device_lb)));
|
||||
airpcap_if_selected = airpcap_if_active;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* XXX - remove this? */
|
||||
if (global_capture_opts.save_file) {
|
||||
g_free(global_capture_opts.save_file);
|
||||
global_capture_opts.save_file = NULL;
|
||||
}
|
||||
|
||||
if (global_capture_opts.ifaces->len > 1) {
|
||||
global_capture_opts.use_pcapng = TRUE;
|
||||
}
|
||||
/* stop capturing from all interfaces, we are going to do real work now ... */
|
||||
window_destroy(cap_if_w);
|
||||
|
||||
capture_start_cb(NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
/* prepare capture button was pressed */
|
||||
static void
|
||||
capture_prepare_cb(GtkWidget *prepare_bt _U_, gpointer if_data _U_)
|
||||
{
|
||||
/* stop capturing from all interfaces, we are going to do real work now ... */
|
||||
window_destroy(cap_if_w);
|
||||
if (global_capture_opts.ifaces->len > 1) {
|
||||
global_capture_opts.use_pcapng = TRUE;
|
||||
}
|
||||
capture_prep_cb(NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
/* capture details button was pressed */
|
||||
static void
|
||||
capture_details_cb(GtkWidget *details_bt _U_, gpointer name)
|
||||
{
|
||||
capture_if_details_open(name);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* update a single interface */
|
||||
static void
|
||||
update_if(gchar *name, if_stat_cache_t *sc_p)
|
||||
{
|
||||
struct pcap_stat stats;
|
||||
gchar *str;
|
||||
guint diff, ifs, data_ifs;
|
||||
interface_t device;
|
||||
if_dlg_data_t data;
|
||||
gboolean found = FALSE;
|
||||
|
||||
|
||||
/*
|
||||
* Note that some versions of libpcap, on some versions of UN*X,
|
||||
* pcap_stats() returns the number of packets since the last
|
||||
* pcap_stats call.
|
||||
*
|
||||
* That's a bug, and should be fixed; "pcap_stats()" is supposed
|
||||
* to work the same way on all platforms.
|
||||
*/
|
||||
device.last_packets = 0;
|
||||
data.curr_lb = NULL;
|
||||
data.last_lb = NULL;
|
||||
if (sc_p) {
|
||||
for (ifs = 0, data_ifs = 0; ifs < global_capture_opts.all_ifaces->len; ifs++) {
|
||||
device = g_array_index(global_capture_opts.all_ifaces, interface_t, ifs);
|
||||
if (device.type != IF_PIPE) {
|
||||
data = g_array_index(if_array, if_dlg_data_t, data_ifs++);
|
||||
if (!device.hidden && strcmp(name, device.name) == 0) {
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
if (capture_stats(sc_p, name, &stats)) {
|
||||
if ((int)(stats.ps_recv - device.last_packets) < 0) {
|
||||
diff = 0;
|
||||
} else {
|
||||
diff = stats.ps_recv - device.last_packets;
|
||||
}
|
||||
device.last_packets = stats.ps_recv;
|
||||
|
||||
str = g_strdup_printf("%u", device.last_packets);
|
||||
gtk_label_set_text(GTK_LABEL(data.curr_lb), str);
|
||||
g_free(str);
|
||||
str = g_strdup_printf("%u", diff);
|
||||
gtk_label_set_text(GTK_LABEL(data.last_lb), str);
|
||||
g_free(str);
|
||||
|
||||
gtk_widget_set_sensitive(data.curr_lb, diff);
|
||||
gtk_widget_set_sensitive(data.last_lb, diff);
|
||||
} else {
|
||||
gtk_label_set_text(GTK_LABEL(data.curr_lb), "error");
|
||||
gtk_label_set_text(GTK_LABEL(data.last_lb), "error");
|
||||
}
|
||||
global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, ifs);
|
||||
g_array_insert_val(global_capture_opts.all_ifaces, ifs, device);
|
||||
if_array = g_array_remove_index(if_array, ifs);
|
||||
g_array_insert_val(if_array, ifs, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* update all interfaces */
|
||||
static gboolean
|
||||
update_all(gpointer data)
|
||||
{
|
||||
interface_t device;
|
||||
guint ifs;
|
||||
if_stat_cache_t *sc_p = (if_stat_cache_t *)data;
|
||||
|
||||
if (!cap_if_w) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (ifs = 0; ifs < global_capture_opts.all_ifaces->len; ifs++) {
|
||||
device = g_array_index(global_capture_opts.all_ifaces, interface_t, ifs);
|
||||
update_if(device.name, sc_p);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* a live capture has started or stopped */
|
||||
void
|
||||
set_capture_if_dialog_for_capture_in_progress(gboolean capture_in_progress)
|
||||
{
|
||||
gbl_capture_in_progress = capture_in_progress;
|
||||
if (cap_if_w) {
|
||||
gtk_widget_set_sensitive(stop_bt, capture_in_progress);
|
||||
gtk_widget_set_sensitive(capture_bt, !capture_in_progress && (global_capture_opts.num_selected > 0));
|
||||
}
|
||||
}
|
||||
|
||||
/* a live capture is being stopped */
|
||||
void
|
||||
set_capture_if_dialog_for_capture_stopping(void)
|
||||
{
|
||||
if (cap_if_w) {
|
||||
gtk_widget_set_sensitive(stop_bt, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* the window was closed, cleanup things */
|
||||
static void
|
||||
capture_if_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
|
||||
{
|
||||
g_source_remove(timer_id);
|
||||
|
||||
if (sc) {
|
||||
capture_stat_stop(sc);
|
||||
sc = NULL;
|
||||
}
|
||||
window_destroy(GTK_WIDGET(cap_if_w));
|
||||
/* Note that we no longer have a "Capture Options" dialog box. */
|
||||
cap_if_w = NULL;
|
||||
cap_if_top_vb = NULL;
|
||||
cap_if_sw = NULL;
|
||||
#ifdef HAVE_AIRPCAP
|
||||
if (airpcap_if_active)
|
||||
airpcap_set_toolbar_stop_capture(airpcap_if_active);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Used to retrieve the interface icon.
|
||||
*/
|
||||
GtkWidget * capture_get_if_icon(interface_t *device)
|
||||
{
|
||||
#ifdef HAVE_PCAP_REMOTE
|
||||
if (!device->local) {
|
||||
return PIXBUF_TO_WIDGET(remote_sat_pb_data, "/org/wireshark/image/toolbar/remote_sat_16.png");
|
||||
}
|
||||
#endif
|
||||
if (device->display_name && strstr(device->display_name,"Wi-Fi") != NULL) {
|
||||
return PIXBUF_TO_WIDGET(network_wireless_pb_data, "/org/wireshark/image/toolbar/network_wireless_16.png");
|
||||
}
|
||||
switch (device->type) {
|
||||
case IF_DIALUP:
|
||||
return xpm_to_widget(modem_16_xpm);
|
||||
case IF_WIRELESS:
|
||||
return PIXBUF_TO_WIDGET(network_wireless_pb_data, "/org/wireshark/image/toolbar/network_wireless_16.png");
|
||||
#ifdef HAVE_AIRPCAP
|
||||
case IF_AIRPCAP:
|
||||
return xpm_to_widget(capture_airpcap_16_xpm);
|
||||
#endif
|
||||
case IF_BLUETOOTH:
|
||||
return PIXBUF_TO_WIDGET(network_bluetooth_pb_data, "/org/wireshark/image/toolbar/network_bluetooth_16.png");
|
||||
case IF_USB:
|
||||
return PIXBUF_TO_WIDGET(network_usb_pb_data, "/org/wireshark/image/toolbar/network_usb_16.png");
|
||||
case IF_VIRTUAL:
|
||||
return xpm_to_widget(network_virtual_16_xpm);
|
||||
case IF_WIRED:
|
||||
return PIXBUF_TO_WIDGET(network_wired_pb_data, "/org/wireshark/image/toolbar/network_wired_16.png");
|
||||
case IF_EXTCAP:
|
||||
#ifdef _WIN32
|
||||
if (strncmp(device->friendly_name, "USBPcap", 7) == 0) {
|
||||
return PIXBUF_TO_WIDGET(network_usb_pb_data, "/org/wireshark/image/toolbar/network_usb_16.png");
|
||||
}
|
||||
#endif
|
||||
case IF_PIPE:
|
||||
case IF_STDIN:
|
||||
return PIXBUF_TO_WIDGET(pipe_pb_data, "/org/wireshark/image/toolbar/pipe_16.png");
|
||||
default:
|
||||
printf("unknown device type\n");
|
||||
}
|
||||
return PIXBUF_TO_WIDGET(network_wired_pb_data, "/org/wireshark/image/toolbar/network_wired_16.png");
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
get_ip_addr_count(GSList *addr_list)
|
||||
{
|
||||
GSList *curr_addr;
|
||||
if_addr_t *addr;
|
||||
int count;
|
||||
|
||||
count = 0;
|
||||
for (curr_addr = addr_list; curr_addr != NULL;
|
||||
curr_addr = g_slist_next(curr_addr)) {
|
||||
addr = (if_addr_t *)curr_addr->data;
|
||||
switch (addr->ifat_type) {
|
||||
|
||||
case IF_AT_IPv4:
|
||||
case IF_AT_IPv6:
|
||||
count++;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* In case we add non-IP addresses */
|
||||
break;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
set_ip_addr_label(GSList *addr_list, GtkWidget *ip_lb, guint selected_ip_addr)
|
||||
{
|
||||
GSList *curr_addr;
|
||||
if_addr_t *addr;
|
||||
address addr_address;
|
||||
char *addr_str = NULL;
|
||||
|
||||
curr_addr = g_slist_nth(addr_list, selected_ip_addr);
|
||||
if (curr_addr) {
|
||||
addr = (if_addr_t *)curr_addr->data;
|
||||
switch (addr->ifat_type) {
|
||||
|
||||
case IF_AT_IPv4:
|
||||
set_address(&addr_address, AT_IPv4, 4, &addr->addr.ip4_addr);
|
||||
addr_str = (char*)address_to_str(NULL, &addr_address);
|
||||
break;
|
||||
|
||||
case IF_AT_IPv6:
|
||||
set_address(&addr_address, AT_IPv6, 16, addr->addr.ip6_addr);
|
||||
addr_str = (char*)address_to_str(NULL, &addr_address);
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Ignore non-IP addresses, in case we ever support them */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (addr_str) {
|
||||
gtk_label_set_text(GTK_LABEL(ip_lb), addr_str);
|
||||
} else {
|
||||
gtk_label_set_text(GTK_LABEL(ip_lb), "none");
|
||||
}
|
||||
wmem_free(NULL, addr_str);
|
||||
g_object_set_data(G_OBJECT(ip_lb), CAPTURE_IF_SELECTED_IP_ADDR, GINT_TO_POINTER(selected_ip_addr));
|
||||
|
||||
return addr_str;
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
ip_label_enter_cb(GtkWidget *eb, GdkEventCrossing *event _U_, gpointer user_data _U_)
|
||||
{
|
||||
gtk_widget_set_state(eb, GTK_STATE_PRELIGHT);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
ip_label_leave_cb(GtkWidget *eb, GdkEvent *event _U_, gpointer user_data _U_)
|
||||
{
|
||||
gtk_widget_set_state(eb, GTK_STATE_NORMAL);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
ip_label_press_cb(GtkWidget *widget, GdkEvent *event _U_, gpointer data)
|
||||
{
|
||||
GtkWidget *ip_lb = (GtkWidget *)g_object_get_data(G_OBJECT(widget), CAPTURE_IF_IP_ADDR_LABEL);
|
||||
GSList *addr_list = (GSList *)data;
|
||||
GSList *curr_addr, *start_addr;
|
||||
if_addr_t *addr;
|
||||
guint selected_ip_addr = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(ip_lb), CAPTURE_IF_SELECTED_IP_ADDR));
|
||||
|
||||
/* Select next IP address */
|
||||
start_addr = g_slist_nth(addr_list, selected_ip_addr);
|
||||
for (;;) {
|
||||
selected_ip_addr++;
|
||||
if (g_slist_length(addr_list) <= selected_ip_addr) {
|
||||
/* Wrap around */
|
||||
selected_ip_addr = 0;
|
||||
}
|
||||
curr_addr = g_slist_nth(addr_list, selected_ip_addr);
|
||||
if (curr_addr == start_addr) {
|
||||
/* We wrapped all the way around */
|
||||
break;
|
||||
}
|
||||
|
||||
addr = (if_addr_t *)curr_addr->data;
|
||||
switch (addr->ifat_type) {
|
||||
|
||||
case IF_AT_IPv4:
|
||||
case IF_AT_IPv6:
|
||||
goto found;
|
||||
|
||||
default:
|
||||
/* In case we add non-IP addresses */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
found:
|
||||
set_ip_addr_label(addr_list, ip_lb, selected_ip_addr);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
capture_if_stop_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||
{
|
||||
guint ifs;
|
||||
if_dlg_data_t data;
|
||||
|
||||
for (ifs = 0; ifs < if_array->len; ifs++) {
|
||||
data = g_array_index(if_array, if_dlg_data_t, ifs);
|
||||
if (data.hidden) {
|
||||
continue;
|
||||
}
|
||||
gtk_widget_set_sensitive(data.choose_bt, TRUE);
|
||||
if_array = g_array_remove_index(if_array, ifs);
|
||||
g_array_insert_val(if_array, ifs, data);
|
||||
}
|
||||
capture_stop_cb(NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
make_if_array(void)
|
||||
{
|
||||
if_dlg_data_t data;
|
||||
guint i;
|
||||
|
||||
if_array = g_array_new(FALSE, FALSE, sizeof(if_dlg_data_t));
|
||||
|
||||
for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
|
||||
data.device_lb = NULL;
|
||||
data.descr_lb = NULL;
|
||||
data.ip_lb = NULL;
|
||||
data.curr_lb = NULL;
|
||||
data.last_lb = NULL;
|
||||
data.choose_bt = NULL;
|
||||
#ifdef _WIN32
|
||||
data.details_bt = NULL;
|
||||
#endif
|
||||
data.hidden = FALSE;
|
||||
g_array_append_val(if_array, data);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If this is Windows, is WinPcap loaded? If not, pop up a dialog noting
|
||||
* that fact and return FALSE, as we can't capture traffic.
|
||||
*
|
||||
* Otherwise (not Windows or WinPcap loaded), are there any interfaces?
|
||||
* If not, pop up a dialog noting that fact and return FALSE, as there
|
||||
* are no interfaces on which to capture traffic.
|
||||
*
|
||||
* Otherwise, return TRUE, as we can capture.
|
||||
*/
|
||||
static gboolean
|
||||
can_capture(void)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
/* Is WPcap loaded? */
|
||||
if (!has_wpcap) {
|
||||
char *detailed_err;
|
||||
|
||||
detailed_err = cant_load_winpcap_err("Wireshark");
|
||||
simple_error_message_box("%s", detailed_err);
|
||||
g_free(detailed_err);
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (global_capture_opts.all_ifaces->len == 0) {
|
||||
simple_error_message_box("There are no interfaces on which a capture can be done.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
capture_if_refresh_if_list(void)
|
||||
{
|
||||
GtkWidget *if_vb, *if_grid, *icon, *if_lb, *eb;
|
||||
GtkRequisition requisition;
|
||||
int row = 0, height = 0;
|
||||
guint ifs;
|
||||
interface_t device;
|
||||
const gchar *addr_str;
|
||||
gchar *user_descr;
|
||||
if_dlg_data_t data;
|
||||
|
||||
if (!can_capture()) {
|
||||
/* No interfaces or, on Windows, no WinPcap; we've already popped
|
||||
up a message, so just get rid of the interface dialog. */
|
||||
destroy_if_window();
|
||||
return;
|
||||
}
|
||||
|
||||
if (cap_if_sw) {
|
||||
/* First, get rid of the old interface list, and stop updating
|
||||
the statistics on it. */
|
||||
gtk_container_remove(GTK_CONTAINER(cap_if_top_vb), cap_if_sw);
|
||||
capture_stat_stop(sc);
|
||||
g_source_remove(timer_id);
|
||||
}
|
||||
|
||||
/* Now construct the new interface list, and start updating the
|
||||
statistics on it. */
|
||||
|
||||
make_if_array();
|
||||
|
||||
cap_if_sw = gtk_scrolled_window_new(NULL, NULL);
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(cap_if_sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
||||
gtk_box_pack_start(GTK_BOX(cap_if_top_vb), cap_if_sw, TRUE, TRUE, 0);
|
||||
|
||||
if_vb = gtk_alignment_new(0.0F, 0.0F, 1.0F, 0.0F);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(if_vb), 5);
|
||||
#if ! GTK_CHECK_VERSION(3,8,0)
|
||||
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(cap_if_sw), if_vb);
|
||||
#else
|
||||
gtk_container_add(GTK_CONTAINER(cap_if_sw), if_vb);
|
||||
#endif
|
||||
|
||||
if_grid = ws_gtk_grid_new();
|
||||
ws_gtk_grid_set_row_spacing(GTK_GRID(if_grid), 3);
|
||||
ws_gtk_grid_set_column_spacing(GTK_GRID(if_grid), 3);
|
||||
gtk_container_add(GTK_CONTAINER(if_vb), if_grid);
|
||||
|
||||
/* This is the icon column, used to display which kind of interface we have */
|
||||
if_lb = gtk_label_new("");
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(if_grid), if_lb, 0, row, 1, 1,
|
||||
(GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0);
|
||||
|
||||
if_lb = gtk_label_new("Device");
|
||||
ws_gtk_grid_attach_defaults(GTK_GRID(if_grid), if_lb, 1, row, 3, 1);
|
||||
|
||||
if_lb = gtk_label_new("Description");
|
||||
ws_gtk_grid_attach_defaults(GTK_GRID(if_grid), if_lb, 4, row, 1, 1);
|
||||
|
||||
if_lb = gtk_label_new(" IP ");
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(if_grid), if_lb, 5, row, 1, 1,
|
||||
(GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0);
|
||||
|
||||
if_lb = gtk_label_new("Packets");
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(if_grid), if_lb, 6, row, 1, 1,
|
||||
(GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0);
|
||||
|
||||
if_lb = gtk_label_new(" Packets/s ");
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(if_grid), if_lb, 7, row, 1, 1,
|
||||
(GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0);
|
||||
row++;
|
||||
|
||||
height += 30;
|
||||
/* Start gathering statistics (using dumpcap) */
|
||||
sc = capture_stat_start(&global_capture_opts);
|
||||
|
||||
/* List the interfaces */
|
||||
for (ifs = 0; ifs < global_capture_opts.all_ifaces->len; ifs++) {
|
||||
device = g_array_index(global_capture_opts.all_ifaces, interface_t, ifs);
|
||||
data = g_array_index(if_array, if_dlg_data_t, ifs);
|
||||
/* Continue if capture device is hidden */
|
||||
if (device.hidden) {
|
||||
data.hidden = TRUE;
|
||||
if_array = g_array_remove_index(if_array, ifs);
|
||||
g_array_insert_val(if_array, ifs, data);
|
||||
continue;
|
||||
}
|
||||
data.choose_bt = gtk_check_button_new();
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(if_grid), data.choose_bt, 0, row, 1, 1,
|
||||
(GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0);
|
||||
if (gbl_capture_in_progress) {
|
||||
gtk_widget_set_sensitive(data.choose_bt, FALSE);
|
||||
} else {
|
||||
gtk_widget_set_sensitive(data.choose_bt, TRUE);
|
||||
}
|
||||
gtk_toggle_button_set_active((GtkToggleButton *)data.choose_bt, device.selected);
|
||||
g_signal_connect(data.choose_bt, "toggled", G_CALLBACK(store_selected), device.name);
|
||||
/* Kind of adaptor (icon) */
|
||||
icon = capture_get_if_icon(&(device));
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(if_grid), icon, 1, row, 1, 1,
|
||||
(GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0);
|
||||
|
||||
/* device name */
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
* On Windows, device names are generally not meaningful - NT 5
|
||||
* uses long blobs with GUIDs in them, for example - so instead we use
|
||||
* the display name which should match that shown in ncpa.cpl
|
||||
*/
|
||||
data.device_lb = gtk_label_new(device.display_name);
|
||||
#else
|
||||
data.device_lb = gtk_label_new(device.name);
|
||||
#endif
|
||||
gtk_misc_set_alignment(GTK_MISC(data.device_lb), 0.0f, 0.5f);
|
||||
if (strlen(gtk_label_get_text(GTK_LABEL(data.device_lb))) > SOFT_LABEL_LEN) {
|
||||
gtk_label_set_ellipsize(GTK_LABEL(data.device_lb), PANGO_ELLIPSIZE_MIDDLE);
|
||||
gtk_label_set_width_chars(GTK_LABEL(data.device_lb), SOFT_LABEL_LEN);
|
||||
}
|
||||
ws_gtk_grid_attach_defaults(GTK_GRID(if_grid), data.device_lb, 2, row, 2, 1);
|
||||
|
||||
/* description */
|
||||
user_descr = capture_dev_user_descr_find(device.name);
|
||||
if (user_descr) {
|
||||
data.descr_lb = gtk_label_new(user_descr);
|
||||
g_free (user_descr);
|
||||
} else {
|
||||
if (device.if_info.vendor_description)
|
||||
data.descr_lb = gtk_label_new(device.if_info.vendor_description);
|
||||
else
|
||||
data.descr_lb = gtk_label_new("");
|
||||
}
|
||||
gtk_misc_set_alignment(GTK_MISC(data.descr_lb), 0.0f, 0.5f);
|
||||
if (strlen(gtk_label_get_text(GTK_LABEL(data.descr_lb))) > SOFT_LABEL_LEN) {
|
||||
gtk_label_set_ellipsize(GTK_LABEL(data.descr_lb), PANGO_ELLIPSIZE_MIDDLE);
|
||||
gtk_label_set_width_chars(GTK_LABEL(data.descr_lb), SOFT_LABEL_LEN);
|
||||
}
|
||||
ws_gtk_grid_attach_defaults(GTK_GRID(if_grid), data.descr_lb, 4, row, 1, 1);
|
||||
|
||||
/* IP address */
|
||||
/* Only one IP address will be shown, start with the first */
|
||||
data.ip_lb = gtk_label_new("");
|
||||
addr_str = set_ip_addr_label (device.if_info.addrs, data.ip_lb, 0);
|
||||
if (addr_str) {
|
||||
gtk_widget_set_sensitive(data.ip_lb, TRUE);
|
||||
} else {
|
||||
gtk_widget_set_sensitive(data.ip_lb, FALSE);
|
||||
}
|
||||
eb = gtk_event_box_new ();
|
||||
gtk_container_add(GTK_CONTAINER(eb), data.ip_lb);
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(if_grid), eb, 5, row, 1, 1,
|
||||
(GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0);
|
||||
if (get_ip_addr_count(device.if_info.addrs) > 1) {
|
||||
/* More than one IP address, make it possible to toggle */
|
||||
g_object_set_data(G_OBJECT(eb), CAPTURE_IF_IP_ADDR_LABEL, data.ip_lb);
|
||||
gtk_widget_set_tooltip_text(eb, "Click to see additional IP addresses");
|
||||
g_signal_connect(eb, "enter-notify-event", G_CALLBACK(ip_label_enter_cb), NULL);
|
||||
g_signal_connect(eb, "leave-notify-event", G_CALLBACK(ip_label_leave_cb), NULL);
|
||||
g_signal_connect(eb, "button-press-event", G_CALLBACK(ip_label_press_cb), device.if_info.addrs);
|
||||
}
|
||||
|
||||
/* packets */
|
||||
data.curr_lb = gtk_label_new("-");
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(if_grid), data.curr_lb, 6, row, 1, 1,
|
||||
(GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0);
|
||||
|
||||
/* packets/s */
|
||||
data.last_lb = gtk_label_new("-");
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(if_grid), data.last_lb, 7, row, 1, 1,
|
||||
(GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0);
|
||||
|
||||
/* details button */
|
||||
#ifdef _WIN32
|
||||
data.details_bt = ws_gtk_button_new_from_stock(WIRESHARK_STOCK_CAPTURE_DETAILS);
|
||||
gtk_widget_set_tooltip_text(data.details_bt, "Open the capture details dialog of this interface.");
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(if_grid), data.details_bt, 8, row, 1, 1, 0, 0, 0, 0);
|
||||
if (capture_if_has_details(device.name)) {
|
||||
g_signal_connect(data.details_bt, "clicked", G_CALLBACK(capture_details_cb), device.name);
|
||||
} else {
|
||||
gtk_widget_set_sensitive(data.details_bt, FALSE);
|
||||
}
|
||||
#endif
|
||||
if_array = g_array_remove_index(if_array, ifs);
|
||||
g_array_insert_val(if_array, ifs, data);
|
||||
|
||||
row++;
|
||||
if (row <= 20) {
|
||||
/* Add up to 20 rows of interfaces, otherwise the window may become too high */
|
||||
#ifdef _WIN32
|
||||
gtk_widget_get_preferred_size(GTK_WIDGET(data.details_bt), &requisition, NULL);
|
||||
#else
|
||||
gtk_widget_get_preferred_size(GTK_WIDGET(data.choose_bt), &requisition, NULL);
|
||||
#endif
|
||||
height += requisition.height;
|
||||
}
|
||||
}
|
||||
|
||||
gtk_widget_get_preferred_size(GTK_WIDGET(close_bt), &requisition, NULL);
|
||||
/* height + static offset + grid spacing */
|
||||
height += requisition.height + 40 + (row * 3);
|
||||
|
||||
gtk_window_set_default_size(GTK_WINDOW(cap_if_w), -1, height);
|
||||
|
||||
gtk_widget_show_all(cap_if_w);
|
||||
|
||||
/* update the interface list every 1000ms */
|
||||
timer_id = g_timeout_add(1000, update_all, sc);
|
||||
}
|
||||
|
||||
/* start getting capture stats from all interfaces */
|
||||
void
|
||||
capture_if_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||
{
|
||||
GtkWidget *bbox,
|
||||
*help_bt;
|
||||
#ifdef HAVE_AIRPCAP
|
||||
GtkWidget *decryption_cb;
|
||||
#endif
|
||||
|
||||
if (cap_if_w != NULL) {
|
||||
/* There's already a "Capture Interfaces" dialog box; reactivate it. */
|
||||
reactivate_window(cap_if_w);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!can_capture()) {
|
||||
/* No interfaces or, on Windows, no WinPcap; just give up. */
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef HAVE_AIRPCAP
|
||||
/* LOAD AIRPCAP INTERFACES */
|
||||
|
||||
/* If no airpcap interface is present, gray everything */
|
||||
if (airpcap_if_active == NULL) {
|
||||
if (g_airpcap_if_list == NULL) {
|
||||
/*No airpcap device found */
|
||||
airpcap_enable_toolbar_widgets(wireless_tb,FALSE);
|
||||
} else {
|
||||
/* default adapter is not airpcap... or is airpcap but is not found*/
|
||||
if (airpcap_if_active){
|
||||
/* XXX can never happen? */
|
||||
airpcap_set_toolbar_stop_capture(airpcap_if_active);
|
||||
}
|
||||
airpcap_enable_toolbar_widgets(wireless_tb,FALSE);
|
||||
}
|
||||
}
|
||||
if (airpcap_if_active){
|
||||
decryption_cb = (GtkWidget *)g_object_get_data(G_OBJECT(wireless_tb),AIRPCAP_TOOLBAR_DECRYPTION_KEY);
|
||||
/* XXXX update_decryption_mode_list() trigers a rescan, should only be done if the mode is changed */
|
||||
update_decryption_mode_list(decryption_cb);
|
||||
airpcap_set_toolbar_start_capture(airpcap_if_active);
|
||||
}
|
||||
#endif
|
||||
|
||||
cap_if_w = dlg_window_new("Wireshark: Capture Interfaces"); /* transient_for top_level */
|
||||
/* XXX: Note that on Windows the following is effectively a no-op; See dlg_window_new(). */
|
||||
/* This means, on Windows, if the top_level Wireshark window is destroyed when */
|
||||
/* the capture_interfaces dialog window is open, that the dumpcap process will not */
|
||||
/* be stopped since the destroy callback for the capture_interfaces dialog window */
|
||||
/* will not be called. */
|
||||
/* ToDo: Fix this ! */
|
||||
gtk_window_set_destroy_with_parent (GTK_WINDOW(cap_if_w), TRUE);
|
||||
|
||||
cap_if_top_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, DLG_UNRELATED_SPACING, FALSE);
|
||||
gtk_container_add(GTK_CONTAINER(cap_if_w), cap_if_top_vb);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(cap_if_top_vb), DLG_OUTER_MARGIN);
|
||||
|
||||
/* Button row: close, help, stop, start, and options button */
|
||||
bbox = dlg_button_row_new(GTK_STOCK_HELP, WIRESHARK_STOCK_CAPTURE_START, WIRESHARK_STOCK_CAPTURE_OPTIONS, WIRESHARK_STOCK_CAPTURE_STOP, GTK_STOCK_CLOSE, NULL);
|
||||
|
||||
gtk_box_pack_end(GTK_BOX(cap_if_top_vb), bbox, FALSE, FALSE, 0);
|
||||
help_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
|
||||
g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb), (gpointer)(HELP_CAPTURE_INTERFACES_DIALOG));
|
||||
|
||||
stop_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_CAPTURE_STOP);
|
||||
g_signal_connect(stop_bt, "clicked", G_CALLBACK(capture_if_stop_cb), NULL);
|
||||
close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
|
||||
window_set_cancel_button(cap_if_w, close_bt, window_cancel_button_cb);
|
||||
gtk_widget_set_tooltip_text(close_bt, "Close this window.");
|
||||
options_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_CAPTURE_OPTIONS);
|
||||
g_signal_connect(options_bt, "clicked", G_CALLBACK(capture_prepare_cb), NULL);
|
||||
capture_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_CAPTURE_START);
|
||||
g_signal_connect(capture_bt, "clicked", G_CALLBACK(capture_do_cb), NULL);
|
||||
|
||||
gtk_widget_grab_default(close_bt);
|
||||
|
||||
g_signal_connect(cap_if_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
||||
g_signal_connect(cap_if_w, "destroy", G_CALLBACK(capture_if_destroy_cb), sc);
|
||||
|
||||
capture_if_refresh_if_list();
|
||||
|
||||
window_present(cap_if_w);
|
||||
|
||||
set_capture_if_dialog_for_capture_in_progress(gbl_capture_in_progress);
|
||||
}
|
||||
|
||||
gboolean interfaces_dialog_window_present(void)
|
||||
{
|
||||
return (cap_if_w?TRUE:FALSE);
|
||||
}
|
||||
|
||||
void refresh_if_window(void)
|
||||
{
|
||||
if (cap_if_w) {
|
||||
capture_if_refresh_if_list();
|
||||
}
|
||||
}
|
||||
|
||||
void select_all_interfaces(gboolean enable _U_)
|
||||
{
|
||||
guint ifs;
|
||||
interface_t device;
|
||||
|
||||
for (ifs = 0; ifs < global_capture_opts.all_ifaces->len; ifs++) {
|
||||
device = g_array_index(global_capture_opts.all_ifaces, interface_t, ifs);
|
||||
update_selected_interface(device.if_info.name);
|
||||
}
|
||||
}
|
||||
|
||||
void destroy_if_window(void)
|
||||
{
|
||||
if (cap_if_w) {
|
||||
window_destroy(cap_if_w);
|
||||
}
|
||||
}
|
||||
#else /* HAVE_LIBPCAP */
|
||||
|
||||
void
|
||||
set_capture_if_dialog_for_capture_in_progress(gboolean capture_in_progress _U_)
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* HAVE_LIBPCAP */
|
||||
|
||||
/*
|
||||
* Editor modelines
|
||||
*
|
||||
* Local Variables:
|
||||
* c-basic-offset: 2
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* ex: set shiftwidth=2 tabstop=8 expandtab:
|
||||
* :indentSize=2:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -1,77 +0,0 @@
|
|||
/* capture_if_dlg.h
|
||||
* Definitions for packet capture interface windows
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __CAPTURE_IF_DLG_H__
|
||||
#define __CAPTURE_IF_DLG_H__
|
||||
|
||||
/** A live capture has started or stopped.
|
||||
*
|
||||
* @param capture_in_progress capture is in progress
|
||||
*/
|
||||
void
|
||||
set_capture_if_dialog_for_capture_in_progress(gboolean capture_in_progress);
|
||||
|
||||
/** A live capture is being stopped.
|
||||
*/
|
||||
void set_capture_if_dialog_for_capture_stopping(void);
|
||||
|
||||
/** User requested the "Capture Interfaces" dialog box by menu or toolbar.
|
||||
*
|
||||
* @param widget parent widget (unused)
|
||||
* @param data unused
|
||||
*/
|
||||
void
|
||||
capture_if_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
#ifdef HAVE_LIBPCAP
|
||||
|
||||
#include "caputils/capture_ifinfo.h" /* for if_info_t */
|
||||
|
||||
/*
|
||||
* Used to retrieve the interface icon
|
||||
*/
|
||||
GtkWidget *
|
||||
capture_get_if_icon(interface_t *device);
|
||||
|
||||
void
|
||||
update_selected_interface(gchar *name);
|
||||
|
||||
gboolean
|
||||
interfaces_dialog_window_present(void);
|
||||
|
||||
void
|
||||
add_interface(void);
|
||||
|
||||
void
|
||||
refresh_if_window(void);
|
||||
|
||||
void
|
||||
select_all_interfaces(gboolean enable);
|
||||
|
||||
void
|
||||
destroy_if_window(void);
|
||||
|
||||
#endif /* HAVE_LIBPCAP */
|
||||
|
||||
#endif /* capture_if_dlg.h */
|
||||
|
||||
|
|
@ -1,389 +0,0 @@
|
|||
/* capture_info_dlg.c
|
||||
* Routines for packet capture info dialog
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_LIBPCAP
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <epan/packet.h>
|
||||
#include <epan/capture_dissectors.h>
|
||||
|
||||
#include "ui/capture.h"
|
||||
#include "../../capture_info.h"
|
||||
|
||||
#include "ui/capture_ui_utils.h"
|
||||
|
||||
#include "ui/gtk/dlg_utils.h"
|
||||
#include "ui/gtk/gui_utils.h"
|
||||
#include "ui/gtk/main.h"
|
||||
#include "ui/gtk/help_dlg.h"
|
||||
#include "ui/gtk/stock_icons.h"
|
||||
|
||||
#ifdef HAVE_AIRPCAP
|
||||
#include <caputils/airpcap.h>
|
||||
#include <caputils/airpcap_loader.h>
|
||||
#include "airpcap_gui_utils.h"
|
||||
#include "airpcap_dlg.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* a single capture counter value (with title, pointer to value and GtkWidgets) */
|
||||
/* as the packet_counts is a struct, not an array, keep a pointer to the */
|
||||
/* corresponding value packet_counts, to speed up (and simplify) output of values */
|
||||
typedef struct {
|
||||
const gchar *title;
|
||||
int proto;
|
||||
GtkWidget *label, *value_lb, *percent_pb, *percent_lb;
|
||||
} capture_info_counts_t;
|
||||
|
||||
/** Number of packet counts. */
|
||||
#define PACKET_COUNTS_SIZE 12
|
||||
|
||||
/* all data we need to know of this dialog, after creation finished */
|
||||
typedef struct {
|
||||
GtkWidget *cap_w;
|
||||
GtkWidget *running_time_lb;
|
||||
capture_info_counts_t total_count;
|
||||
capture_info_counts_t other_count;
|
||||
capture_info_counts_t counts[PACKET_COUNTS_SIZE];
|
||||
guint timer_id;
|
||||
time_t start_time;
|
||||
} capture_info_ui_t;
|
||||
|
||||
|
||||
/* Workhorse for stopping capture */
|
||||
static void
|
||||
capture_info_stop(capture_session *cap_session)
|
||||
{
|
||||
#ifdef HAVE_AIRPCAP
|
||||
airpcap_set_toolbar_stop_capture(airpcap_if_active);
|
||||
#endif
|
||||
capture_stop(cap_session);
|
||||
}
|
||||
|
||||
/* "delete-event" signal callback. Note different signature than "clicked" signal callback */
|
||||
static gboolean
|
||||
capture_info_delete_cb(GtkWidget *w _U_, GdkEvent *event _U_, gpointer data) {
|
||||
capture_info_stop((capture_session *)data);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* "clicked" signal callback */
|
||||
static void
|
||||
capture_info_stop_clicked_cb(GtkButton *w _U_, gpointer data) {
|
||||
capture_info_stop((capture_session *)data);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
capture_info_ui_update_cb(gpointer data)
|
||||
{
|
||||
capture_info *cinfo = (capture_info *)data;
|
||||
capture_info_ui_t *info = (capture_info_ui_t *)cinfo->ui;
|
||||
|
||||
if (!info) /* ...which might happen on slow displays? */
|
||||
return TRUE;
|
||||
|
||||
cinfo->running_time = time(NULL) - info->start_time;
|
||||
capture_info_ui_update(cinfo);
|
||||
return TRUE; /* call the timer again */
|
||||
}
|
||||
|
||||
static void
|
||||
capture_info_count_init(capture_info_counts_t* count, int idx, GtkWidget *percent_pb, gboolean show, GtkWidget *counts_grid)
|
||||
{
|
||||
count->label = gtk_label_new(count->title);
|
||||
gtk_misc_set_alignment(GTK_MISC(count->label), 0.0f, 0.5f);
|
||||
|
||||
count->value_lb = gtk_label_new("0");
|
||||
gtk_misc_set_alignment(GTK_MISC(count->value_lb), 0.5f, 0.5f);
|
||||
|
||||
count->percent_pb = percent_pb;
|
||||
|
||||
if (!show) /* Do for all but "total" */
|
||||
{
|
||||
/* downsize the default size of this progress bar in x direction (def:150), */
|
||||
/* otherwise it will become too large and the dialog will look ugly */
|
||||
/* XXX: use a TreeView instead of a grid in order to fix this */
|
||||
gtk_widget_set_size_request(count->percent_pb, 70, -1);
|
||||
}
|
||||
|
||||
count->percent_lb = gtk_label_new("0.0%");
|
||||
gtk_misc_set_alignment(GTK_MISC(count->percent_lb), 1.0f, 0.5f);
|
||||
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(counts_grid), count->label,
|
||||
0, idx, 1, 1, (GtkAttachOptions)(GTK_EXPAND|GTK_FILL), (GtkAttachOptions)0, 0, 0);
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(counts_grid), count->value_lb,
|
||||
1, idx, 1, 1, (GtkAttachOptions)(GTK_EXPAND|GTK_FILL), (GtkAttachOptions)0, 0, 0);
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(counts_grid), count->percent_pb,
|
||||
2, idx, 1, 1, (GtkAttachOptions)(GTK_EXPAND|GTK_FILL), (GtkAttachOptions)0, 0, 0);
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(counts_grid), count->percent_lb,
|
||||
3, idx, 1, 1, (GtkAttachOptions)(GTK_EXPAND|GTK_FILL), (GtkAttachOptions)0, 0, 0);
|
||||
|
||||
gtk_widget_show(count->label);
|
||||
gtk_widget_show(count->value_lb);
|
||||
gtk_widget_show(count->percent_pb);
|
||||
/* don't show percentages for the "total" row */
|
||||
if (show) {
|
||||
gtk_widget_show(count->percent_lb);
|
||||
}
|
||||
}
|
||||
|
||||
/* create the capture info dialog */
|
||||
/* will keep pointers to the fields in the counts parameter */
|
||||
void
|
||||
capture_info_ui_create(capture_info *cinfo, capture_session *cap_session)
|
||||
{
|
||||
capture_options *capture_opts = cap_session->capture_opts;
|
||||
unsigned int i;
|
||||
GtkWidget *main_vb, *stop_bt, *counts_grid;
|
||||
GtkWidget *counts_fr, *running_grid, *running_label, *lb, *bbox, *ci_help;
|
||||
capture_info_ui_t *info;
|
||||
gchar *cap_w_title;
|
||||
gchar *title_iface;
|
||||
GString *str;
|
||||
|
||||
info = g_new0(capture_info_ui_t,1);
|
||||
info->total_count.title = "Total";
|
||||
info->other_count.title = "Other";
|
||||
|
||||
info->counts[0].title = "SCTP";
|
||||
info->counts[0].proto = proto_get_id_by_short_name(info->counts[0].title);
|
||||
info->counts[1].title = "TCP";
|
||||
info->counts[1].proto = proto_get_id_by_short_name(info->counts[1].title);
|
||||
info->counts[2].title = "UDP";
|
||||
info->counts[2].proto = proto_get_id_by_short_name(info->counts[2].title);
|
||||
info->counts[3].title = "ICMP";
|
||||
info->counts[3].proto = proto_get_id_by_short_name(info->counts[3].title);
|
||||
info->counts[4].title = "ARP";
|
||||
info->counts[4].proto = proto_get_id_by_short_name(info->counts[4].title);
|
||||
info->counts[5].title = "OSPF";
|
||||
info->counts[5].proto = proto_get_id_by_short_name(info->counts[5].title);
|
||||
info->counts[6].title = "GRE";
|
||||
info->counts[6].proto = proto_get_id_by_short_name(info->counts[6].title);
|
||||
info->counts[7].title = "NetBIOS";
|
||||
info->counts[7].proto = proto_get_id_by_short_name(info->counts[7].title);
|
||||
info->counts[8].title = "IPX";
|
||||
info->counts[8].proto = proto_get_id_by_short_name(info->counts[8].title);
|
||||
info->counts[9].title = "VINES";
|
||||
info->counts[9].proto = proto_get_id_by_short_name(info->counts[9].title);
|
||||
info->counts[10].title = "I2C Events";
|
||||
info->counts[10].proto = proto_get_id_by_short_name(info->counts[10].title);
|
||||
info->counts[11].title = "I2C Data";
|
||||
info->counts[11].proto = proto_get_id_by_short_name(info->counts[11].title);
|
||||
|
||||
/*
|
||||
* Create the dialog window, with a title that includes the interfaces
|
||||
* on which we're capturing.
|
||||
*/
|
||||
str = get_iface_list_string(capture_opts, 0);
|
||||
title_iface = g_strdup_printf("Wireshark: Capture from %s", str->str);
|
||||
g_string_free(str, TRUE);
|
||||
cap_w_title = create_user_window_title(title_iface);
|
||||
g_free(title_iface);
|
||||
info->cap_w = dlg_window_new(cap_w_title);
|
||||
g_free(cap_w_title);
|
||||
|
||||
/* Container for capture display widgets */
|
||||
main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 1, FALSE);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
|
||||
gtk_container_add(GTK_CONTAINER(info->cap_w), main_vb);
|
||||
gtk_widget_show(main_vb);
|
||||
|
||||
counts_fr = gtk_frame_new("Captured Packets");
|
||||
gtk_box_pack_start(GTK_BOX(main_vb), counts_fr, FALSE, FALSE, 3);
|
||||
gtk_widget_show(counts_fr);
|
||||
|
||||
/* Individual statistic elements */
|
||||
counts_grid = ws_gtk_grid_new();
|
||||
ws_gtk_grid_set_homogeneous(GTK_GRID(counts_grid), TRUE);
|
||||
gtk_container_add(GTK_CONTAINER(counts_fr), counts_grid);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(counts_grid), 5);
|
||||
gtk_widget_show(counts_grid);
|
||||
|
||||
ws_gtk_grid_set_row_spacing(GTK_GRID(counts_grid), 0);
|
||||
ws_gtk_grid_set_column_spacing(GTK_GRID(counts_grid), 5);
|
||||
|
||||
capture_info_count_init(&info->total_count, 0, gtk_label_new("% of total"), FALSE, counts_grid);
|
||||
|
||||
for (i = 0; i < PACKET_COUNTS_SIZE; i++) {
|
||||
capture_info_count_init(&info->counts[i], i+1, gtk_progress_bar_new(), TRUE, counts_grid);
|
||||
}
|
||||
|
||||
capture_info_count_init(&info->other_count, i+1, gtk_progress_bar_new(), TRUE, counts_grid);
|
||||
|
||||
/* Running time */
|
||||
running_grid = ws_gtk_grid_new();
|
||||
ws_gtk_grid_set_homogeneous(GTK_GRID(running_grid), TRUE);
|
||||
|
||||
running_label = gtk_label_new("Running");
|
||||
gtk_misc_set_alignment(GTK_MISC(running_label), 0.0f, 0.0f);
|
||||
gtk_widget_show(running_label);
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(running_grid), running_label,
|
||||
0, 0, 1, 1, (GtkAttachOptions)(GTK_EXPAND|GTK_FILL), (GtkAttachOptions)0, 0, 0);
|
||||
|
||||
info->running_time_lb = gtk_label_new("00:00:00");
|
||||
gtk_misc_set_alignment(GTK_MISC(info->running_time_lb), 0.5f, 0.0f);
|
||||
gtk_widget_show(info->running_time_lb);
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(running_grid), info->running_time_lb,
|
||||
1, 0, 1, 1, (GtkAttachOptions)(GTK_EXPAND|GTK_FILL), (GtkAttachOptions)0, 5, 0); /* effect: pads *all* the columns ?? */
|
||||
|
||||
/* two dummy cols to match the 4 cols above */
|
||||
lb = gtk_label_new("");
|
||||
gtk_widget_show(lb);
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(running_grid), lb,
|
||||
2, 0, 1, 1, (GtkAttachOptions)(GTK_EXPAND|GTK_FILL), (GtkAttachOptions)0, 0, 0);
|
||||
lb = gtk_label_new("");
|
||||
gtk_widget_show(lb);
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(running_grid), lb,
|
||||
3, 0, 1, 1, (GtkAttachOptions)(GTK_EXPAND|GTK_FILL), (GtkAttachOptions)0, 0, 0);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(main_vb), running_grid, FALSE, FALSE, 3);
|
||||
gtk_widget_show(running_grid);
|
||||
|
||||
/* allow user to either click a stop button, or the close button on
|
||||
the window to stop a capture in progress. */
|
||||
bbox = dlg_button_row_new(WIRESHARK_STOCK_CAPTURE_STOP, GTK_STOCK_HELP, NULL);
|
||||
gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 3);
|
||||
gtk_widget_show(bbox);
|
||||
|
||||
stop_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_CAPTURE_STOP);
|
||||
window_set_cancel_button(info->cap_w, stop_bt, NULL);
|
||||
g_signal_connect(stop_bt, "clicked", G_CALLBACK(capture_info_stop_clicked_cb), cap_session);
|
||||
g_signal_connect(info->cap_w, "delete_event", G_CALLBACK(capture_info_delete_cb), cap_session);
|
||||
|
||||
ci_help = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
|
||||
gtk_widget_set_tooltip_text(ci_help, "Get help about this dialog");
|
||||
g_signal_connect(ci_help, "clicked", G_CALLBACK(topic_cb), (gpointer)HELP_CAPTURE_INFO_DIALOG);
|
||||
|
||||
gtk_widget_show(info->cap_w);
|
||||
window_present(info->cap_w);
|
||||
|
||||
info->start_time = time(NULL);
|
||||
|
||||
cinfo->ui = info;
|
||||
|
||||
/* update the dialog once a second, even if no packets rushing in */
|
||||
info->timer_id = g_timeout_add(1000, capture_info_ui_update_cb,cinfo);
|
||||
}
|
||||
|
||||
static void
|
||||
capture_info_count_update(capture_info_counts_t* count, capture_info *cinfo)
|
||||
{
|
||||
gchar label_str[64];
|
||||
float pb_frac;
|
||||
guint32 proto_count;
|
||||
|
||||
proto_count = capture_dissector_get_count(cinfo->counts, count->proto);
|
||||
|
||||
g_snprintf(label_str, sizeof(label_str), "%d", proto_count);
|
||||
gtk_label_set_text(GTK_LABEL(count->value_lb), label_str);
|
||||
|
||||
pb_frac = (cinfo->counts->total != 0) ?
|
||||
((float)proto_count / cinfo->counts->total) : 0.0f;
|
||||
|
||||
/* don't try to update the "total" row progress bar */
|
||||
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(count->percent_pb), pb_frac);
|
||||
g_snprintf(label_str, sizeof(label_str), "%.1f%%", pb_frac * 100.0);
|
||||
gtk_label_set_text(GTK_LABEL(count->percent_lb), label_str);
|
||||
}
|
||||
|
||||
/* 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)
|
||||
{
|
||||
unsigned int i;
|
||||
gchar label_str[64];
|
||||
capture_info_ui_t *info = (capture_info_ui_t *)cinfo->ui;
|
||||
|
||||
if (!info) /* ...which might happen on slow displays? */
|
||||
return;
|
||||
|
||||
/* display running time */
|
||||
g_snprintf(label_str, sizeof(label_str), "%02ld:%02ld:%02ld",
|
||||
(long)(cinfo->running_time/3600), (long)((cinfo->running_time%3600)/60),
|
||||
(long)(cinfo->running_time%60));
|
||||
gtk_label_set_text(GTK_LABEL(info->running_time_lb), label_str);
|
||||
|
||||
/* if we have new packets, update all rows */
|
||||
if (cinfo->new_packets) {
|
||||
float pb_frac;
|
||||
|
||||
/* First setup total */
|
||||
g_snprintf(label_str, sizeof(label_str), "%d", cinfo->counts->total);
|
||||
gtk_label_set_text(GTK_LABEL(info->total_count.value_lb), label_str);
|
||||
|
||||
for (i = 0; i < PACKET_COUNTS_SIZE; i++) {
|
||||
capture_info_count_update(&info->counts[i], cinfo);
|
||||
}
|
||||
|
||||
/* Now handle "other" packets */
|
||||
g_snprintf(label_str, sizeof(label_str), "%d", cinfo->counts->other);
|
||||
gtk_label_set_text(GTK_LABEL(info->other_count.value_lb), label_str);
|
||||
|
||||
pb_frac = (cinfo->counts->total != 0) ?
|
||||
((float)cinfo->counts->other / cinfo->counts->total) : 0.0f;
|
||||
|
||||
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(info->other_count.percent_pb), pb_frac);
|
||||
g_snprintf(label_str, sizeof(label_str), "%.1f%%", pb_frac * 100.0);
|
||||
gtk_label_set_text(GTK_LABEL(info->other_count.percent_lb), label_str);
|
||||
}
|
||||
}
|
||||
|
||||
/* destroy the capture info dialog again */
|
||||
void capture_info_ui_destroy(
|
||||
capture_info *cinfo)
|
||||
{
|
||||
capture_info_ui_t *info = (capture_info_ui_t *)cinfo->ui;
|
||||
|
||||
if (!info) /* ...which probably shouldn't happen */
|
||||
return;
|
||||
|
||||
g_source_remove(info->timer_id);
|
||||
|
||||
/* called from capture engine, so it's ok to destroy the dialog here */
|
||||
gtk_grab_remove(GTK_WIDGET(info->cap_w));
|
||||
window_destroy(GTK_WIDGET(info->cap_w));
|
||||
g_free(info);
|
||||
cinfo->ui = NULL;
|
||||
}
|
||||
|
||||
|
||||
#endif /* HAVE_LIBPCAP */
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local Variables:
|
||||
* c-basic-offset: 2
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=2 tabstop=8 expandtab:
|
||||
* :indentSize=2:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -1,33 +0,0 @@
|
|||
/* cfilter_combo_utils.h
|
||||
* Capture filter combo box routines
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __CFILTER_COMBO_UTILS_H__
|
||||
#define __CFILTER_COMBO_UTILS_H__
|
||||
|
||||
/** @file
|
||||
* Capture filter combo box routines
|
||||
*/
|
||||
|
||||
#define E_CFILTER_CM_KEY "capture_filter_combo"
|
||||
#define E_ALL_CFILTER_CM_KEY "capture_all_filter_combo"
|
||||
|
||||
#endif /* __CFILTER_COMBO_UTILS_H__ */
|
1124
ui/gtk/color_dlg.c
1124
ui/gtk/color_dlg.c
File diff suppressed because it is too large
Load Diff
|
@ -1,53 +0,0 @@
|
|||
/* color_dlg.h
|
||||
* Definitions for dialog boxes for color filters
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __COLOR_DLG_H__
|
||||
#define __COLOR_DLG_H__
|
||||
|
||||
/** @file
|
||||
* "Colorize Display" dialog box.
|
||||
* @ingroup dialog_group
|
||||
*/
|
||||
|
||||
extern gint color_dlg_num_of_filters; /* number of filters being displayed */
|
||||
extern gint color_dlg_row_selected; /* row in color_filters that is selected */
|
||||
|
||||
/** User requested the "Colorize Display" dialog box by menu or toolbar.
|
||||
*
|
||||
* @param widget parent widget (unused)
|
||||
* @param data unused
|
||||
*/
|
||||
void color_display_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
/** Open the colorize dialogue and presets the filter string.
|
||||
*
|
||||
* @param filter the preset filter string
|
||||
*/
|
||||
void color_display_with_filter(char *filter);
|
||||
|
||||
/** Count the number of selected color filters.
|
||||
*
|
||||
* @return the number of selected color filters
|
||||
*/
|
||||
int color_selected_count(void);
|
||||
|
||||
#endif /* color_dlg.h */
|
|
@ -1,663 +0,0 @@
|
|||
/* color_edit_dlg.c
|
||||
* Definitions for single color filter edit dialog boxes
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <epan/dfilter/dfilter.h>
|
||||
|
||||
#include <epan/color_filters.h>
|
||||
|
||||
#include "ui/simple_dialog.h"
|
||||
|
||||
#include "ui/gtk/color_dlg.h"
|
||||
#include "ui/gtk/color_utils.h"
|
||||
#include "ui/gtk/dlg_utils.h"
|
||||
#include "ui/gtk/stock_icons.h"
|
||||
#include "ui/gtk/filter_dlg.h"
|
||||
#include "ui/gtk/dfilter_expr_dlg.h"
|
||||
#include "ui/gtk/color_edit_dlg.h"
|
||||
#include "ui/gtk/filter_autocomplete.h"
|
||||
|
||||
#include "ui/gtk/old-gtk-compat.h"
|
||||
|
||||
|
||||
/* Essentially:
|
||||
*
|
||||
* There are two dialog windows:
|
||||
* - color_edit_dlg
|
||||
*
|
||||
* - color_selection_dlg (Gtk2) aka color_chooser_dlg (gtk 3.4 and newer).
|
||||
* The color_selection_dlg window can be instantiated (serially or in parallel)
|
||||
* to select the foreground and/or the background color for the filter.
|
||||
* The color_selection_dlg windows are 'transient_for' and 'destroyed_with'
|
||||
* the color_edit_dlg window.
|
||||
*
|
||||
*
|
||||
* The information needed by the various dlg callback functions is passed via
|
||||
* the callback 'user_data' parameter.
|
||||
*
|
||||
* There are two different structs passed via a pointer in 'user_data':
|
||||
* - (color_edit_dlg_info_t *)user_data
|
||||
* supplied to the color_edit_dlg Ok and Cancel button "clicked"
|
||||
* callbacks and to the color_edit_dlg "destroy" callback.
|
||||
*
|
||||
* - (color_selection_dlg_info_t *)user_data
|
||||
* supplied to the color_edit_dlg FG/BG button "clicked" and "destroy"
|
||||
* callbacks and to the color_selection_dlg "response" and "destroy" callbacks.
|
||||
*
|
||||
* Note that there are two separate instances of this struct:
|
||||
* - "foreground" info associated with the color_edit_dlg Foreground button;
|
||||
* - "background" info associated with the color_edit_dlg Background button.
|
||||
*/
|
||||
|
||||
static void color_edit_dlg_ok_cb(GtkWidget *w, gpointer user_data);
|
||||
static void color_edit_dlg_cancel_cb(GtkWidget *w, gpointer user_data);
|
||||
static void color_edit_dlg_destroy_cb(GObject *object, gpointer user_data);
|
||||
static void color_edit_dlg_fg_bg_btn_cb(GtkWidget *button, gpointer user_data);
|
||||
static void color_edit_dlg_fg_bg_btn_destroy_cb(GObject *object, gpointer user_data);
|
||||
|
||||
static void color_selection_dlg_response_cb(GtkWidget *color_selection_dlg, gint response, gpointer data);
|
||||
static void color_selection_dlg_destroy_cb(GObject *object, gpointer user_data);
|
||||
|
||||
typedef enum {
|
||||
COLOR_SELECTION_TYPE_FG = 1,
|
||||
COLOR_SELECTION_TYPE_BG = 2
|
||||
} color_selection_type_t;
|
||||
|
||||
/* info sent to color_edit_dlg Ok, cancel & destroy callbacks;
|
||||
* pointed to by colof->color_edit_dlg_info and by user_data for the callbacks
|
||||
*/
|
||||
struct _color_edit_dlg_info_t {
|
||||
GtkWidget *color_edit_dlg;
|
||||
GtkWidget *color_filters; /* Treeview */
|
||||
color_filter_t *colorf;
|
||||
/* color_edit_dlg widgets */
|
||||
GtkWidget *filt_name_entry;
|
||||
GtkWidget *filt_text_entry;
|
||||
GtkWidget *disabled_cb;
|
||||
};
|
||||
|
||||
/* info sent to color_edit_dlg FG/BG button callbacks and also to color_selection_dlg callbacks;
|
||||
* pointed by user data for the callbacks
|
||||
*/
|
||||
struct _color_selection_dlg_info_t {
|
||||
GtkWidget *color_selection_dlg;
|
||||
color_selection_type_t color_selection_type; /* FG/BG */
|
||||
color_filter_t *colorf;
|
||||
color_t *color; /* ptr to FG or BG color struct in colorf */
|
||||
const gchar *color_selection_type_text;
|
||||
GtkWidget *filt_name_entry;
|
||||
};
|
||||
typedef struct _color_selection_dlg_info_t color_selection_dlg_info_t;
|
||||
|
||||
|
||||
static void
|
||||
filter_expr_cb(GtkWidget *w _U_, gpointer filter_te)
|
||||
{
|
||||
dfilter_expr_dlg_new(GTK_WIDGET(filter_te));
|
||||
}
|
||||
|
||||
|
||||
/* Create "colorize filter" button for the "color edit" dialog, add it to hbox and connect callbacka */
|
||||
static void
|
||||
colorize_filter_new(GtkWidget *colorize_hbox,
|
||||
color_selection_type_t color_selection_type,
|
||||
const gchar *t1, /* "Foreground" */
|
||||
const gchar *t2, /* "Foreground Color..." */
|
||||
const gchar *t3, /* "Select foreground color for data display" */
|
||||
color_filter_t *colorf,
|
||||
color_t *color,
|
||||
GtkWidget *filt_name_entry)
|
||||
{
|
||||
GtkWidget *colorize_filter;
|
||||
color_selection_dlg_info_t *csdi;
|
||||
|
||||
colorize_filter = gtk_button_new_with_label(t2);
|
||||
gtk_box_pack_start (GTK_BOX (colorize_hbox), colorize_filter, TRUE, FALSE, 0);
|
||||
gtk_widget_set_tooltip_text(colorize_filter, t3);
|
||||
|
||||
csdi = g_new(color_selection_dlg_info_t, 1);
|
||||
csdi->color_selection_dlg = NULL;
|
||||
csdi->color_selection_type = color_selection_type;
|
||||
csdi->colorf = colorf;
|
||||
csdi->color = color;
|
||||
csdi->color_selection_type_text = t1;
|
||||
csdi->filt_name_entry = filt_name_entry;
|
||||
|
||||
g_signal_connect(colorize_filter, "clicked", G_CALLBACK(color_edit_dlg_fg_bg_btn_cb), csdi);
|
||||
g_signal_connect(colorize_filter, "destroy", G_CALLBACK(color_edit_dlg_fg_bg_btn_destroy_cb), csdi);
|
||||
}
|
||||
|
||||
|
||||
/* Create a "color edit dialog" for a given color filter, and
|
||||
associate it with that color filter. */
|
||||
void
|
||||
color_edit_dlg_new(GtkWidget *color_filters,
|
||||
gboolean is_new_filter)
|
||||
{
|
||||
color_edit_dlg_info_t *cedi;
|
||||
color_filter_t *colorf;
|
||||
|
||||
GtkWidget *color_edit_dlg;
|
||||
GtkWidget *dialog_vbox;
|
||||
GtkWidget *filter_fr;
|
||||
GtkWidget *filter_fr_vbox;
|
||||
GtkWidget *filter_name_hbox;
|
||||
GtkWidget *filt_name_entry;
|
||||
GtkWidget *filt_text_entry;
|
||||
GtkWidget *color_filter_name;
|
||||
GtkWidget *filter_string_hbox;
|
||||
GtkWidget *add_expression_bt;
|
||||
GtkWidget *color_filter_text;
|
||||
|
||||
GtkWidget *settings_hbox;
|
||||
|
||||
GtkWidget *colorize_fr;
|
||||
GtkWidget *colorize_hbox;
|
||||
|
||||
GtkWidget *status_fr;
|
||||
GtkWidget *status_vbox;
|
||||
|
||||
GtkWidget *disabled_cb;
|
||||
|
||||
GtkWidget *bbox;
|
||||
GtkWidget *edit_color_filter_ok;
|
||||
GtkWidget *edit_color_filter_cancel;
|
||||
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
|
||||
model = gtk_tree_view_get_model(GTK_TREE_VIEW(color_filters));
|
||||
|
||||
gtk_tree_model_iter_nth_child(model, &iter, NULL, color_dlg_row_selected);
|
||||
gtk_tree_model_get(model, &iter, 5, &colorf, -1);
|
||||
|
||||
if (colorf->color_edit_dlg_info != NULL) {
|
||||
cedi = (color_edit_dlg_info_t *)colorf->color_edit_dlg_info;
|
||||
g_assert(cedi->color_edit_dlg != NULL);
|
||||
/* There's already an edit box open for this filter; reactivate it. */
|
||||
reactivate_window(cedi->color_edit_dlg);
|
||||
return;
|
||||
}
|
||||
|
||||
/* dialog window */
|
||||
color_edit_dlg = dlg_conf_window_new ("Wireshark: Edit Color Filter");
|
||||
gtk_window_set_default_size(GTK_WINDOW(color_edit_dlg), 500, -1);
|
||||
/* XXX: set color_edit_dlg as 'modal' to prevent simultaneously opening
|
||||
* dialog windows for different filters ? is 'transient for' also needed ?
|
||||
*/
|
||||
|
||||
dialog_vbox = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);
|
||||
gtk_container_add (GTK_CONTAINER (color_edit_dlg), dialog_vbox);
|
||||
|
||||
/* Filter frame */
|
||||
filter_fr = gtk_frame_new("Filter");
|
||||
gtk_box_pack_start (GTK_BOX (dialog_vbox), filter_fr, FALSE, FALSE, 0);
|
||||
|
||||
filter_fr_vbox = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (filter_fr_vbox), 5);
|
||||
gtk_container_add(GTK_CONTAINER(filter_fr), filter_fr_vbox);
|
||||
|
||||
/* filter name hbox */
|
||||
filter_name_hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0, FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (filter_fr_vbox), filter_name_hbox, TRUE, FALSE, 3);
|
||||
|
||||
color_filter_name = gtk_label_new (("Name: "));
|
||||
gtk_box_pack_start (GTK_BOX (filter_name_hbox), color_filter_name, FALSE, FALSE, 0);
|
||||
|
||||
filt_name_entry = gtk_entry_new ();
|
||||
gtk_entry_set_text(GTK_ENTRY(filt_name_entry), colorf->filter_name);
|
||||
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
{
|
||||
GdkRGBA bg_rgba_color, fg_rgba_color;
|
||||
color_t_to_gdkRGBAcolor(&bg_rgba_color, &colorf->bg_color);
|
||||
color_t_to_gdkRGBAcolor(&fg_rgba_color, &colorf->fg_color);
|
||||
gtk_widget_override_background_color(filt_name_entry, GTK_STATE_FLAG_NORMAL, &bg_rgba_color);
|
||||
gtk_widget_override_color(filt_name_entry, GTK_STATE_FLAG_NORMAL, &fg_rgba_color);
|
||||
}
|
||||
#else
|
||||
{
|
||||
GdkColor bg_color, fg_color;
|
||||
color_t_to_gdkcolor(&bg_color, &colorf->bg_color);
|
||||
color_t_to_gdkcolor(&fg_color, &colorf->fg_color);
|
||||
|
||||
gtk_widget_modify_base(filt_name_entry, GTK_STATE_NORMAL, &bg_color);
|
||||
gtk_widget_modify_text(filt_name_entry, GTK_STATE_NORMAL, &fg_color);
|
||||
}
|
||||
#endif
|
||||
gtk_box_pack_start (GTK_BOX (filter_name_hbox), filt_name_entry, TRUE, TRUE, 0);
|
||||
gtk_widget_set_tooltip_text(filt_name_entry, "This is the editable name of the filter. (No @ characters allowed.)");
|
||||
|
||||
/* filter string hbox */
|
||||
filter_string_hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0, FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (filter_fr_vbox), filter_string_hbox, TRUE, FALSE, 3);
|
||||
|
||||
color_filter_text = gtk_label_new (("String: "));
|
||||
gtk_box_pack_start (GTK_BOX (filter_string_hbox), color_filter_text, FALSE, FALSE, 0);
|
||||
|
||||
filt_text_entry = gtk_entry_new ();
|
||||
g_signal_connect(filt_text_entry, "changed", G_CALLBACK(filter_te_syntax_check_cb), NULL);
|
||||
g_object_set_data(G_OBJECT(filter_string_hbox), E_FILT_AUTOCOMP_PTR_KEY, NULL);
|
||||
g_signal_connect(filt_text_entry, "key-press-event", G_CALLBACK (filter_string_te_key_pressed_cb), NULL);
|
||||
g_signal_connect(color_edit_dlg, "key-press-event", G_CALLBACK (filter_parent_dlg_key_pressed_cb), NULL);
|
||||
gtk_entry_set_text(GTK_ENTRY(filt_text_entry), colorf->filter_text);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (filter_string_hbox), filt_text_entry, TRUE, TRUE, 0);
|
||||
gtk_widget_set_tooltip_text(filt_text_entry, "This is the editable text of the filter");
|
||||
|
||||
/* Create the "Add Expression..." button, to pop up a dialog
|
||||
for constructing filter comparison expressions. */
|
||||
add_expression_bt = ws_gtk_button_new_from_stock(WIRESHARK_STOCK_ADD_EXPRESSION);
|
||||
g_signal_connect(add_expression_bt, "clicked", G_CALLBACK(filter_expr_cb), filt_text_entry);
|
||||
gtk_box_pack_start (GTK_BOX(filter_string_hbox), add_expression_bt, FALSE, FALSE, 3);
|
||||
gtk_widget_set_tooltip_text(add_expression_bt, "Add an expression to the filter string");
|
||||
|
||||
/* Show the (in)validity of the default filter string */
|
||||
filter_te_syntax_check_cb(filt_text_entry, NULL);
|
||||
|
||||
/* settings_hbox for "choose color frame" and "status frame" */
|
||||
settings_hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0, FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (dialog_vbox), settings_hbox, FALSE, FALSE, 0);
|
||||
|
||||
/* choose color frame */
|
||||
colorize_fr = gtk_frame_new("Display Colors");
|
||||
gtk_box_pack_start (GTK_BOX (settings_hbox), colorize_fr, TRUE, TRUE, 0);
|
||||
|
||||
colorize_hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0, FALSE);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (colorize_hbox), 5);
|
||||
gtk_container_add(GTK_CONTAINER(colorize_fr), colorize_hbox);
|
||||
|
||||
colorize_filter_new(colorize_hbox,
|
||||
COLOR_SELECTION_TYPE_FG,
|
||||
"Foreground", "Foreground Color...", "Select foreground color for data display",
|
||||
colorf, &colorf->fg_color,
|
||||
filt_name_entry);
|
||||
|
||||
colorize_filter_new(colorize_hbox,
|
||||
COLOR_SELECTION_TYPE_BG,
|
||||
"Background", "Background Color...", "Select background color for data display",
|
||||
colorf, &colorf->bg_color,
|
||||
filt_name_entry);
|
||||
|
||||
/* status frame */
|
||||
status_fr = gtk_frame_new("Status");
|
||||
gtk_box_pack_start (GTK_BOX (settings_hbox), status_fr, TRUE, TRUE, 0);
|
||||
|
||||
status_vbox = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (status_vbox), 5);
|
||||
gtk_container_add(GTK_CONTAINER(status_fr), status_vbox);
|
||||
|
||||
/** "Disabled" check box */
|
||||
disabled_cb = gtk_check_button_new_with_label("Disabled");
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(disabled_cb), colorf->disabled);
|
||||
gtk_box_pack_start (GTK_BOX (status_vbox), disabled_cb, TRUE, FALSE, 0);
|
||||
gtk_widget_set_tooltip_text(disabled_cb, "Color rule won't be checked if this box is selected");
|
||||
|
||||
/* button box */
|
||||
bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL);
|
||||
gtk_box_pack_start(GTK_BOX(dialog_vbox), bbox, FALSE, FALSE, 0);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (bbox), 0);
|
||||
|
||||
/** Cancel **/
|
||||
edit_color_filter_cancel = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
|
||||
gtk_widget_set_tooltip_text(edit_color_filter_cancel, "Reject filter color change");
|
||||
/* escape will select cancel */
|
||||
window_set_cancel_button(color_edit_dlg, edit_color_filter_cancel, window_cancel_button_cb);
|
||||
|
||||
/** Ok **/
|
||||
edit_color_filter_ok = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
|
||||
gtk_widget_set_tooltip_text(edit_color_filter_ok, "Accept filter color change");
|
||||
gtk_widget_grab_default(edit_color_filter_ok);
|
||||
|
||||
cedi = g_new(color_edit_dlg_info_t, 1);
|
||||
colorf->color_edit_dlg_info = cedi;
|
||||
|
||||
cedi->color_filters = color_filters;
|
||||
cedi->colorf = colorf;
|
||||
cedi->color_edit_dlg = color_edit_dlg;
|
||||
cedi->filt_name_entry = filt_name_entry;
|
||||
cedi->filt_text_entry = filt_text_entry;
|
||||
cedi->disabled_cb = disabled_cb;
|
||||
|
||||
g_signal_connect(color_edit_dlg, "destroy", G_CALLBACK(color_edit_dlg_destroy_cb), cedi);
|
||||
|
||||
g_signal_connect(edit_color_filter_ok, "clicked", G_CALLBACK(color_edit_dlg_ok_cb), cedi);
|
||||
|
||||
if (is_new_filter) {
|
||||
g_signal_connect(edit_color_filter_cancel, "clicked",
|
||||
G_CALLBACK(color_edit_dlg_cancel_cb), cedi);
|
||||
}
|
||||
|
||||
g_signal_connect(color_edit_dlg, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
||||
|
||||
gtk_widget_show_all(color_edit_dlg);
|
||||
window_present(color_edit_dlg);
|
||||
}
|
||||
|
||||
|
||||
/* accept color (and potential content) change */
|
||||
static void
|
||||
color_edit_dlg_ok_cb(GtkWidget *w _U_, gpointer user_data)
|
||||
{
|
||||
color_edit_dlg_info_t *cedi = (color_edit_dlg_info_t *)user_data;
|
||||
|
||||
gchar *filter_name;
|
||||
gchar *filter_text;
|
||||
gboolean filter_disabled;
|
||||
color_filter_t *colorf;
|
||||
dfilter_t *compiled_filter;
|
||||
gchar *err_msg;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
gchar fg_str[14], bg_str[14];
|
||||
|
||||
filter_name = g_strdup(gtk_entry_get_text(GTK_ENTRY(cedi->filt_name_entry)));
|
||||
filter_text = g_strdup(gtk_entry_get_text(GTK_ENTRY(cedi->filt_text_entry)));
|
||||
filter_disabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cedi->disabled_cb));
|
||||
|
||||
if (strchr(filter_name,'@') || strchr(filter_text,'@')) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Filter names and strings must not"
|
||||
" use the '@' character. Filter unchanged.");
|
||||
g_free(filter_name);
|
||||
g_free(filter_text);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!dfilter_compile(filter_text, &compiled_filter, &err_msg)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Filter \"%s\" didn't compile correctly.\n"
|
||||
" Please try again. Filter unchanged.\n%s\n", filter_name,
|
||||
err_msg);
|
||||
g_free(err_msg);
|
||||
g_free(filter_name);
|
||||
g_free(filter_text);
|
||||
return;
|
||||
}
|
||||
|
||||
colorf = cedi->colorf;
|
||||
|
||||
g_free(colorf->filter_name);
|
||||
g_free(colorf->filter_text);
|
||||
|
||||
colorf->filter_name = filter_name;
|
||||
colorf->filter_text = filter_text;
|
||||
|
||||
colorf->disabled = filter_disabled;
|
||||
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
{ /* GTK3 */
|
||||
GtkStyleContext *context;
|
||||
GdkRGBA new_rgba_fg_color;
|
||||
GdkRGBA new_rgba_bg_color;
|
||||
|
||||
context = gtk_widget_get_style_context (cedi->filt_name_entry);
|
||||
|
||||
gtk_style_context_get_color(context, (GtkStateFlags)GTK_STATE_NORMAL, &new_rgba_fg_color); /* aka foreground color */
|
||||
gtk_style_context_get_background_color(context, (GtkStateFlags)GTK_STATE_NORMAL, &new_rgba_bg_color);
|
||||
|
||||
gdkRGBAcolor_to_color_t(&colorf->fg_color, &new_rgba_fg_color);
|
||||
gdkRGBAcolor_to_color_t(&colorf->bg_color, &new_rgba_bg_color);
|
||||
}
|
||||
#else
|
||||
{ /* GTK2 */
|
||||
GtkStyle *style;
|
||||
GdkColor new_fg_color;
|
||||
GdkColor new_bg_color;
|
||||
|
||||
style = gtk_widget_get_style(cedi->filt_name_entry);
|
||||
new_bg_color = style->base[GTK_STATE_NORMAL];
|
||||
new_fg_color = style->text[GTK_STATE_NORMAL];
|
||||
|
||||
gdkcolor_to_color_t(&colorf->fg_color, &new_fg_color);
|
||||
gdkcolor_to_color_t(&colorf->bg_color, &new_bg_color);
|
||||
}
|
||||
#endif
|
||||
|
||||
g_snprintf(fg_str, sizeof(fg_str), "#%04X%04X%04X",
|
||||
colorf->fg_color.red, colorf->fg_color.green, colorf->fg_color.blue);
|
||||
g_snprintf(bg_str, sizeof(bg_str), "#%04X%04X%04X",
|
||||
colorf->bg_color.red, colorf->bg_color.green, colorf->bg_color.blue);
|
||||
|
||||
model = gtk_tree_view_get_model(GTK_TREE_VIEW(cedi->color_filters));
|
||||
gtk_tree_model_iter_nth_child(model, &iter, NULL, color_dlg_row_selected);
|
||||
gtk_list_store_set(GTK_LIST_STORE(model), &iter, 0, filter_name,
|
||||
1, filter_text, 2, fg_str, 3, bg_str,
|
||||
4, filter_disabled, -1);
|
||||
|
||||
dfilter_free(colorf->c_colorfilter);
|
||||
colorf->c_colorfilter = compiled_filter;
|
||||
|
||||
/* Destroy the dialog box. */
|
||||
window_destroy(cedi->color_edit_dlg);
|
||||
}
|
||||
|
||||
|
||||
/* reject new color filter addition */
|
||||
static void
|
||||
color_edit_dlg_cancel_cb(GtkWidget *w _U_, gpointer user_data)
|
||||
{
|
||||
color_edit_dlg_info_t *cedi = (color_edit_dlg_info_t *)user_data;
|
||||
|
||||
/* Delete the entry. As a side effect this destroys the edit_dialog window.
|
||||
Before the edit dialogue was launched, the color filter list was
|
||||
prepended with a default entry. This is the entry at position 0 that we
|
||||
want to delete now. */
|
||||
color_delete_single(0, cedi->color_filters); /* calls color_edit_dlg_destroy() */
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
color_edit_dlg_destroy(color_edit_dlg_info_t *cedi)
|
||||
{
|
||||
if (cedi == NULL) {
|
||||
return;
|
||||
}
|
||||
g_assert(cedi->color_edit_dlg != NULL);
|
||||
window_destroy(cedi->color_edit_dlg); /* invokes color_edit_dlg_destroy_cb */
|
||||
}
|
||||
|
||||
|
||||
/* Called when the color_edit_dlg is being destroyed;
|
||||
* null out the pointer to this dialog.
|
||||
* Note: any color_selection_dlg windows associated with
|
||||
* this color_edit_dlg window will automatically be destroyed.
|
||||
* (this is because the color_selection_dlg windows
|
||||
* have done 'set_transient_for() & destroy_with_parent()
|
||||
* ToDo: worry about 'order'
|
||||
*/
|
||||
static void
|
||||
color_edit_dlg_destroy_cb(GObject *object _U_, gpointer user_data)
|
||||
{
|
||||
color_edit_dlg_info_t *cedi = (color_edit_dlg_info_t *)user_data;
|
||||
|
||||
g_assert(cedi->color_edit_dlg);
|
||||
|
||||
cedi->colorf->color_edit_dlg_info = NULL;
|
||||
g_free(cedi);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Pop up a color selection (GTK3: color chooser) dialog to choose the foreground or background color. */
|
||||
static void
|
||||
color_edit_dlg_fg_bg_btn_cb(GtkWidget *button, gpointer user_data)
|
||||
{
|
||||
color_selection_dlg_info_t *csdi = (color_selection_dlg_info_t *)user_data;
|
||||
|
||||
GtkWidget *color_selection_dlg;
|
||||
|
||||
gchar *title;
|
||||
|
||||
/* Do we already have one open for this dialog? */
|
||||
if (csdi->color_selection_dlg != NULL) {
|
||||
/* Yes. Just reactivate it. */
|
||||
reactivate_window(csdi->color_selection_dlg);
|
||||
return;
|
||||
}
|
||||
|
||||
title = g_strdup_printf("Wireshark: Choose %s color for \"%s\"",
|
||||
csdi->color_selection_type_text,
|
||||
csdi->colorf->filter_name);
|
||||
|
||||
#if GTK_CHECK_VERSION(3,4,0)
|
||||
{ /* GTK >= GTK 3.4: Use GtkColorChooser */
|
||||
GdkRGBA rgba_color;
|
||||
color_selection_dlg = gtk_color_chooser_dialog_new(title, GTK_WINDOW(gtk_widget_get_toplevel(button)));
|
||||
csdi->color_selection_dlg = color_selection_dlg;
|
||||
|
||||
color_t_to_gdkRGBAcolor(&rgba_color, csdi->color);
|
||||
gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(color_selection_dlg), &rgba_color);
|
||||
}
|
||||
#else
|
||||
{ /* GTK < GTK 3.4: Use GtkColorSelection */
|
||||
GdkColor gcolor;
|
||||
GtkWidget *color_selection;
|
||||
GtkWidget *color_selection_dlg_help_btn;
|
||||
|
||||
color_selection_dlg = gtk_color_selection_dialog_new(title);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (color_selection_dlg), 10);
|
||||
gtk_window_set_transient_for(GTK_WINDOW(color_selection_dlg), GTK_WINDOW(gtk_widget_get_toplevel(button)));
|
||||
gtk_window_set_destroy_with_parent(GTK_WINDOW(color_selection_dlg), TRUE);
|
||||
|
||||
/* suppress the "help" button (brutally) */
|
||||
g_object_get(color_selection_dlg, "help-button", &color_selection_dlg_help_btn, NULL);
|
||||
gtk_widget_destroy(color_selection_dlg_help_btn);
|
||||
|
||||
color_selection =
|
||||
gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(color_selection_dlg));
|
||||
|
||||
color_t_to_gdkcolor(&gcolor, csdi->color);
|
||||
gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(color_selection), &gcolor);
|
||||
|
||||
csdi->color_selection_dlg = color_selection_dlg;
|
||||
}
|
||||
#endif /* GTK_CHECK(3,4,0) */
|
||||
|
||||
g_free(title);
|
||||
|
||||
g_signal_connect(G_OBJECT(color_selection_dlg), "response", G_CALLBACK(color_selection_dlg_response_cb), csdi);
|
||||
g_signal_connect(G_OBJECT(color_selection_dlg), "destroy", G_CALLBACK(color_selection_dlg_destroy_cb), csdi);
|
||||
|
||||
gtk_widget_show_all(color_selection_dlg);
|
||||
}
|
||||
|
||||
|
||||
/* here when color_edit_dlg FG/BG button destroyed */
|
||||
static void
|
||||
color_edit_dlg_fg_bg_btn_destroy_cb(GObject *object _U_, gpointer user_data)
|
||||
{
|
||||
color_selection_dlg_info_t *csdi = (color_selection_dlg_info_t *)user_data;
|
||||
|
||||
g_free(csdi);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
color_selection_dlg_response_cb(GtkWidget *color_selection_dlg, gint response, gpointer user_data)
|
||||
{
|
||||
color_selection_dlg_info_t *csdi = (color_selection_dlg_info_t *)user_data;
|
||||
|
||||
if (response != GTK_RESPONSE_OK) {
|
||||
window_destroy(color_selection_dlg);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Handle GTK_RESPONSE_OK */
|
||||
|
||||
#if GTK_CHECK_VERSION(3,4,0)
|
||||
{ /* GTK >= GTK 3.4: Using GtkColorChooser */
|
||||
GdkRGBA new_rgba_color;
|
||||
|
||||
gtk_color_chooser_get_rgba(GTK_COLOR_CHOOSER(color_selection_dlg), &new_rgba_color);
|
||||
|
||||
/* now apply the change to the fore/background */
|
||||
if (csdi->color_selection_type == COLOR_SELECTION_TYPE_FG)
|
||||
gtk_widget_override_color(csdi->filt_name_entry, GTK_STATE_FLAG_NORMAL, &new_rgba_color);
|
||||
else
|
||||
gtk_widget_override_background_color(csdi->filt_name_entry, GTK_STATE_FLAG_NORMAL, &new_rgba_color);
|
||||
}
|
||||
|
||||
#elif GTK_CHECK_VERSION(3,0,0)
|
||||
{ /* (GTK >= GTK 3.0) && (GTK < GTK 3.4): Using GtkColorSelection (RGBA Color) */
|
||||
GtkWidget *color_selection;
|
||||
GdkRGBA new_rgba_color;
|
||||
|
||||
color_selection =
|
||||
gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(color_selection_dlg));
|
||||
|
||||
gtk_color_selection_get_current_rgba(GTK_COLOR_SELECTION(color_selection), &new_rgba_color);
|
||||
|
||||
/* now apply the change to the fore/background */
|
||||
if (csdi->color_selection_type == COLOR_SELECTION_TYPE_FG)
|
||||
gtk_widget_override_color(csdi->filt_name_entry, GTK_STATE_FLAG_NORMAL, &new_rgba_color);
|
||||
else
|
||||
gtk_widget_override_background_color(csdi->filt_name_entry, GTK_STATE_FLAG_NORMAL, &new_rgba_color);
|
||||
}
|
||||
#else
|
||||
{ /* GTK2: Using GtkColorSelection (GDK Color) */
|
||||
GtkWidget *color_selection;
|
||||
GdkColor new_color;
|
||||
|
||||
color_selection =
|
||||
gtk_color_selection_dialog_get_color_selection(GTK_COLOR_SELECTION_DIALOG(color_selection_dlg));
|
||||
|
||||
gtk_color_selection_get_current_color(GTK_COLOR_SELECTION(color_selection), &new_color);
|
||||
|
||||
/* now apply the change to the fore/background */
|
||||
if (csdi->color_selection_type == COLOR_SELECTION_TYPE_FG)
|
||||
gtk_widget_modify_text(csdi->filt_name_entry, GTK_STATE_NORMAL, &new_color);
|
||||
else
|
||||
gtk_widget_modify_base(csdi->filt_name_entry, GTK_STATE_NORMAL, &new_color);
|
||||
}
|
||||
#endif /* GTK_CHECK_VERSION(3,4,0) */
|
||||
|
||||
window_destroy(color_selection_dlg);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
color_selection_dlg_destroy_cb(GObject *object _U_, gpointer user_data)
|
||||
{
|
||||
color_selection_dlg_info_t *csdi = (color_selection_dlg_info_t *)user_data;
|
||||
|
||||
g_assert(csdi->color_selection_dlg);
|
||||
|
||||
csdi->color_selection_dlg = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 2
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=2 tabstop=8 expandtab:
|
||||
* :indentSize=2:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -1,49 +0,0 @@
|
|||
/* color_edit_dlg.h
|
||||
* Definitions for dialog boxes for color filters
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __COLOR_EDIT_DLG_H__
|
||||
#define __COLOR_EDIT_DLG_H__
|
||||
|
||||
/** @file
|
||||
* "Colorize Edit Display" dialog box.
|
||||
* @ingroup dialog_group
|
||||
*/
|
||||
|
||||
struct _color_edit_dlg_info_t;
|
||||
|
||||
typedef struct _color_edit_dlg_info_t color_edit_dlg_info_t;
|
||||
|
||||
/* new color filter edit dialog */
|
||||
extern void
|
||||
color_edit_dlg_new(GtkWidget *color_filters,
|
||||
gboolean is_new_filter);
|
||||
|
||||
#if 1 /* doesn't really belong here */
|
||||
/* edit dialog wants to destroy itself */
|
||||
extern void
|
||||
color_delete_single(gint row, GtkWidget *color_filters);
|
||||
#endif
|
||||
|
||||
extern void
|
||||
color_edit_dlg_destroy(color_edit_dlg_info_t *cedi);
|
||||
|
||||
#endif /* color_edit_dlg.h */
|
|
@ -1,95 +0,0 @@
|
|||
/* color_utils.c
|
||||
* GTK+ color conversion routines.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "ui/gtk/color_utils.h"
|
||||
|
||||
void
|
||||
color_t_to_gdkcolor(GdkColor *target, const color_t *source)
|
||||
{
|
||||
target->pixel = 0;
|
||||
target->red = source->red;
|
||||
target->green = source->green;
|
||||
target->blue = source->blue;
|
||||
}
|
||||
|
||||
void
|
||||
color_t_to_gdkRGBAcolor(GdkRGBA *target, const color_t *source)
|
||||
{
|
||||
target->alpha = 1;
|
||||
target->red = source->red / 65535.0;
|
||||
target->green = source->green / 65535.0;
|
||||
target->blue = source->blue / 65535.0;
|
||||
}
|
||||
|
||||
void
|
||||
gdkcolor_to_color_t(color_t *target, const GdkColor *source)
|
||||
{
|
||||
target->red = source->red;
|
||||
target->green = source->green;
|
||||
target->blue = source->blue;
|
||||
}
|
||||
|
||||
void
|
||||
gdkRGBAcolor_to_color_t(color_t *target, const GdkRGBA *source)
|
||||
{
|
||||
target->red = (guint16)(source->red*65535);
|
||||
target->green = (guint16)(source->green*65535);
|
||||
target->blue = (guint16)(source->blue*65535);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
GdkColor_to_GdkRGBA(GdkRGBA *target, const GdkColor *source)
|
||||
{
|
||||
target->alpha = 1;
|
||||
target->red = (double)source->red / 65535.0;
|
||||
target->green = (double)source->green / 65535.0;
|
||||
target->blue = (double)source->blue / 65535.0;
|
||||
}
|
||||
|
||||
void
|
||||
gdkRGBAcolor_to_GdkColor(GdkColor *target, const GdkRGBA *source)
|
||||
{
|
||||
target->pixel = 0;
|
||||
target->red = (guint16)(source->red*65535);
|
||||
target->green = (guint16)(source->green*65535);
|
||||
target->blue = (guint16)(source->blue*65535);
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
||||
* :indentSize=8:tabSize=8:noTabs=false:
|
||||
*/
|
|
@ -1,74 +0,0 @@
|
|||
/* color_utils.h
|
||||
* Definitions for GTK+ color conversion routines.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __COLOR_UTILS_H__
|
||||
#define __COLOR_UTILS_H__
|
||||
|
||||
#include "ui/gtk/gui_utils.h"
|
||||
#include <wsutil/color.h>
|
||||
|
||||
/** @file
|
||||
* Definitions for color structures and routines
|
||||
*/
|
||||
|
||||
/** Convert color_t to GdkColor.
|
||||
*
|
||||
* @param target the GdkColor to be filled
|
||||
* @param source the source color_t
|
||||
*/
|
||||
void color_t_to_gdkcolor(GdkColor *target, const color_t *source);
|
||||
|
||||
/** Convert color_t to GdkRGBA.
|
||||
*
|
||||
* @param target the GdkRGBA to be filled
|
||||
* @param source the source color_t
|
||||
*/
|
||||
void color_t_to_gdkRGBAcolor(GdkRGBA *target, const color_t *source);
|
||||
|
||||
/** Convert GdkColor to color_t.
|
||||
*
|
||||
* @param target the source color_t
|
||||
* @param source the GdkColor to be filled
|
||||
*/
|
||||
void gdkcolor_to_color_t(color_t *target, const GdkColor *source);
|
||||
|
||||
/** Convert GdkRGBA to color_t.
|
||||
*
|
||||
* @param target the source color_t
|
||||
* @param source the GdkRGBA to be filled
|
||||
*/
|
||||
void gdkRGBAcolor_to_color_t(color_t *target, const GdkRGBA *source);
|
||||
|
||||
/** Convert GdkColor to GdkRGBA.
|
||||
*
|
||||
* @param target the source GdkColor
|
||||
* @param source the GdkRGBA to be filled
|
||||
*/
|
||||
void GdkColor_to_GdkRGBA(GdkRGBA *target, const GdkColor *source);
|
||||
|
||||
/** Convert GdkRGBA to GdkColor.
|
||||
*
|
||||
* @param target the source GdkColor
|
||||
* @param source the GdkRGBA to be filled
|
||||
*/
|
||||
void gdkRGBAcolor_to_GdkColor(GdkColor *target, const GdkRGBA *source);
|
||||
#endif /* __COLOR_UTILS_H__ */
|
File diff suppressed because it is too large
Load Diff
|
@ -1,176 +0,0 @@
|
|||
/* conversation_hastables_dlg.c
|
||||
* Show conversation hastable info
|
||||
*
|
||||
* Copyright 2013 Anders Broman <anders.broman@ericsson.com>
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <epan/conversation.h>
|
||||
|
||||
|
||||
#include "ui/gtk/dlg_utils.h"
|
||||
#include "ui/gtk/font_utils.h"
|
||||
#include "ui/gtk/gui_utils.h"
|
||||
#include "ui/gtk/conversation_hastables_dlg.h"
|
||||
|
||||
static GtkWidget *conversation_hastables_dlg_w = NULL;
|
||||
|
||||
#define CONV_STR_BUF_MAX 1024
|
||||
|
||||
static void
|
||||
conversation_hashtable_exact_to_texbuff(gpointer key, gpointer value _U_, gpointer user_data)
|
||||
{
|
||||
gchar string_buff[CONV_STR_BUF_MAX];
|
||||
GtkTextBuffer *buffer = (GtkTextBuffer*)user_data;
|
||||
|
||||
g_snprintf(string_buff, CONV_STR_BUF_MAX, "Key:0x%x\n",conversation_hash_exact(key));
|
||||
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
conversation_info_to_texbuff(GtkTextBuffer *buffer)
|
||||
{
|
||||
gchar string_buff[CONV_STR_BUF_MAX];
|
||||
wmem_map_t *conversation_hashtable_exact;
|
||||
wmem_map_t *conversation_hashtable_no_addr2;
|
||||
wmem_map_t *conversation_hashtable_no_port2;
|
||||
wmem_map_t *conversation_hashtable_no_addr2_or_port2;
|
||||
|
||||
g_snprintf(string_buff, CONV_STR_BUF_MAX, "Conversation hastables info:\n");
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
|
||||
conversation_hashtable_exact = get_conversation_hashtable_exact();
|
||||
if(conversation_hashtable_exact){
|
||||
g_snprintf(string_buff, CONV_STR_BUF_MAX, "conversation_hashtable_exact %i entries\n#\n",
|
||||
wmem_map_size(conversation_hashtable_exact));
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
wmem_map_foreach( conversation_hashtable_exact, conversation_hashtable_exact_to_texbuff, buffer);
|
||||
}
|
||||
|
||||
conversation_hashtable_no_addr2 = get_conversation_hashtable_no_addr2();
|
||||
if(conversation_hashtable_no_addr2){
|
||||
g_snprintf(string_buff, CONV_STR_BUF_MAX, "conversation_hashtable_no_addr2 %i entries\n#\n",
|
||||
wmem_map_size(conversation_hashtable_no_addr2));
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
|
||||
}
|
||||
|
||||
conversation_hashtable_no_port2 = get_conversation_hashtable_no_port2();
|
||||
if(conversation_hashtable_no_port2){
|
||||
g_snprintf(string_buff, CONV_STR_BUF_MAX, "conversation_hashtable_no_port2 %i entries\n#\n",
|
||||
wmem_map_size(conversation_hashtable_no_port2));
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
|
||||
}
|
||||
|
||||
conversation_hashtable_no_addr2_or_port2 = get_conversation_hashtable_no_addr2_or_port2();
|
||||
if(conversation_hashtable_no_addr2_or_port2){
|
||||
g_snprintf(string_buff, CONV_STR_BUF_MAX, "conversation_hashtable_no_addr2_or_port2 %i entries\n#\n",
|
||||
wmem_map_size(conversation_hashtable_no_addr2_or_port2));
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
conversation_hastables_dlg (GtkAction *action _U_, gpointer data _U_)
|
||||
{
|
||||
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *view;
|
||||
GtkWidget *scroll;
|
||||
GtkWidget *bbox;
|
||||
GtkWidget *ok_bt, *cancel_bt, *help_bt;
|
||||
GtkTextBuffer *buffer;
|
||||
|
||||
conversation_hastables_dlg_w = dlg_window_new ("Conversation hastables");
|
||||
gtk_widget_set_size_request (conversation_hastables_dlg_w, 750, 350);
|
||||
gtk_window_set_resizable (GTK_WINDOW (conversation_hastables_dlg_w), TRUE);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (conversation_hastables_dlg_w), DLG_OUTER_MARGIN);
|
||||
|
||||
vbox = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, DLG_UNRELATED_SPACING, FALSE);
|
||||
gtk_container_add (GTK_CONTAINER (conversation_hastables_dlg_w), vbox);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
view = gtk_text_view_new ();
|
||||
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_WORD);
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
gtk_widget_override_font(view, user_font_get_regular());
|
||||
#else
|
||||
gtk_widget_modify_font(view, user_font_get_regular());
|
||||
#endif
|
||||
gtk_widget_show (view);
|
||||
|
||||
scroll = gtk_scrolled_window_new(NULL, NULL);
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
|
||||
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
||||
gtk_container_add(GTK_CONTAINER(scroll), view);
|
||||
gtk_widget_show(scroll);
|
||||
gtk_box_pack_start(GTK_BOX (vbox), scroll, TRUE, TRUE, 0);
|
||||
|
||||
/* Get the address list */
|
||||
conversation_info_to_texbuff(buffer);
|
||||
|
||||
/* Button row. */
|
||||
bbox = dlg_button_row_new (GTK_STOCK_OK, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
|
||||
gtk_box_pack_end (GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
|
||||
|
||||
ok_bt = (GtkWidget *)g_object_get_data (G_OBJECT(bbox), GTK_STOCK_OK);
|
||||
/*g_signal_connect (ok_bt, "clicked", G_CALLBACK(pkt_comment_text_buff_ok_cb), view);*/
|
||||
gtk_widget_set_sensitive (ok_bt, TRUE);
|
||||
|
||||
cancel_bt = (GtkWidget *)g_object_get_data (G_OBJECT(bbox), GTK_STOCK_CANCEL);
|
||||
window_set_cancel_button (conversation_hastables_dlg_w, cancel_bt, window_cancel_button_cb);
|
||||
|
||||
help_bt = (GtkWidget *)g_object_get_data (G_OBJECT(bbox), GTK_STOCK_HELP);
|
||||
#if 0
|
||||
g_signal_connect (help_bt, "clicked",/* G_CALLBACK(topic_cb)*/NULL, /*(gpointer)HELP_MANUAL_ADDR_RESOLVE_DIALOG*/NULL);
|
||||
#endif
|
||||
gtk_widget_set_sensitive (help_bt, FALSE);
|
||||
|
||||
gtk_widget_grab_default (ok_bt);
|
||||
/*g_signal_connect (conversation_hastables_dlg_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);*/
|
||||
|
||||
|
||||
gtk_widget_show (conversation_hastables_dlg_w);
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines
|
||||
*
|
||||
* Local Variables:
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* ex: set shiftwidth=4 tabstop=8 expandtab:
|
||||
* :indentSize=4:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -1,30 +0,0 @@
|
|||
/* conversation_hastables_dlg.h
|
||||
* Show current addres resolution as a hosts file
|
||||
*
|
||||
* Copyright 2013 Anders Broman <anders.broman@ericsson.com>
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __CONVERSATION_HASTABLES_DLG_H__
|
||||
#define __CONVERSATION_HASTABLES_DLG_H__
|
||||
|
||||
void conversation_hastables_dlg (GtkAction *action, gpointer data);
|
||||
|
||||
#endif /* __conversation_hastables_dlg_H__ */
|
File diff suppressed because it is too large
Load Diff
|
@ -1,76 +0,0 @@
|
|||
/* conversations_table.h
|
||||
* conversations_table 2003 Ronnie Sahlberg
|
||||
* Helper routines common to all conversations taps.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __CONVERSATIONS_TABLE_H__
|
||||
#define __CONVERSATIONS_TABLE_H__
|
||||
|
||||
#include <epan/conv_id.h>
|
||||
#include <epan/conversation_table.h>
|
||||
#include <ui/traffic_table_ui.h>
|
||||
|
||||
/** @file
|
||||
* Conversation definitions.
|
||||
*/
|
||||
|
||||
/** Conversation widget */
|
||||
typedef struct _conversations_table {
|
||||
const char *name; /**< the name of the table */
|
||||
const char *filter; /**< the filter used */
|
||||
gboolean use_dfilter; /**< use display filter */
|
||||
GtkWidget *win; /**< GTK window */
|
||||
GtkWidget *page_lb; /**< page label */
|
||||
GtkWidget *name_lb; /**< name label */
|
||||
GtkWidget *scrolled_window; /**< the scrolled window */
|
||||
GtkTreeView *table; /**< the GTK table */
|
||||
const char *default_titles[14]; /**< Column headers */
|
||||
GtkWidget *menu; /**< context menu */
|
||||
gboolean has_ports; /**< table has ports */
|
||||
conv_hash_t hash; /**< conversations hash table */
|
||||
|
||||
gboolean fixed_col; /**< if switched to fixed column */
|
||||
gboolean resolve_names; /**< resolve address names? */
|
||||
|
||||
int reselection_idx; /**< conversation index to reselect */
|
||||
} conversations_table;
|
||||
|
||||
/** Init the conversation table for the single conversation window.
|
||||
*
|
||||
* @param ct the registered conversation
|
||||
* @param filter the optional filter name or NULL
|
||||
*/
|
||||
extern void init_conversation_table(struct register_ct* ct, const char *filter);
|
||||
|
||||
/** Callback for "Conversations" statistics item.
|
||||
*
|
||||
* @param widget unused
|
||||
* @param data unused
|
||||
*/
|
||||
extern void init_conversation_notebook_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
/** Function called to instantiate the "GTK conversation table display"
|
||||
*
|
||||
* @param table conversation table to be created
|
||||
*/
|
||||
extern void conversation_endpoint_cb(register_ct_t* table);
|
||||
|
||||
#endif /* __CONVERSATIONS_TABLE_H__ */
|
|
@ -1,689 +0,0 @@
|
|||
/* dcerpc_stat.c
|
||||
* dcerpc_stat 2002 Ronnie Sahlberg
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/* This module provides rpc call/reply SRT statistics to Wireshark,
|
||||
* and displays them graphically.
|
||||
* It is only used by Wireshark and not tshark
|
||||
*
|
||||
* It serves as an example on how to use the tap api.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <epan/packet_info.h>
|
||||
#include <epan/stat_tap_ui.h>
|
||||
#include <epan/tap.h>
|
||||
#include <epan/dissectors/packet-dcerpc.h>
|
||||
|
||||
#include "ui/simple_dialog.h"
|
||||
|
||||
#include "ui/gtk/gui_stat_menu.h"
|
||||
#include "ui/gtk/dlg_utils.h"
|
||||
#include "ui/gtk/gui_utils.h"
|
||||
#include "ui/gtk/filter_dlg.h"
|
||||
#include "ui/gtk/stock_icons.h"
|
||||
#include "ui/gtk/service_response_time_table.h"
|
||||
#include "ui/gtk/gtkglobals.h"
|
||||
#include "ui/gtk/main.h"
|
||||
#include "ui/gtk/filter_autocomplete.h"
|
||||
|
||||
#include "ui/gtk/old-gtk-compat.h"
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
void register_tap_listener_gtkdcerpcstat(void);
|
||||
|
||||
/* used to keep track of the statistics for an entire program interface */
|
||||
typedef struct _dcerpcstat_t {
|
||||
const char *prog;
|
||||
guint16 ver;
|
||||
gtk_srt_t gtk_data;
|
||||
register_srt_t* srt;
|
||||
srt_data_t data;
|
||||
} dcerpcstat_t;
|
||||
|
||||
|
||||
static char *
|
||||
dcerpcstat_gen_title(dcerpcstat_t *rs)
|
||||
{
|
||||
char *title;
|
||||
char *display_name;
|
||||
|
||||
display_name = cf_get_display_name(&cfile);
|
||||
title = g_strdup_printf("DCE-RPC Service Response Time statistics for %s major version %u: %s", rs->prog, rs->ver, display_name);
|
||||
g_free(display_name);
|
||||
return title;
|
||||
}
|
||||
|
||||
static void
|
||||
dcerpcstat_set_title(dcerpcstat_t *rs)
|
||||
{
|
||||
char *title;
|
||||
|
||||
title = dcerpcstat_gen_title(rs);
|
||||
gtk_window_set_title(GTK_WINDOW(rs->gtk_data.win), title);
|
||||
g_free(title);
|
||||
}
|
||||
|
||||
static void
|
||||
dcerpcstat_reset(void *rs_arg)
|
||||
{
|
||||
srt_data_t *srt = (srt_data_t*)rs_arg;
|
||||
dcerpcstat_t *rs = (dcerpcstat_t *)srt->user_data;
|
||||
|
||||
reset_srt_table(rs->data.srt_array, reset_table_data, &rs->gtk_data);
|
||||
|
||||
dcerpcstat_set_title(rs);
|
||||
}
|
||||
|
||||
static void
|
||||
dcerpcstat_draw(void *rs_arg)
|
||||
{
|
||||
guint i = 0;
|
||||
srt_stat_table *srt_table;
|
||||
srt_data_t *srt = (srt_data_t*)rs_arg;
|
||||
dcerpcstat_t *rs = (dcerpcstat_t *)srt->user_data;
|
||||
|
||||
for (i = 0; i < srt->srt_array->len; i++)
|
||||
{
|
||||
srt_table = g_array_index(srt->srt_array, srt_stat_table*, i);
|
||||
draw_srt_table_data(srt_table, &rs->gtk_data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
win_destroy_cb(GtkWindow *win _U_, gpointer data)
|
||||
{
|
||||
dcerpcstat_t *rs = (dcerpcstat_t *)data;
|
||||
|
||||
remove_tap_listener(&rs->data);
|
||||
|
||||
free_srt_table(rs->srt, rs->data.srt_array, free_table_data, &rs->gtk_data);
|
||||
g_free(rs);
|
||||
}
|
||||
|
||||
/* When called, this function will create a new instance of gtk-dcerpcstat.
|
||||
*/
|
||||
static void
|
||||
gtk_dcerpcstat_init(const char *opt_arg, void* userdata _U_)
|
||||
{
|
||||
dcerpcstat_t *rs;
|
||||
guint32 i, max_procs;
|
||||
char *title_string;
|
||||
char *filter_string;
|
||||
GtkWidget *stat_label;
|
||||
GtkWidget *filter_label;
|
||||
GtkWidget *bbox;
|
||||
GtkWidget *close_bt;
|
||||
dcerpc_sub_dissector *procs;
|
||||
e_guid_t uuid;
|
||||
guint d1,d2,d3,d40,d41,d42,d43,d44,d45,d46,d47;
|
||||
int major, minor;
|
||||
guint16 ver;
|
||||
int pos = 0;
|
||||
const char *filter = NULL;
|
||||
dcerpcstat_tap_data_t* tap_data;
|
||||
GString *error_string;
|
||||
|
||||
/*
|
||||
* XXX - DCE RPC statistics are maintained only by major version,
|
||||
* not by major and minor version, so the minor version number is
|
||||
* ignored.
|
||||
*
|
||||
* Should we just stop supporting minor version numbers here?
|
||||
* Or should we allow it to be omitted? Or should we keep
|
||||
* separate statistics for different minor version numbers,
|
||||
* and allow the minor version number to be omitted, and
|
||||
* report aggregate statistics for all minor version numbers
|
||||
* if it's omitted?
|
||||
*/
|
||||
if(sscanf(
|
||||
opt_arg,
|
||||
"dcerpc,srt,%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x,%d.%d,%n",
|
||||
&d1,&d2,&d3,&d40,&d41,&d42,&d43,&d44,&d45,&d46,&d47,&major,&minor,&pos)
|
||||
== 13) {
|
||||
uuid.data1 = d1;
|
||||
uuid.data2 = d2;
|
||||
uuid.data3 = d3;
|
||||
uuid.data4[0] = d40;
|
||||
uuid.data4[1] = d41;
|
||||
uuid.data4[2] = d42;
|
||||
uuid.data4[3] = d43;
|
||||
uuid.data4[4] = d44;
|
||||
uuid.data4[5] = d45;
|
||||
uuid.data4[6] = d46;
|
||||
uuid.data4[7] = d47;
|
||||
if(pos) {
|
||||
filter = opt_arg+pos;
|
||||
} else {
|
||||
filter = NULL;
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "wireshark: invalid \"-z dcerpc,srt,<uuid>,<major version>.<minor version>[,<filter>]\" argument\n");
|
||||
exit(1);
|
||||
}
|
||||
if ((major < 0) || (major > 65535)) {
|
||||
fprintf(stderr,"wireshark: dcerpcstat_init() Major version number %d is invalid - must be positive and <= 65535\n", major);
|
||||
exit(1);
|
||||
}
|
||||
if ((minor < 0) || (minor > 65535)) {
|
||||
fprintf(stderr,"wireshark: dcerpcstat_init() Minor version number %d is invalid - must be positive and <= 65535\n", minor);
|
||||
exit(1);
|
||||
}
|
||||
ver = major;
|
||||
|
||||
rs = (dcerpcstat_t *)g_malloc0(sizeof(dcerpcstat_t));
|
||||
rs->prog = dcerpc_get_proto_name(&uuid, ver);
|
||||
if(!rs->prog){
|
||||
g_free(rs);
|
||||
fprintf(stderr,
|
||||
"wireshark: dcerpcstat_init() Protocol with uuid:%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x v%u not supported\n",
|
||||
uuid.data1,uuid.data2,uuid.data3,uuid.data4[0],uuid.data4[1],uuid.data4[2],uuid.data4[3],uuid.data4[4],uuid.data4[5],uuid.data4[6],uuid.data4[7],ver);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
procs = dcerpc_get_proto_sub_dissector(&uuid, ver);
|
||||
rs->ver = ver;
|
||||
|
||||
rs->gtk_data.win = dlg_window_new("dcerpc-stat"); /* transient_for top_level */
|
||||
gtk_window_set_destroy_with_parent(GTK_WINDOW(rs->gtk_data.win), TRUE);
|
||||
|
||||
dcerpcstat_set_title(rs);
|
||||
gtk_window_set_default_size(GTK_WINDOW(rs->gtk_data.win), SRT_PREFERRED_WIDTH, SRT_PREFERRED_HEIGHT);
|
||||
|
||||
rs->gtk_data.vbox =ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
|
||||
gtk_container_add(GTK_CONTAINER(rs->gtk_data.win), rs->gtk_data.vbox);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(rs->gtk_data.vbox), 12);
|
||||
|
||||
title_string = dcerpcstat_gen_title(rs);
|
||||
stat_label = gtk_label_new(title_string);
|
||||
g_free(title_string);
|
||||
gtk_box_pack_start(GTK_BOX(rs->gtk_data.vbox), stat_label, FALSE, FALSE, 0);
|
||||
|
||||
filter_string = g_strdup_printf("Filter: %s",filter ? filter : "");
|
||||
filter_label = gtk_label_new(filter_string);
|
||||
g_free(filter_string);
|
||||
gtk_label_set_line_wrap(GTK_LABEL(filter_label), TRUE);
|
||||
gtk_box_pack_start(GTK_BOX(rs->gtk_data.vbox), filter_label, FALSE, FALSE, 0);
|
||||
|
||||
/* We must display TOP LEVEL Widget before calling init_gtk_srt_table() */
|
||||
gtk_widget_show_all(rs->gtk_data.win);
|
||||
|
||||
rs->srt = get_srt_table_by_name("dcerpc");
|
||||
|
||||
|
||||
for(i=0,max_procs=0;procs[i].name;i++){
|
||||
if(procs[i].num>max_procs){
|
||||
max_procs = procs[i].num;
|
||||
}
|
||||
}
|
||||
|
||||
/* Setup the tap data */
|
||||
tap_data = g_new0(dcerpcstat_tap_data_t, 1);
|
||||
|
||||
tap_data->uuid = uuid;
|
||||
tap_data->prog = dcerpc_get_proto_name(&tap_data->uuid, ver);
|
||||
tap_data->ver = ver;
|
||||
tap_data->num_procedures = max_procs+1;
|
||||
|
||||
set_srt_table_param_data(rs->srt, tap_data);
|
||||
|
||||
rs->gtk_data.gtk_srt_array = g_array_new(FALSE, TRUE, sizeof(gtk_srt_table_t*));
|
||||
rs->data.srt_array = g_array_new(FALSE, TRUE, sizeof(srt_stat_table*));
|
||||
rs->data.user_data = rs;
|
||||
|
||||
srt_table_dissector_init(rs->srt, rs->data.srt_array, init_gtk_srt_table, &rs->gtk_data);
|
||||
|
||||
error_string = register_tap_listener("dcerpc", &rs->data, filter, 0, dcerpcstat_reset, get_srt_packet_func(rs->srt), dcerpcstat_draw);
|
||||
if(error_string){
|
||||
/* error, we failed to attach to the tap. clean up */
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str);
|
||||
g_string_free(error_string, TRUE);
|
||||
free_srt_table(rs->srt, rs->data.srt_array, NULL, NULL);
|
||||
g_free(rs);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Button row. */
|
||||
bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
|
||||
gtk_box_pack_end(GTK_BOX(rs->gtk_data.vbox), bbox, FALSE, FALSE, 0);
|
||||
|
||||
close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
|
||||
window_set_cancel_button(rs->gtk_data.win, close_bt, window_cancel_button_cb);
|
||||
|
||||
g_signal_connect(rs->gtk_data.win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
||||
g_signal_connect(rs->gtk_data.win, "destroy", G_CALLBACK(win_destroy_cb), rs);
|
||||
|
||||
gtk_widget_show_all(rs->gtk_data.win);
|
||||
window_present(rs->gtk_data.win);
|
||||
|
||||
cf_retap_packets(&cfile);
|
||||
gdk_window_raise(gtk_widget_get_window(rs->gtk_data.win));
|
||||
}
|
||||
|
||||
|
||||
|
||||
static e_guid_t *dcerpc_uuid_program;
|
||||
static guint16 dcerpc_version;
|
||||
static GtkWidget *dlg = NULL;
|
||||
static GtkWidget *filter_entry;
|
||||
static guid_key *current_uuid_key;
|
||||
static dcerpc_uuid_value *current_uuid_value;
|
||||
static guid_key *new_uuid_key;
|
||||
static dcerpc_uuid_value *new_uuid_value;
|
||||
|
||||
static void
|
||||
dcerpcstat_start_button_clicked(GtkWidget *item _U_, gpointer data _U_)
|
||||
{
|
||||
GString *str;
|
||||
const char *filter;
|
||||
|
||||
if (dcerpc_uuid_program == NULL) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Please select a program");
|
||||
return;
|
||||
}
|
||||
str = g_string_new("dcerpc,srt");
|
||||
g_string_append_printf(str,
|
||||
",%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x,%u.%u",
|
||||
dcerpc_uuid_program->data1, dcerpc_uuid_program->data2,
|
||||
dcerpc_uuid_program->data3,
|
||||
dcerpc_uuid_program->data4[0], dcerpc_uuid_program->data4[1],
|
||||
dcerpc_uuid_program->data4[2], dcerpc_uuid_program->data4[3],
|
||||
dcerpc_uuid_program->data4[4], dcerpc_uuid_program->data4[5],
|
||||
dcerpc_uuid_program->data4[6], dcerpc_uuid_program->data4[7],
|
||||
dcerpc_version, 0);
|
||||
filter = gtk_entry_get_text(GTK_ENTRY(filter_entry));
|
||||
if(filter[0] != 0){
|
||||
g_string_append_printf(str, ",%s", filter);
|
||||
}
|
||||
|
||||
gtk_dcerpcstat_init(str->str,NULL);
|
||||
g_string_free(str, TRUE);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dcerpcstat_version_select(GtkWidget *vers_combo_box, gpointer user_data _U_)
|
||||
{
|
||||
guid_key *k;
|
||||
|
||||
if (! ws_combo_box_get_active_pointer(GTK_COMBO_BOX(vers_combo_box), (gpointer *)&k)) {
|
||||
g_assert_not_reached(); /* Programming error: somehow no active item */
|
||||
}
|
||||
|
||||
dcerpc_version = k->ver;
|
||||
}
|
||||
|
||||
static void
|
||||
dcerpcstat_find_vers(gpointer *key, gpointer *value _U_, gpointer user_data)
|
||||
{
|
||||
guid_key *k = (guid_key *)key;
|
||||
GtkWidget *vers_combo_box = (GtkWidget *)user_data;
|
||||
char vs[5];
|
||||
|
||||
if(guid_cmp(&(k->guid), dcerpc_uuid_program)){
|
||||
return;
|
||||
}
|
||||
g_snprintf(vs, sizeof(vs), "%u", k->ver);
|
||||
ws_combo_box_append_text_and_pointer(GTK_COMBO_BOX(vers_combo_box), vs, k);
|
||||
}
|
||||
|
||||
static void
|
||||
dcerpcstat_program_select(GtkWidget *prog_combo_box, gpointer user_data)
|
||||
{
|
||||
guid_key *k;
|
||||
GtkWidget *vers_combo_box;
|
||||
|
||||
vers_combo_box = (GtkWidget *)user_data;
|
||||
|
||||
if (! ws_combo_box_get_active_pointer(GTK_COMBO_BOX(prog_combo_box), (gpointer *)&k)) {
|
||||
g_assert_not_reached(); /* Programming error: somehow no active item */
|
||||
}
|
||||
|
||||
g_signal_handlers_disconnect_by_func(vers_combo_box, G_CALLBACK(dcerpcstat_version_select), NULL );
|
||||
ws_combo_box_clear_text_and_pointer(GTK_COMBO_BOX(vers_combo_box));
|
||||
|
||||
/* dcerpc_stat: invalid selection... somehow selected top level ?? */
|
||||
g_assert(k != NULL);
|
||||
dcerpc_uuid_program = &(k->guid);
|
||||
|
||||
/* re-create version menu */
|
||||
g_signal_handlers_disconnect_by_func(vers_combo_box, G_CALLBACK(dcerpcstat_version_select), NULL );
|
||||
ws_combo_box_clear_text_and_pointer(GTK_COMBO_BOX(vers_combo_box));
|
||||
|
||||
g_hash_table_foreach(dcerpc_uuids, (GHFunc)dcerpcstat_find_vers, vers_combo_box);
|
||||
|
||||
g_signal_connect(vers_combo_box, "changed", G_CALLBACK(dcerpcstat_version_select), NULL);
|
||||
ws_combo_box_set_active(GTK_COMBO_BOX(vers_combo_box), 0); /* default: triggers dcerpcstat_version_select callback */
|
||||
|
||||
}
|
||||
|
||||
static GtkTreeIter
|
||||
dcerpcstat_add_program_to_menu(guid_key *k, dcerpc_uuid_value *v, GtkWidget *prog_combo_box, int program_item_index)
|
||||
{
|
||||
static GtkTreeIter iter;
|
||||
char str[64];
|
||||
|
||||
switch(program_item_index%15){
|
||||
case 0:
|
||||
g_snprintf(str,sizeof(str),"%s ...",v->name);
|
||||
iter = ws_combo_box_append_text_and_pointer_full(
|
||||
GTK_COMBO_BOX(prog_combo_box), NULL, str, NULL, FALSE); /* top-level entries are insensitive */
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ws_combo_box_append_text_and_pointer_full(
|
||||
GTK_COMBO_BOX(prog_combo_box), &iter, v->name, k, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
dcerpcstat_find_next_program(gpointer *key, gpointer *value, gpointer *user_data _U_)
|
||||
{
|
||||
guid_key *k = (guid_key *)key;
|
||||
dcerpc_uuid_value *v = (dcerpc_uuid_value *)value;
|
||||
|
||||
/* first time called, just set new_uuid to this one */
|
||||
if((current_uuid_key==NULL) && (new_uuid_key==NULL)){
|
||||
new_uuid_key = k;
|
||||
new_uuid_value = v;
|
||||
return;
|
||||
}
|
||||
|
||||
/* if we haven't got a current one yet, just check the new
|
||||
and scan for the first one alphabetically */
|
||||
if(current_uuid_key==NULL){
|
||||
if(strcmp(new_uuid_value->name, v->name)>0){
|
||||
new_uuid_key = k;
|
||||
new_uuid_value = v;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* searching for the next one we are only interested in those
|
||||
that sorts alphabetically after the current one */
|
||||
if(strcmp(current_uuid_value->name, v->name) >= 0){
|
||||
/* this one doesn't so just skip it */
|
||||
return;
|
||||
}
|
||||
|
||||
/* is it the first potential new entry? */
|
||||
if(new_uuid_key==NULL){
|
||||
new_uuid_key = k;
|
||||
new_uuid_value = v;
|
||||
return;
|
||||
}
|
||||
|
||||
/* does it sort before the current new one? */
|
||||
if(strcmp(new_uuid_value->name, v->name) > 0){
|
||||
new_uuid_key = k;
|
||||
new_uuid_value = v;
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dlg_destroy_cb(GtkWidget *w _U_, gpointer user_data _U_)
|
||||
{
|
||||
dlg = NULL;
|
||||
}
|
||||
|
||||
|
||||
void gtk_dcerpcstat_cb(GtkAction *action _U_, gpointer user_data _U_)
|
||||
{
|
||||
GtkWidget *dlg_box;
|
||||
GtkWidget *prog_box, *prog_label, *prog_combo_box;
|
||||
GtkWidget *vers_label, *vers_combo_box;
|
||||
GtkWidget *filter_box, *filter_bt;
|
||||
GtkWidget *bbox, *start_button, *cancel_button;
|
||||
GtkCellRenderer *cell_renderer;
|
||||
#if 0
|
||||
GtkTreeIter program_first_item_iter;
|
||||
#endif
|
||||
const char *filter;
|
||||
int program_item_index = 0;
|
||||
|
||||
static construct_args_t args = {
|
||||
"Service Response Time Statistics Filter",
|
||||
FALSE,
|
||||
FALSE,
|
||||
FALSE
|
||||
};
|
||||
|
||||
/* if the window is already open, bring it to front and
|
||||
un-minimize it, as necessary */
|
||||
if(dlg){
|
||||
reactivate_window(dlg);
|
||||
return;
|
||||
}
|
||||
|
||||
dlg = dlg_window_new("Wireshark: Compute DCE-RPC SRT statistics");
|
||||
gtk_window_set_default_size(GTK_WINDOW(dlg), 400, -1);
|
||||
|
||||
dlg_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 10, FALSE);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(dlg_box), 10);
|
||||
gtk_container_add(GTK_CONTAINER(dlg), dlg_box);
|
||||
gtk_widget_show(dlg_box);
|
||||
|
||||
/* Program box */
|
||||
prog_box = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
|
||||
|
||||
/* Program label */
|
||||
gtk_container_set_border_width(GTK_CONTAINER(prog_box), 10);
|
||||
prog_label = gtk_label_new("Program:");
|
||||
gtk_box_pack_start(GTK_BOX(prog_box), prog_label, FALSE, FALSE, 0);
|
||||
gtk_widget_show(prog_label);
|
||||
|
||||
/* Program menu */
|
||||
dcerpc_uuid_program = NULL; /* default: no program selected */
|
||||
|
||||
/* The "program combo box" is implemented with a two-level tree.
|
||||
Each top-level of the tree has (up to) 15 selectable "program name"
|
||||
children and shows the name of the first child of that entry
|
||||
as "child_name ...". Each of the top-level entries can be expanded
|
||||
(to show the children) but is "insensitive": ie: cannot be selected.
|
||||
(dcerpcstat_add_program_to_menu() does the actual work to add entries
|
||||
to the combo box).
|
||||
XXX: A simpler alternative might be to just do away with all the two-level
|
||||
complexity and just use a standard ws_combo_box... even though the
|
||||
list of "program names" is quite large.
|
||||
XXX: The gtkrc file distributed with Windows Wireshark has the
|
||||
"appears-as-list" GtkComboBox style property set to 1 and thus
|
||||
on Windows the entries for this combo box will appear as a tree-view.
|
||||
The default is 0(FALSE). In this case the the combo box entries will
|
||||
display as a menu with sub-menus.
|
||||
A possibility would be to set "appears-as-list" to 0 just for this
|
||||
particular combo box on Windows so that the entries will appear as a
|
||||
menu even on Windows).
|
||||
*/
|
||||
prog_combo_box = ws_combo_box_new_text_and_pointer_full(&cell_renderer);
|
||||
{
|
||||
/* XXX: Hack So that the top-level insensitive entries don't show
|
||||
as "grayed out"; The "foreground normal" color is used instead.
|
||||
This may not really be necessary but seems better to me.
|
||||
*/
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
GtkStyleContext *context;
|
||||
GdkRGBA *new_rgba_fg_color;
|
||||
context = gtk_widget_get_style_context (prog_combo_box);
|
||||
gtk_style_context_get (context, GTK_STATE_FLAG_NORMAL,
|
||||
"color", &new_rgba_fg_color,
|
||||
NULL);
|
||||
|
||||
g_object_set(cell_renderer,
|
||||
"foreground-rgba", &new_rgba_fg_color,
|
||||
"foreground-set", TRUE,
|
||||
NULL);
|
||||
|
||||
#else
|
||||
GtkStyle *s;
|
||||
s = gtk_widget_get_style(prog_combo_box);
|
||||
g_object_set(cell_renderer,
|
||||
"foreground-gdk", &(s->fg[GTK_STATE_NORMAL]),
|
||||
"foreground-set", TRUE,
|
||||
NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
current_uuid_key = NULL;
|
||||
current_uuid_value = NULL;
|
||||
do {
|
||||
new_uuid_key = NULL;
|
||||
new_uuid_value = NULL;
|
||||
g_hash_table_foreach(dcerpc_uuids, (GHFunc)dcerpcstat_find_next_program, NULL);
|
||||
if(new_uuid_key){
|
||||
#if 0
|
||||
GtkTreeIter tmp_iter;
|
||||
tmp_iter = dcerpcstat_add_program_to_menu(new_uuid_key, new_uuid_value,
|
||||
prog_combo_box, program_item_index);
|
||||
if (program_item_index == 0)
|
||||
program_first_item_iter = tmp_iter;
|
||||
#else
|
||||
dcerpcstat_add_program_to_menu(new_uuid_key, new_uuid_value,
|
||||
prog_combo_box, program_item_index);
|
||||
#endif
|
||||
program_item_index += 1;
|
||||
}
|
||||
current_uuid_key = new_uuid_key;
|
||||
current_uuid_value = new_uuid_value;
|
||||
} while(new_uuid_key != NULL);
|
||||
gtk_box_pack_start(GTK_BOX(prog_box), prog_combo_box, TRUE, TRUE, 0);
|
||||
gtk_widget_show(prog_combo_box);
|
||||
|
||||
/* Version label */
|
||||
gtk_container_set_border_width(GTK_CONTAINER(prog_box), 10);
|
||||
vers_label = gtk_label_new("Version:");
|
||||
gtk_box_pack_start(GTK_BOX(prog_box), vers_label, FALSE, FALSE, 0);
|
||||
gtk_widget_show(vers_label);
|
||||
|
||||
/* Version combo-box */
|
||||
/* Note: version combo box rows set when dcerpcstat_program_select() callback invoked */
|
||||
vers_combo_box = ws_combo_box_new_text_and_pointer();
|
||||
gtk_box_pack_start(GTK_BOX(prog_box), vers_combo_box, TRUE, TRUE, 0);
|
||||
gtk_widget_show(vers_combo_box);
|
||||
|
||||
g_signal_connect(prog_combo_box, "changed", G_CALLBACK(dcerpcstat_program_select), vers_combo_box);
|
||||
#if 0 /* Don't select an active entry given the way the drop down treeview appears if a default (active) entry is set */
|
||||
ws_combo_box_set_active_iter(GTK_COMBO_BOX(prog_combo_box), &program_first_item_iter); /* triggers callback */
|
||||
#endif
|
||||
gtk_box_pack_start(GTK_BOX(dlg_box), prog_box, TRUE, TRUE, 0);
|
||||
gtk_widget_show(prog_box);
|
||||
|
||||
/* Filter box */
|
||||
filter_box = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
|
||||
|
||||
/* Filter label */
|
||||
filter_bt = ws_gtk_button_new_from_stock(WIRESHARK_STOCK_DISPLAY_FILTER_ENTRY);
|
||||
g_signal_connect(filter_bt, "clicked", G_CALLBACK(display_filter_construct_cb), &args);
|
||||
gtk_box_pack_start(GTK_BOX(filter_box), filter_bt, FALSE, FALSE, 0);
|
||||
gtk_widget_show(filter_bt);
|
||||
|
||||
/* Filter entry */
|
||||
filter_entry = gtk_entry_new();
|
||||
g_signal_connect(filter_entry, "changed", G_CALLBACK(filter_te_syntax_check_cb), NULL);
|
||||
g_object_set_data(G_OBJECT(filter_box), E_FILT_AUTOCOMP_PTR_KEY, NULL);
|
||||
g_signal_connect(filter_entry, "key-press-event", G_CALLBACK (filter_string_te_key_pressed_cb), NULL);
|
||||
g_signal_connect(dlg, "key-press-event", G_CALLBACK (filter_parent_dlg_key_pressed_cb), NULL);
|
||||
gtk_box_pack_start(GTK_BOX(filter_box), filter_entry, TRUE, TRUE, 0);
|
||||
filter = gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
|
||||
if(filter){
|
||||
gtk_entry_set_text(GTK_ENTRY(filter_entry), filter);
|
||||
} else {
|
||||
colorize_filter_te_as_empty(filter_entry);
|
||||
}
|
||||
gtk_widget_show(filter_entry);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(dlg_box), filter_box, TRUE, TRUE, 0);
|
||||
gtk_widget_show(filter_box);
|
||||
|
||||
g_object_set_data(G_OBJECT(filter_bt), E_FILT_TE_PTR_KEY, filter_entry);
|
||||
|
||||
/* button box */
|
||||
bbox = dlg_button_row_new(WIRESHARK_STOCK_CREATE_STAT, GTK_STOCK_CANCEL, NULL);
|
||||
gtk_box_pack_start(GTK_BOX(dlg_box), bbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show(bbox);
|
||||
|
||||
start_button = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_CREATE_STAT);
|
||||
g_signal_connect_swapped(start_button, "clicked",
|
||||
G_CALLBACK(dcerpcstat_start_button_clicked), NULL);
|
||||
|
||||
cancel_button = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
|
||||
window_set_cancel_button(dlg, cancel_button, window_cancel_button_cb);
|
||||
|
||||
g_signal_connect(dlg, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
||||
g_signal_connect(dlg, "destroy", G_CALLBACK(dlg_destroy_cb), NULL);
|
||||
|
||||
/* Catch the "activate" signal on the filter text entry, so that
|
||||
if the user types Return there, we act as if the "Create Stat"
|
||||
button had been selected, as happens if Return is typed if some
|
||||
widget that *doesn't* handle the Return key has the input
|
||||
focus. */
|
||||
dlg_set_activate(filter_entry, start_button);
|
||||
|
||||
gtk_widget_grab_default(start_button );
|
||||
|
||||
/* Give the initial focus to the "Filter" entry box. */
|
||||
gtk_widget_grab_focus(filter_entry);
|
||||
|
||||
gtk_widget_show_all(dlg);
|
||||
window_present(dlg);
|
||||
}
|
||||
|
||||
static stat_tap_ui dcerpcstat_ui = {
|
||||
REGISTER_STAT_GROUP_RESPONSE_TIME,
|
||||
NULL,
|
||||
"dcerpc,srt",
|
||||
gtk_dcerpcstat_init,
|
||||
0,
|
||||
NULL
|
||||
};
|
||||
|
||||
void
|
||||
register_tap_listener_gtkdcerpcstat(void)
|
||||
{
|
||||
register_stat_tap_ui(&dcerpcstat_ui, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
||||
* :indentSize=8:tabSize=8:noTabs=false:
|
||||
*/
|
File diff suppressed because it is too large
Load Diff
|
@ -1,65 +0,0 @@
|
|||
/* decode_as_dlg.h
|
||||
*
|
||||
* Routines to modify dissector tables on the fly.
|
||||
*
|
||||
* By David Hampton <dhampton@mac.com>
|
||||
* Copyright 2001 David Hampton
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __DECODE_AS_DLG_H__
|
||||
#define __DECODE_AS_DLG_H__
|
||||
|
||||
/** @file
|
||||
* "Decode As" / "User Specified Decodes" dialog box.
|
||||
* @ingroup dialog_group
|
||||
*/
|
||||
|
||||
/*
|
||||
* Enum used to track which radio button is currently selected in the
|
||||
* dialog. These buttons are labeled "Decode" and "Do not decode".
|
||||
*/
|
||||
enum action_type {
|
||||
/* The "Decode" button is currently selected. */
|
||||
E_DECODE_YES,
|
||||
|
||||
/* The "Do not decode" button is currently selected. */
|
||||
E_DECODE_NO
|
||||
};
|
||||
|
||||
/** User requested the "Decode As" dialog box by menu or toolbar.
|
||||
*
|
||||
* @param widget parent widget (unused)
|
||||
* @param data unused
|
||||
*/
|
||||
void decode_as_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
/** User requested the "User Specified Decodes" dialog box by menu or toolbar.
|
||||
*
|
||||
* @param widget parent widget (unused)
|
||||
* @param data unused
|
||||
*/
|
||||
void decode_show_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
/** Have any pages in the notebook in a "Decode As" dialog box? If there
|
||||
* wouldn't be, we inactivate the menu item for "Decode As".
|
||||
*
|
||||
* @return TRUE, if we have at least one notebook page in "Decode As"
|
||||
*/
|
||||
gboolean decode_as_ok(void);
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -1,39 +0,0 @@
|
|||
/* dfilter_expr_dlg.h
|
||||
* Definitions for dialog boxes for display filter expression construction
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __DFILTER_EXPR_DLG_H__
|
||||
#define __DFILTER_EXPR_DLG_H__
|
||||
|
||||
/** @file
|
||||
* "Add Expression" dialog box.
|
||||
* @ingroup dialog_group
|
||||
*/
|
||||
|
||||
/** User requested the "Add Expression" dialog box by menu or toolbar.
|
||||
*
|
||||
* @param widget corresponding text entry widget
|
||||
* @return the newly created dialog widget
|
||||
*/
|
||||
GtkWidget *dfilter_expr_dlg_new(GtkWidget *widget);
|
||||
|
||||
#endif /* dfilter_expr_dlg.h */
|
|
@ -1,442 +0,0 @@
|
|||
/* dissector_tables_dlg.c
|
||||
* dissector_tables_dlg 2010 Anders Broman
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#include <epan/packet.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "ui/gtk/gui_utils.h"
|
||||
#include "ui/gtk/dlg_utils.h"
|
||||
#include "ui/gtk/dissector_tables_dlg.h"
|
||||
|
||||
static GtkWidget *dissector_tables_dlg_w = NULL;
|
||||
|
||||
/* The columns */
|
||||
enum
|
||||
{
|
||||
TABLE_UI_NAME_COL,
|
||||
TABLE_SHORT_NAME_COL,
|
||||
N_COLUMNS
|
||||
};
|
||||
|
||||
static void
|
||||
win_destroy_cb(GtkWindow *win _U_, gpointer data _U_)
|
||||
{
|
||||
|
||||
if (dissector_tables_dlg_w != NULL) {
|
||||
window_destroy(dissector_tables_dlg_w);
|
||||
dissector_tables_dlg_w = NULL;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* For a dissector table, put
|
||||
* its short name and its
|
||||
* descriptive name in the treeview.
|
||||
*/
|
||||
|
||||
struct dissector_tables_tree_info {
|
||||
GtkWidget *tree;
|
||||
GtkTreeIter iter;
|
||||
GtkTreeIter new_iter;
|
||||
};
|
||||
|
||||
typedef struct dissector_tables_tree_info dissector_tables_tree_info_t;
|
||||
|
||||
static gint
|
||||
ui_sort_func(GtkTreeModel *model,
|
||||
GtkTreeIter *a,
|
||||
GtkTreeIter *b,
|
||||
gpointer user_data)
|
||||
{
|
||||
gchar *stra, *strb;
|
||||
|
||||
/* The col to get data from is in userdata */
|
||||
gint data_column = GPOINTER_TO_INT(user_data);
|
||||
|
||||
gtk_tree_model_get(model, a, data_column, &stra, -1);
|
||||
gtk_tree_model_get(model, b, data_column, &strb, -1);
|
||||
|
||||
return strcmp(stra, strb);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Struct to hold the pointer to the trees
|
||||
* for dissector tables.
|
||||
*/
|
||||
struct dissector_tables_trees {
|
||||
GtkWidget *str_tree_wgt;
|
||||
GtkWidget *uint_tree_wgt;
|
||||
GtkWidget *custom_tree_wgt;
|
||||
GtkWidget *heuristic_tree_wgt;
|
||||
};
|
||||
|
||||
typedef struct dissector_tables_trees dissector_tables_trees_t;
|
||||
|
||||
static void
|
||||
proto_add_to_list(dissector_tables_tree_info_t *tree_info,
|
||||
GtkTreeStore *store,
|
||||
const gchar *str,
|
||||
const gchar *proto_name)
|
||||
{
|
||||
gtk_tree_store_insert_with_values(store, &tree_info->new_iter, &tree_info->iter, G_MAXINT,
|
||||
TABLE_UI_NAME_COL, str,
|
||||
TABLE_SHORT_NAME_COL, proto_name,
|
||||
-1);
|
||||
}
|
||||
|
||||
static void
|
||||
decode_proto_add_to_list (const gchar *table_name _U_, ftenum_t selector_type,
|
||||
gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
GtkTreeStore *store;
|
||||
const gchar *proto_name;
|
||||
dtbl_entry_t *dtbl_entry;
|
||||
dissector_handle_t handle;
|
||||
guint32 port;
|
||||
gchar *int_str;
|
||||
const gchar *dissector_name_str;
|
||||
dissector_tables_tree_info_t *tree_info;
|
||||
|
||||
tree_info = (dissector_tables_tree_info_t *)user_data;
|
||||
dtbl_entry = (dtbl_entry_t*)value;
|
||||
handle = dtbl_entry_get_handle(dtbl_entry);
|
||||
proto_name = dissector_handle_get_short_name(handle);
|
||||
|
||||
store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree_info->tree)));
|
||||
|
||||
switch (selector_type) {
|
||||
|
||||
case FT_UINT8:
|
||||
case FT_UINT16:
|
||||
case FT_UINT24:
|
||||
case FT_UINT32:
|
||||
port = GPOINTER_TO_UINT(key);
|
||||
/* Hack: Use fixed width rj str so alpha sort (strcmp) will sort field numerically */
|
||||
int_str = g_strdup_printf ("%10d", port);
|
||||
proto_add_to_list(tree_info, store, int_str, proto_name);
|
||||
g_free (int_str);
|
||||
break;
|
||||
|
||||
case FT_STRING:
|
||||
case FT_STRINGZ:
|
||||
case FT_UINT_STRING:
|
||||
case FT_STRINGZPAD:
|
||||
proto_add_to_list(tree_info, store, (const gchar*)key, proto_name);
|
||||
break;
|
||||
|
||||
case FT_BYTES:
|
||||
case FT_GUID:
|
||||
case FT_NONE:
|
||||
dissector_name_str = dissector_handle_get_dissector_name(handle);
|
||||
if (dissector_name_str == NULL)
|
||||
dissector_name_str = "<Unknown>";
|
||||
proto_add_to_list(tree_info, store, dissector_name_str, proto_name);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
table_name_add_to_list(dissector_tables_tree_info_t *tree_info,
|
||||
GtkWidget *tree_view,
|
||||
const char *table_name,
|
||||
const char *ui_name)
|
||||
{
|
||||
GtkTreeStore *store;
|
||||
|
||||
tree_info->tree = tree_view;
|
||||
store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view))); /* Get store */
|
||||
|
||||
gtk_tree_store_insert_with_values(store, &tree_info->iter, NULL, G_MAXINT,
|
||||
TABLE_UI_NAME_COL, ui_name,
|
||||
TABLE_SHORT_NAME_COL, table_name,
|
||||
-1);
|
||||
}
|
||||
|
||||
static void
|
||||
display_heur_dissector_table_entries(const char *table_name _U_,
|
||||
struct heur_dtbl_entry *dtbl_entry, gpointer user_data)
|
||||
{
|
||||
dissector_tables_tree_info_t *tree_info = (dissector_tables_tree_info_t*)user_data;
|
||||
GtkTreeStore *store;
|
||||
|
||||
if (dtbl_entry->protocol) {
|
||||
|
||||
store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree_info->tree))); /* Get store */
|
||||
proto_add_to_list(tree_info, store,
|
||||
(gchar *)proto_get_protocol_long_name(dtbl_entry->protocol),
|
||||
proto_get_protocol_short_name(dtbl_entry->protocol));
|
||||
}else{
|
||||
g_warning("no protocol info");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
display_heur_dissector_table_names(const char *table_name, struct heur_dissector_list *list, gpointer w)
|
||||
{
|
||||
dissector_tables_trees_t *dis_tbl_trees;
|
||||
dissector_tables_tree_info_t *tree_info;
|
||||
|
||||
tree_info = g_new(dissector_tables_tree_info_t, 1);
|
||||
dis_tbl_trees = (dissector_tables_trees_t*)w;
|
||||
|
||||
table_name_add_to_list(tree_info, dis_tbl_trees->heuristic_tree_wgt, "", table_name);
|
||||
|
||||
if (list) {
|
||||
heur_dissector_table_foreach(table_name, display_heur_dissector_table_entries, tree_info);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
display_dissector_table_names(const char *table_name, const char *ui_name, void *w)
|
||||
{
|
||||
dissector_tables_trees_t *dis_tbl_trees;
|
||||
dissector_tables_tree_info_t *tree_info;
|
||||
ftenum_t selector_type = get_dissector_table_selector_type(table_name);
|
||||
|
||||
tree_info = g_new(dissector_tables_tree_info_t, 1);
|
||||
dis_tbl_trees = (dissector_tables_trees_t*)w;
|
||||
|
||||
switch (selector_type) {
|
||||
case FT_UINT8:
|
||||
case FT_UINT16:
|
||||
case FT_UINT24:
|
||||
case FT_UINT32:
|
||||
table_name_add_to_list(tree_info, dis_tbl_trees->uint_tree_wgt, table_name, ui_name);
|
||||
break;
|
||||
case FT_STRING:
|
||||
case FT_STRINGZ:
|
||||
case FT_UINT_STRING:
|
||||
case FT_STRINGZPAD:
|
||||
table_name_add_to_list(tree_info, dis_tbl_trees->str_tree_wgt, table_name, ui_name);
|
||||
break;
|
||||
case FT_BYTES:
|
||||
case FT_GUID:
|
||||
case FT_NONE:
|
||||
table_name_add_to_list(tree_info, dis_tbl_trees->custom_tree_wgt, table_name, ui_name);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
dissector_table_foreach(table_name, decode_proto_add_to_list, tree_info);
|
||||
|
||||
g_free(tree_info);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
init_table(void)
|
||||
{
|
||||
GtkTreeStore *store;
|
||||
GtkWidget *tree;
|
||||
GtkTreeView *tree_view;
|
||||
GtkTreeViewColumn *column;
|
||||
GtkCellRenderer *renderer;
|
||||
GtkTreeSortable *sortable;
|
||||
|
||||
/* Create the store */
|
||||
store = gtk_tree_store_new (N_COLUMNS, /* Total number of columns */
|
||||
G_TYPE_STRING, /* Table */
|
||||
G_TYPE_STRING); /* Table */
|
||||
|
||||
/* Create a view */
|
||||
tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
|
||||
tree_view = GTK_TREE_VIEW(tree);
|
||||
sortable = GTK_TREE_SORTABLE(store);
|
||||
|
||||
/* Speed up the list display */
|
||||
gtk_tree_view_set_fixed_height_mode(tree_view, TRUE);
|
||||
|
||||
/* Setup the sortable columns */
|
||||
gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW (tree), FALSE);
|
||||
|
||||
/* The view now holds a reference. We can get rid of our own reference */
|
||||
g_object_unref (G_OBJECT (store));
|
||||
|
||||
/* Create the first column, associating the "text" attribute of the
|
||||
* cell_renderer to the first column of the model */
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
column = gtk_tree_view_column_new_with_attributes ("UI name", renderer, "text", TABLE_UI_NAME_COL, NULL);
|
||||
gtk_tree_sortable_set_sort_func(sortable, TABLE_UI_NAME_COL,
|
||||
ui_sort_func, GINT_TO_POINTER(TABLE_UI_NAME_COL), NULL);
|
||||
gtk_tree_view_column_set_sort_column_id(column, TABLE_UI_NAME_COL);
|
||||
gtk_tree_view_column_set_resizable(column, TRUE);
|
||||
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
gtk_tree_view_column_set_min_width(column, 80);
|
||||
gtk_tree_view_column_set_fixed_width(column, 330);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
column = gtk_tree_view_column_new_with_attributes ("Short name", renderer, "text", TABLE_SHORT_NAME_COL, NULL);
|
||||
gtk_tree_sortable_set_sort_func(sortable, TABLE_SHORT_NAME_COL,
|
||||
ui_sort_func, GINT_TO_POINTER(TABLE_SHORT_NAME_COL), NULL);
|
||||
gtk_tree_view_column_set_sort_column_id(column, TABLE_SHORT_NAME_COL);
|
||||
gtk_tree_view_column_set_resizable(column, TRUE);
|
||||
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
gtk_tree_view_column_set_min_width(column, 80);
|
||||
gtk_tree_view_column_set_fixed_width(column, 100);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
|
||||
|
||||
return tree;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
dissector_tables_dlg_init(void)
|
||||
{
|
||||
dissector_tables_trees_t dis_tbl_trees;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *main_nb;
|
||||
GtkWidget *scrolled_window;
|
||||
GtkTreeSortable *sortable;
|
||||
GtkWidget *temp_page, *tmp;
|
||||
|
||||
dissector_tables_dlg_w = dlg_window_new("Dissector tables"); /* transient_for top_level */
|
||||
gtk_window_set_destroy_with_parent (GTK_WINDOW(dissector_tables_dlg_w), TRUE);
|
||||
gtk_window_set_default_size(GTK_WINDOW(dissector_tables_dlg_w), 700, 300);
|
||||
|
||||
vbox=ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
|
||||
gtk_container_add(GTK_CONTAINER(dissector_tables_dlg_w), vbox);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
|
||||
|
||||
main_nb = gtk_notebook_new();
|
||||
gtk_box_pack_start(GTK_BOX(vbox), main_nb, TRUE, TRUE, 0);
|
||||
|
||||
/* String tables */
|
||||
temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
|
||||
tmp = gtk_label_new("String tables");
|
||||
gtk_widget_show(tmp);
|
||||
hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
|
||||
gtk_box_pack_start(GTK_BOX (hbox), tmp, TRUE, TRUE, 0);
|
||||
gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, hbox);
|
||||
|
||||
scrolled_window = scrolled_window_new(NULL, NULL);
|
||||
dis_tbl_trees.str_tree_wgt = init_table();
|
||||
gtk_widget_show(dis_tbl_trees.str_tree_wgt);
|
||||
gtk_container_add(GTK_CONTAINER(scrolled_window), dis_tbl_trees.str_tree_wgt);
|
||||
gtk_box_pack_start(GTK_BOX(temp_page), scrolled_window, TRUE, TRUE, 0);
|
||||
gtk_widget_show(scrolled_window);
|
||||
|
||||
/* uint tables */
|
||||
temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
|
||||
tmp = gtk_label_new("Integer tables");
|
||||
gtk_widget_show(tmp);
|
||||
hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
|
||||
gtk_box_pack_start(GTK_BOX (hbox), tmp, TRUE, TRUE, 0);
|
||||
gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, hbox);
|
||||
|
||||
scrolled_window = scrolled_window_new(NULL, NULL);
|
||||
dis_tbl_trees.uint_tree_wgt = init_table();
|
||||
gtk_widget_show(dis_tbl_trees.uint_tree_wgt);
|
||||
gtk_container_add(GTK_CONTAINER(scrolled_window), dis_tbl_trees.uint_tree_wgt);
|
||||
gtk_box_pack_start(GTK_BOX(temp_page), scrolled_window, TRUE, TRUE, 0);
|
||||
gtk_widget_show(scrolled_window);
|
||||
|
||||
/* custom tables */
|
||||
temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
|
||||
tmp = gtk_label_new("Custom tables");
|
||||
gtk_widget_show(tmp);
|
||||
hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
|
||||
gtk_box_pack_start(GTK_BOX (hbox), tmp, TRUE, TRUE, 0);
|
||||
gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, hbox);
|
||||
|
||||
scrolled_window = scrolled_window_new(NULL, NULL);
|
||||
dis_tbl_trees.custom_tree_wgt = init_table();
|
||||
gtk_widget_show(dis_tbl_trees.custom_tree_wgt);
|
||||
gtk_container_add(GTK_CONTAINER(scrolled_window), dis_tbl_trees.custom_tree_wgt);
|
||||
gtk_box_pack_start(GTK_BOX(temp_page), scrolled_window, TRUE, TRUE, 0);
|
||||
gtk_widget_show(scrolled_window);
|
||||
|
||||
/* heuristic tables */
|
||||
temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
|
||||
tmp = gtk_label_new("Heuristic tables");
|
||||
gtk_widget_show(tmp);
|
||||
hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), tmp, TRUE, TRUE, 0);
|
||||
gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, hbox);
|
||||
|
||||
scrolled_window = scrolled_window_new(NULL, NULL);
|
||||
dis_tbl_trees.heuristic_tree_wgt = init_table();
|
||||
gtk_widget_show(dis_tbl_trees.heuristic_tree_wgt);
|
||||
gtk_container_add(GTK_CONTAINER(scrolled_window), dis_tbl_trees.heuristic_tree_wgt);
|
||||
gtk_box_pack_start(GTK_BOX(temp_page), scrolled_window, TRUE, TRUE, 0);
|
||||
gtk_widget_show(scrolled_window);
|
||||
|
||||
/* We must display TOP LEVEL Widget before calling init_table() */
|
||||
gtk_widget_show_all(dissector_tables_dlg_w);
|
||||
g_signal_connect(dissector_tables_dlg_w, "destroy", G_CALLBACK(win_destroy_cb), NULL);
|
||||
|
||||
/* Fill the table with data */
|
||||
dissector_all_tables_foreach_table(display_dissector_table_names, &dis_tbl_trees, NULL);
|
||||
|
||||
dissector_all_heur_tables_foreach_table(display_heur_dissector_table_names, (gpointer)&dis_tbl_trees, NULL);
|
||||
|
||||
sortable = GTK_TREE_SORTABLE(gtk_tree_view_get_model(GTK_TREE_VIEW(dis_tbl_trees.str_tree_wgt)));
|
||||
gtk_tree_sortable_set_sort_column_id(sortable, TABLE_UI_NAME_COL, GTK_SORT_ASCENDING);
|
||||
|
||||
sortable = GTK_TREE_SORTABLE(gtk_tree_view_get_model(GTK_TREE_VIEW(dis_tbl_trees.uint_tree_wgt)));
|
||||
gtk_tree_sortable_set_sort_column_id(sortable, TABLE_UI_NAME_COL, GTK_SORT_ASCENDING);
|
||||
|
||||
sortable = GTK_TREE_SORTABLE(gtk_tree_view_get_model(GTK_TREE_VIEW(dis_tbl_trees.custom_tree_wgt)));
|
||||
gtk_tree_sortable_set_sort_column_id(sortable, TABLE_UI_NAME_COL, GTK_SORT_ASCENDING);
|
||||
|
||||
sortable = GTK_TREE_SORTABLE(gtk_tree_view_get_model(GTK_TREE_VIEW(dis_tbl_trees.heuristic_tree_wgt)));
|
||||
gtk_tree_sortable_set_sort_column_id(sortable, TABLE_UI_NAME_COL, GTK_SORT_ASCENDING);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
dissector_tables_dlg_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||
{
|
||||
if (dissector_tables_dlg_w) {
|
||||
reactivate_window(dissector_tables_dlg_w);
|
||||
} else {
|
||||
dissector_tables_dlg_init();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
||||
* :indentSize=4:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -1,23 +0,0 @@
|
|||
/* dissector_tables_dlg.h
|
||||
* dissector_tables_dlg 2010 Anders Broman
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
void dissector_tables_dlg_cb(GtkWidget *w, gpointer d);
|
|
@ -1,565 +0,0 @@
|
|||
/* dlg_utils.c
|
||||
* Utilities to use when constructing dialogs
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "ui/gtk/gtkglobals.h"
|
||||
#include "ui/gtk/gui_utils.h"
|
||||
#include "ui/gtk/dlg_utils.h"
|
||||
#include "ui/gtk/stock_icons.h"
|
||||
#include "ui/gtk/old-gtk-compat.h"
|
||||
|
||||
#include "wsutil/filesystem.h"
|
||||
|
||||
|
||||
static void
|
||||
dlg_activate (GtkWidget *widget, gpointer ok_button);
|
||||
|
||||
/* create a button for the button row (helper for dlg_button_row_new) */
|
||||
static GtkWidget *
|
||||
dlg_button_new(GtkWidget *hbox, GtkWidget *button_hbox, const gchar *stock_id)
|
||||
{
|
||||
GtkWidget *button;
|
||||
|
||||
button = ws_gtk_button_new_from_stock(stock_id);
|
||||
gtk_widget_set_can_default(button, TRUE);
|
||||
g_object_set_data(G_OBJECT(hbox), stock_id, button);
|
||||
gtk_box_pack_end(GTK_BOX(button_hbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show(button);
|
||||
return button;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the focus and default for the nth item in a button row, with
|
||||
* 0 being the first item.
|
||||
*/
|
||||
#define BUTTON_HBOX_KEY "button_hbox"
|
||||
void
|
||||
dlg_button_focus_nth(GtkWidget *hbox, gint focus_item) {
|
||||
GtkWidget *button_hbox, *button;
|
||||
GList *children;
|
||||
gint cur_item = 0;
|
||||
|
||||
if (!hbox)
|
||||
return;
|
||||
|
||||
button_hbox = (GtkWidget *)g_object_get_data(G_OBJECT(hbox), BUTTON_HBOX_KEY);
|
||||
children = gtk_container_get_children(GTK_CONTAINER(button_hbox));
|
||||
|
||||
while (children) {
|
||||
if (cur_item == focus_item) {
|
||||
button = (GtkWidget *)children->data;
|
||||
gtk_widget_grab_focus(button);
|
||||
gtk_widget_grab_default(button);
|
||||
break;
|
||||
}
|
||||
children = g_list_next(children);
|
||||
cur_item++;
|
||||
}
|
||||
|
||||
g_list_free(children);
|
||||
}
|
||||
|
||||
/* create a button row for a dialog */
|
||||
|
||||
/* The purpose of this is, to have one place available, where all button rows
|
||||
* from all dialogs are laid out. This will:
|
||||
*
|
||||
* a.) keep the button layout more consistent over the different dialogs
|
||||
* b.) being able to switch between different button layouts, e.g.:
|
||||
* e.g. Win32: "OK" "Apply" "Cancel"
|
||||
* e.g. GNOME: "Apply" "Cancel" "OK"
|
||||
*/
|
||||
GtkWidget *
|
||||
dlg_button_row_new(const gchar *stock_id_first, ...)
|
||||
{
|
||||
gint buttons = 0;
|
||||
va_list stock_id_list;
|
||||
const gchar *stock_id = stock_id_first;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *button_hbox;
|
||||
GtkWidget *help_hbox;
|
||||
GtkWidget *button;
|
||||
|
||||
const gchar *apply = NULL;
|
||||
const gchar *cancel = NULL;
|
||||
const gchar *cap_start = NULL;
|
||||
const gchar *cap_stop = NULL;
|
||||
const gchar *cap_options = NULL;
|
||||
#ifdef _WIN32
|
||||
const gchar *cap_details = NULL;
|
||||
#endif
|
||||
const gchar *clear = NULL;
|
||||
const gchar *closex = NULL;
|
||||
const gchar *copy = NULL;
|
||||
const gchar *create_stat = NULL;
|
||||
const gchar *delete_id = NULL;
|
||||
const gchar *dont_save = NULL;
|
||||
const gchar *filter_stream = NULL;
|
||||
const gchar *find = NULL;
|
||||
const gchar *help = NULL;
|
||||
const gchar *jump = NULL;
|
||||
const gchar *no = NULL;
|
||||
const gchar *ok = NULL;
|
||||
const gchar *print = NULL;
|
||||
const gchar *save = NULL;
|
||||
const gchar *save_as = NULL;
|
||||
const gchar *save_all = NULL;
|
||||
const gchar *stop = NULL;
|
||||
const gchar *yes = NULL;
|
||||
const gchar *refresh = NULL;
|
||||
const gchar *add = NULL;
|
||||
#ifdef HAVE_GEOIP
|
||||
const gchar *map = NULL;
|
||||
#endif /* HAVE_GEOIP */
|
||||
const gchar *follow_stream = NULL;
|
||||
const gchar *graph_a_b = NULL;
|
||||
const gchar *graph_b_a = NULL;
|
||||
|
||||
|
||||
va_start(stock_id_list, stock_id_first);
|
||||
|
||||
/* get all buttons needed */
|
||||
while(stock_id != NULL) {
|
||||
if (strcmp(stock_id, GTK_STOCK_OK) == 0) {
|
||||
ok = stock_id;
|
||||
} else if (strcmp(stock_id, WIRESHARK_STOCK_CREATE_STAT) == 0) {
|
||||
create_stat = stock_id;
|
||||
} else if (strcmp(stock_id, GTK_STOCK_APPLY) == 0) {
|
||||
apply = stock_id;
|
||||
} else if (strcmp(stock_id, GTK_STOCK_SAVE) == 0) {
|
||||
save = stock_id;
|
||||
} else if (strcmp(stock_id, GTK_STOCK_SAVE_AS) == 0) {
|
||||
save_as = stock_id;
|
||||
} else if (strcmp(stock_id, WIRESHARK_STOCK_SAVE_ALL) == 0) {
|
||||
save_all = stock_id;
|
||||
} else if (strcmp(stock_id, WIRESHARK_STOCK_DONT_SAVE) == 0) {
|
||||
dont_save = stock_id;
|
||||
} else if (strcmp(stock_id, WIRESHARK_STOCK_QUIT_DONT_SAVE) == 0) {
|
||||
dont_save = stock_id;
|
||||
} else if (strcmp(stock_id, GTK_STOCK_CANCEL) == 0) {
|
||||
cancel = stock_id;
|
||||
} else if (strcmp(stock_id, GTK_STOCK_CLOSE) == 0) {
|
||||
closex = stock_id;
|
||||
} else if (strcmp(stock_id, GTK_STOCK_CLEAR) == 0) {
|
||||
clear = stock_id;
|
||||
} else if (strcmp(stock_id, GTK_STOCK_REFRESH) == 0) {
|
||||
refresh = stock_id;
|
||||
} else if (strcmp(stock_id, GTK_STOCK_ADD) == 0) {
|
||||
add = stock_id;
|
||||
#ifdef HAVE_LIBPCAP
|
||||
} else if (strcmp(stock_id, WIRESHARK_STOCK_CAPTURE_START) == 0) {
|
||||
cap_start = stock_id;
|
||||
} else if (strcmp(stock_id, WIRESHARK_STOCK_CAPTURE_STOP) == 0) {
|
||||
cap_stop = stock_id;
|
||||
} else if (strcmp(stock_id, WIRESHARK_STOCK_CAPTURE_OPTIONS) == 0) {
|
||||
cap_options = stock_id;
|
||||
#ifdef _WIN32
|
||||
} else if (strcmp(stock_id, WIRESHARK_STOCK_CAPTURE_DETAILS) == 0) {
|
||||
cap_details = stock_id;
|
||||
#endif
|
||||
#endif /* HAVE_LIBPCAP */
|
||||
#ifdef HAVE_GEOIP
|
||||
} else if (strcmp(stock_id, WIRESHARK_STOCK_MAP) == 0) {
|
||||
map = stock_id;
|
||||
#endif /* HAVE_GEOIP */
|
||||
} else if (strcmp(stock_id, WIRESHARK_STOCK_FOLLOW_STREAM) == 0) {
|
||||
follow_stream = stock_id;
|
||||
} else if (strcmp(stock_id, GTK_STOCK_STOP) == 0) {
|
||||
stop = stock_id;
|
||||
} else if (strcmp(stock_id, GTK_STOCK_HELP) == 0) {
|
||||
help = stock_id;
|
||||
} else if (strcmp(stock_id, GTK_STOCK_PRINT) == 0) {
|
||||
print = stock_id;
|
||||
} else if (strcmp(stock_id, GTK_STOCK_FIND) == 0) {
|
||||
find = stock_id;
|
||||
} else if (strcmp(stock_id, GTK_STOCK_JUMP_TO) == 0) {
|
||||
jump = stock_id;
|
||||
} else if (strcmp(stock_id, GTK_STOCK_YES) == 0) {
|
||||
yes = stock_id;
|
||||
} else if (strcmp(stock_id, GTK_STOCK_NO) == 0) {
|
||||
no = stock_id;
|
||||
} else if (strcmp(stock_id, WIRESHARK_STOCK_FILTER_OUT_STREAM) == 0) {
|
||||
filter_stream = stock_id;
|
||||
} else if (strcmp(stock_id, GTK_STOCK_DELETE) == 0) {
|
||||
delete_id = stock_id;
|
||||
} else if (strcmp(stock_id, GTK_STOCK_COPY) == 0) {
|
||||
copy = stock_id;
|
||||
} else if (strcmp(stock_id, WIRESHARK_STOCK_GRAPH_A_B) == 0) {
|
||||
graph_a_b = stock_id;
|
||||
} else if (strcmp(stock_id, WIRESHARK_STOCK_GRAPH_B_A) == 0) {
|
||||
graph_b_a = stock_id;
|
||||
} else {
|
||||
/* we don't know that button! */
|
||||
g_assert_not_reached();
|
||||
}
|
||||
buttons++;
|
||||
stock_id = va_arg(stock_id_list, gchar *);
|
||||
}
|
||||
va_end(stock_id_list);
|
||||
|
||||
hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, DLG_BUTTON_SPACING, FALSE);
|
||||
gtk_widget_show(hbox);
|
||||
|
||||
button_hbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
|
||||
gtk_box_pack_end(GTK_BOX(hbox), button_hbox, TRUE, TRUE, 0);
|
||||
g_object_set_data(G_OBJECT(hbox), BUTTON_HBOX_KEY, button_hbox);
|
||||
gtk_widget_show(button_hbox);
|
||||
gtk_box_set_spacing(GTK_BOX(button_hbox), DLG_BUTTON_SPACING);
|
||||
|
||||
help_hbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
|
||||
gtk_box_pack_end(GTK_BOX(hbox), help_hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show(help_hbox);
|
||||
gtk_box_set_spacing(GTK_BOX(help_hbox), DLG_BUTTON_SPACING);
|
||||
|
||||
if (buttons == 0) {
|
||||
/* if no buttons wanted, simply do nothing */
|
||||
return hbox;
|
||||
}
|
||||
|
||||
if (buttons == 1) {
|
||||
/* if only one button, simply put it in the middle (default) */
|
||||
dlg_button_new(hbox, button_hbox, stock_id_first);
|
||||
return hbox;
|
||||
}
|
||||
|
||||
/* do we have a help button? -> special handling for it */
|
||||
if (help) {
|
||||
button = ws_gtk_button_new_from_stock(help);
|
||||
gtk_widget_set_can_default(button, TRUE);
|
||||
g_object_set_data(G_OBJECT(hbox), help, button);
|
||||
gtk_box_pack_start(GTK_BOX(help_hbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show(button);
|
||||
buttons--;
|
||||
}
|
||||
|
||||
/* do we have a copy button? -> special handling for it */
|
||||
if (copy) {
|
||||
button = ws_gtk_button_new_from_stock(copy);
|
||||
gtk_widget_set_can_default(button, TRUE);
|
||||
g_object_set_data(G_OBJECT(hbox), copy, button);
|
||||
gtk_box_pack_start(GTK_BOX(help_hbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show(button);
|
||||
buttons--;
|
||||
}
|
||||
|
||||
/* do we have a refresh button? -> special handling for it */
|
||||
if (refresh) {
|
||||
button = ws_gtk_button_new_from_stock(refresh);
|
||||
g_object_set_data(G_OBJECT(hbox), refresh, button);
|
||||
gtk_box_pack_start(GTK_BOX(help_hbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show(button);
|
||||
buttons--;
|
||||
}
|
||||
|
||||
/* do we have an add button? -> special handling for it */
|
||||
if (add) {
|
||||
button = ws_gtk_button_new_from_stock(add);
|
||||
g_object_set_data(G_OBJECT(hbox), add, button);
|
||||
gtk_box_pack_start(GTK_BOX(help_hbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show(button);
|
||||
buttons--;
|
||||
}
|
||||
|
||||
#ifdef HAVE_GEOIP
|
||||
/* do we have a map button? -> special handling for it */
|
||||
if (map) {
|
||||
button = ws_gtk_button_new_from_stock(map);
|
||||
gtk_widget_set_can_default(button, TRUE);
|
||||
g_object_set_data(G_OBJECT(hbox), map, button);
|
||||
gtk_box_pack_start(GTK_BOX(help_hbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show(button);
|
||||
buttons--;
|
||||
}
|
||||
#endif /* HAVE_GEOIP */
|
||||
|
||||
/* if more than one button, sort buttons from left to right */
|
||||
/* (the whole button cluster will then be right aligned) */
|
||||
gtk_button_box_set_layout (GTK_BUTTON_BOX(button_hbox), GTK_BUTTONBOX_END);
|
||||
|
||||
#if !defined(_WIN32)
|
||||
/* beware: sequence of buttons are important! */
|
||||
|
||||
/* XXX: this can be implemented more elegant of course, but it works as it should */
|
||||
if (buttons == 2) {
|
||||
if (ok && cancel) {
|
||||
dlg_button_new(hbox, button_hbox, cancel);
|
||||
dlg_button_new(hbox, button_hbox, ok);
|
||||
return hbox;
|
||||
}
|
||||
if (print && cancel) {
|
||||
dlg_button_new(hbox, button_hbox, cancel);
|
||||
dlg_button_new(hbox, button_hbox, print);
|
||||
return hbox;
|
||||
}
|
||||
if (find && cancel) {
|
||||
dlg_button_new(hbox, button_hbox, cancel);
|
||||
dlg_button_new(hbox, button_hbox, find);
|
||||
return hbox;
|
||||
}
|
||||
if (jump && cancel) {
|
||||
dlg_button_new(hbox, button_hbox, cancel);
|
||||
dlg_button_new(hbox, button_hbox, jump);
|
||||
return hbox;
|
||||
}
|
||||
if (save && cancel) {
|
||||
dlg_button_new(hbox, button_hbox, cancel);
|
||||
dlg_button_new(hbox, button_hbox, save);
|
||||
return hbox;
|
||||
}
|
||||
if (ok && clear) {
|
||||
dlg_button_new(hbox, button_hbox, clear);
|
||||
dlg_button_new(hbox, button_hbox, ok);
|
||||
return hbox;
|
||||
}
|
||||
if (save && closex) {
|
||||
dlg_button_new(hbox, button_hbox, closex);
|
||||
dlg_button_new(hbox, button_hbox, save);
|
||||
return hbox;
|
||||
}
|
||||
if (create_stat && cancel) {
|
||||
dlg_button_new(hbox, button_hbox, cancel);
|
||||
dlg_button_new(hbox, button_hbox, create_stat);
|
||||
return hbox;
|
||||
}
|
||||
if (cap_start && cancel) {
|
||||
dlg_button_new(hbox, button_hbox, cancel);
|
||||
dlg_button_new(hbox, button_hbox, cap_start);
|
||||
return hbox;
|
||||
}
|
||||
if (cap_stop && cancel) {
|
||||
dlg_button_new(hbox, button_hbox, cancel);
|
||||
dlg_button_new(hbox, button_hbox, cap_stop);
|
||||
return hbox;
|
||||
}
|
||||
if (delete_id && cancel) {
|
||||
dlg_button_new(hbox, button_hbox, cancel);
|
||||
dlg_button_new(hbox, button_hbox, delete_id);
|
||||
return hbox;
|
||||
}
|
||||
}
|
||||
if (buttons == 3) {
|
||||
if (ok && save && closex) {
|
||||
dlg_button_new(hbox, button_hbox, save);
|
||||
dlg_button_new(hbox, button_hbox, closex);
|
||||
dlg_button_new(hbox, button_hbox, ok);
|
||||
return hbox;
|
||||
}
|
||||
if (ok && apply && cancel) {
|
||||
dlg_button_new(hbox, button_hbox, apply);
|
||||
dlg_button_new(hbox, button_hbox, cancel);
|
||||
dlg_button_new(hbox, button_hbox, ok);
|
||||
return hbox;
|
||||
}
|
||||
if (apply && save && closex) {
|
||||
dlg_button_new(hbox, button_hbox, save);
|
||||
dlg_button_new(hbox, button_hbox, closex);
|
||||
dlg_button_new(hbox, button_hbox, apply);
|
||||
return hbox;
|
||||
}
|
||||
if (yes && no && cancel) {
|
||||
dlg_button_new(hbox, button_hbox, no);
|
||||
dlg_button_new(hbox, button_hbox, cancel);
|
||||
dlg_button_new(hbox, button_hbox, yes);
|
||||
return hbox;
|
||||
}
|
||||
if (save && dont_save && cancel) {
|
||||
dlg_button_new(hbox, button_hbox, dont_save);
|
||||
dlg_button_new(hbox, button_hbox, cancel);
|
||||
dlg_button_new(hbox, button_hbox, save);
|
||||
return hbox;
|
||||
}
|
||||
}
|
||||
if (buttons == 4) {
|
||||
if (ok && apply && save && cancel) {
|
||||
dlg_button_new(hbox, button_hbox, save);
|
||||
dlg_button_new(hbox, button_hbox, apply);
|
||||
dlg_button_new(hbox, button_hbox, cancel);
|
||||
dlg_button_new(hbox, button_hbox, ok);
|
||||
return hbox;
|
||||
}
|
||||
if (ok && apply && save && closex) {
|
||||
dlg_button_new(hbox, button_hbox, save);
|
||||
dlg_button_new(hbox, button_hbox, apply);
|
||||
dlg_button_new(hbox, button_hbox, closex);
|
||||
dlg_button_new(hbox, button_hbox, ok);
|
||||
return hbox;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* beware: sequence of buttons is important! */
|
||||
if (ok != NULL) dlg_button_new(hbox, button_hbox, ok);
|
||||
if (delete_id != NULL) dlg_button_new(hbox, button_hbox, delete_id);
|
||||
if (jump != NULL) dlg_button_new(hbox, button_hbox, jump);
|
||||
if (find != NULL) dlg_button_new(hbox, button_hbox, find);
|
||||
if (print != NULL) dlg_button_new(hbox, button_hbox, print);
|
||||
if (create_stat != NULL) dlg_button_new(hbox, button_hbox, create_stat);
|
||||
if (apply != NULL) dlg_button_new(hbox, button_hbox, apply);
|
||||
if (yes != NULL) dlg_button_new(hbox, button_hbox, yes);
|
||||
if (no != NULL) dlg_button_new(hbox, button_hbox, no);
|
||||
if (save != NULL) dlg_button_new(hbox, button_hbox, save);
|
||||
if (save_as != NULL) dlg_button_new(hbox, button_hbox, save_as);
|
||||
if (save_all != NULL) dlg_button_new(hbox, button_hbox, save_all);
|
||||
if (dont_save != NULL) dlg_button_new(hbox, button_hbox, dont_save);
|
||||
if (cap_start != NULL) dlg_button_new(hbox, button_hbox, cap_start);
|
||||
if (cap_stop != NULL) dlg_button_new(hbox, button_hbox, cap_stop);
|
||||
if (cap_options != NULL) dlg_button_new(hbox, button_hbox, cap_options);
|
||||
#ifdef _WIN32
|
||||
if (cap_details != NULL) dlg_button_new(hbox, button_hbox, cap_details);
|
||||
#endif
|
||||
if (stop != NULL) dlg_button_new(hbox, button_hbox, stop);
|
||||
if (clear != NULL) dlg_button_new(hbox, button_hbox, clear);
|
||||
if (filter_stream != NULL) dlg_button_new(hbox, button_hbox, filter_stream);
|
||||
if (follow_stream != NULL) dlg_button_new(hbox, button_hbox, follow_stream);
|
||||
if (graph_a_b != NULL) dlg_button_new(hbox, button_hbox, graph_a_b);
|
||||
if (graph_b_a != NULL) dlg_button_new(hbox, button_hbox, graph_b_a);
|
||||
if (closex != NULL) dlg_button_new(hbox, button_hbox, closex);
|
||||
if (cancel != NULL) dlg_button_new(hbox, button_hbox, cancel);
|
||||
|
||||
return hbox;
|
||||
}
|
||||
|
||||
|
||||
/* Create a dialog box window that belongs to Wireshark's main window. */
|
||||
GtkWidget *
|
||||
dlg_window_new(const gchar *title)
|
||||
{
|
||||
GtkWidget *win;
|
||||
|
||||
win = window_new(GTK_WINDOW_TOPLEVEL, title);
|
||||
|
||||
/*
|
||||
* On Windows, making the dialogs transient to top_level behaves strangely.
|
||||
* It is not possible any more to bring the top level window to front easily.
|
||||
* So we don't do this on Windows.
|
||||
*
|
||||
* XXX: Note well: This means that *on Windows* any code which creates a
|
||||
* window using dlg_window_new() and then calls
|
||||
* gtk_widget_destroy_with_parent() will *not* get the desired effect
|
||||
* since the dialog window actually has has no parent.
|
||||
*/
|
||||
#ifndef _WIN32
|
||||
if (top_level) {
|
||||
gtk_window_set_transient_for(GTK_WINDOW(win), GTK_WINDOW(top_level));
|
||||
}
|
||||
#endif /*_WIN32*/
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
/* Create a dialog box window that belongs to Wireshark's main window. */
|
||||
GtkWidget *
|
||||
dlg_window_new_with_geom(const gchar *title, const gchar *geom_name, GtkWindowPosition pos)
|
||||
{
|
||||
GtkWidget *win;
|
||||
|
||||
win = window_new_with_geom(GTK_WINDOW_TOPLEVEL, title, geom_name ? geom_name : title, pos);
|
||||
|
||||
/*
|
||||
* XXX - if we're running in the capture child process, we can't easily
|
||||
* make this window transient for the main process's window. We just
|
||||
* punt here.
|
||||
*
|
||||
* Perhaps the child process should only capture packets, write them to
|
||||
* a file, and somehow notify the parent process and let *it* do all
|
||||
* the GUI work. If we can do that efficiently (so that we don't drop
|
||||
* more packets), perhaps we can also do so even when we're *not* doing
|
||||
* an "Update list of packets in real time" capture. That'd let the
|
||||
* child process run set-UID on platforms where you need that in order
|
||||
* to capture, and might also simplify the job of having the GUI main
|
||||
* loop wait both for user input and packet arrival.
|
||||
*/
|
||||
/*
|
||||
* On Windows, making the dialogs transient to top_level behaves strangely.
|
||||
* It is not possible any more to bring the top level window to front easily.
|
||||
* So we don't do this on Windows.
|
||||
*/
|
||||
#ifndef _WIN32
|
||||
if (top_level) {
|
||||
gtk_window_set_transient_for(GTK_WINDOW(win), GTK_WINDOW(top_level));
|
||||
}
|
||||
#endif /*_WIN32*/
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
/* Create a configuration dialog box window that belongs to Wireshark's
|
||||
* main window and add the name of the current profile name to its title bar
|
||||
*/
|
||||
GtkWidget *
|
||||
dlg_conf_window_new(const gchar *title)
|
||||
{
|
||||
const char *profile_name;
|
||||
gchar *win_name;
|
||||
GtkWidget *win;
|
||||
|
||||
/*
|
||||
* Set window title to reflect which preferences profile we are
|
||||
* working with.
|
||||
*/
|
||||
profile_name = get_profile_name();
|
||||
|
||||
win_name = g_strdup_printf("%s - Profile: %s", title, profile_name);
|
||||
win = dlg_window_new(win_name);
|
||||
|
||||
g_free(win_name);
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
/* Set the "activate" signal for a widget to call a routine to
|
||||
activate the "OK" button for a dialog box.
|
||||
|
||||
XXX - there should be a way to specify that a GtkEntry widget
|
||||
shouldn't itself handle the Return key, but should let it be
|
||||
passed on to the parent, so that you don't have to do this
|
||||
by hand for every GtkEntry widget in a dialog box, but, alas,
|
||||
there isn't. (Does this problem exist for other widgets?
|
||||
I.e., are there any others that seize the Return key? */
|
||||
void
|
||||
dlg_set_activate(GtkWidget *widget, GtkWidget *ok_button)
|
||||
{
|
||||
g_signal_connect(widget, "activate", G_CALLBACK(dlg_activate), ok_button);
|
||||
}
|
||||
|
||||
static void
|
||||
dlg_activate (GtkWidget *widget _U_, gpointer ok_button)
|
||||
{
|
||||
gtk_widget_activate(GTK_WIDGET(ok_button));
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
||||
* :indentSize=4:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -1,154 +0,0 @@
|
|||
/* dlg_utils.h
|
||||
* Declarations of utilities to use when constructing dialogs
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/** @defgroup dialog_group Dialogs
|
||||
*
|
||||
* Dialogs are specially created windows and are related to their parent windows (usually the main window).
|
||||
* See: @ref howto_window_page for details.
|
||||
*
|
||||
* Normal dialogs are created using dlg_window_new().
|
||||
*
|
||||
* - "About" about_wireshark_cb()
|
||||
* - "Capture Options" capture_prep_cb()
|
||||
* - "Capture" capture_info_ui_create()
|
||||
* - "Interface Options" ifopts_edit_cb()
|
||||
* - "Coloring Rules" colorize_dialog_new()
|
||||
* - "Edit Color Filter" edit_color_filter_dialog_new()
|
||||
* - "Compute DCE-RPC SRT statistics" gtk_dcerpcstat_cb()
|
||||
* - "Decode As: Show" decode_show_cb()
|
||||
* - "Decode As" decode_as_cb()
|
||||
* - "Filter Expression" dfilter_expr_dlg_new()
|
||||
* - "Compute Fibre Channel Service Response Time statistics" gtk_fcstat_cb()
|
||||
* - "Filter" (display and capture) filter_dialog_new()
|
||||
* - "Find Packet" find_frame_cb()
|
||||
* - "Follow TCP stream" follow_stream_cb()
|
||||
* - "Go To Packet" goto_frame_cb()
|
||||
* - "Compute LDAP Service Response Time statistics" gtk_ldapstat_cb()
|
||||
* - "Preferences" tools_plugins_cmd_cb()
|
||||
* - "Print" / "Export" open_print_dialog()
|
||||
* - "Progress" create_progress_dlg()
|
||||
* - "Enabled Protocols" proto_cb()
|
||||
* - "Compute ONC-RPC SRT statistics" gtk_rpcstat_cb()
|
||||
* - "RTP Streams" rtpstream_dlg_create()
|
||||
* - "Simple Dialog" display_simple_dialog()
|
||||
* - "Compute SMB SRT statistics" gtk_smbstat_cb()
|
||||
* - "Compute ..." tap_param_dlg_cb()
|
||||
* - "Tcp Graph" create_drawing_area()
|
||||
* - "Tcp Graph Control" control_panel_create()
|
||||
* - "Help for TCP graphing" callback_create_help()
|
||||
* - "Tcp Graph Magnify" magnify_create()
|
||||
*/
|
||||
|
||||
/** @file
|
||||
* Utilities for dialog boxes. Depending on the window functions in
|
||||
* gui_utils.h, see: @ref howto_window_page for details.
|
||||
* @ingroup dialog_group
|
||||
*/
|
||||
|
||||
#ifndef __DLG_UTILS_H__
|
||||
#define __DLG_UTILS_H__
|
||||
|
||||
#if defined(_WIN32)
|
||||
/*
|
||||
* We should calculate these values dynamically using MapDialogRect().
|
||||
* Unfortunately that requires passing a valid dialog HWND, which we
|
||||
* don't have in many cases.
|
||||
* http://msdn.microsoft.com/en-us/library/windows/desktop/aa511279.aspx#sizingspacing
|
||||
*/
|
||||
|
||||
#define DLG_OUTER_MARGIN 11
|
||||
#define DLG_BUTTON_SPACING 7
|
||||
#define DLG_LABEL_SPACING 5
|
||||
#define DLG_UNRELATED_SPACING 11
|
||||
|
||||
/* elif defined (__APPLE__) */
|
||||
#else /* Use the GNOME HIG */
|
||||
|
||||
/* http://developer.gnome.org/hig-book/3.2/design-window.html.en */
|
||||
|
||||
#define DLG_OUTER_MARGIN 12
|
||||
#define DLG_BUTTON_SPACING 6
|
||||
#define DLG_LABEL_SPACING 4 /* Not specified. Guessing. */
|
||||
#define DLG_UNRELATED_SPACING 12
|
||||
|
||||
#endif
|
||||
|
||||
/** Create a dialog box window that belongs to Wireshark's main window.
|
||||
* If you want to create a window, use window_new() instead.
|
||||
* See window_new() for general window usage.
|
||||
*
|
||||
* @param title the title for the new dialog
|
||||
* @return the newly created dialog
|
||||
*/
|
||||
extern GtkWidget *dlg_window_new(const gchar *title);
|
||||
|
||||
/** Create a dialog box window that belongs to Wireshark's main window.
|
||||
* If you want to create a window, use window_new_with_geom() instead.
|
||||
* See window_new_with_geom() for general window usage.
|
||||
*
|
||||
* @param title the title for the new dialog
|
||||
* @param geom_name A unique name for the geometry of this new dialog
|
||||
* @param pos the initial position of the window if a previously saved geometry was not saved or found.
|
||||
* If the initial position does not matter, specify GTK_WIN_POS_NONE.
|
||||
* @return the newly created dialog
|
||||
*/
|
||||
extern GtkWidget *
|
||||
dlg_window_new_with_geom(const gchar *title, const gchar *geom_name, GtkWindowPosition pos);
|
||||
|
||||
/** Create a configuration dialog box window that belongs to Wireshark's
|
||||
* main window and add the name of the current profile name to its title bar
|
||||
* If you want to create a window, use window_new() instead.
|
||||
* See window_new() for general window usage.
|
||||
*
|
||||
* @param title the title for the new dialog
|
||||
* @return the newly created dialog
|
||||
*/
|
||||
extern GtkWidget *dlg_conf_window_new(const gchar *title);
|
||||
|
||||
/** Create a button row (with variable number of buttons) for a dialog.
|
||||
* The button widgets will be available by g_object_get_data(dlg, stock_id) later.
|
||||
*
|
||||
* @param stock_id_first the first button (e.g. GTK_STOCK_OK)
|
||||
* @param ... the next buttons, just like stock_id_first
|
||||
* @return the new button row
|
||||
* @todo move this to gui_utils.h
|
||||
*/
|
||||
extern GtkWidget *dlg_button_row_new(const gchar *stock_id_first, ...);
|
||||
|
||||
/** Set the "activate" signal for a widget to call a routine to
|
||||
* activate the "OK" button for a dialog box.
|
||||
*
|
||||
* @param widget a widget which should be connected (usually a GtkEntry)
|
||||
* @param ok_button the button to be activated
|
||||
* @todo move this to gui_utils.h
|
||||
*/
|
||||
extern void dlg_set_activate(GtkWidget *widget, GtkWidget *ok_button);
|
||||
|
||||
/** Set the focus and default for the nth item in a button row.
|
||||
*
|
||||
* @param hbox A button row returned by dlg_button_row_new().
|
||||
* @param focus_item The button to focus (0 is the first).
|
||||
* @see dlg_button_row_new()
|
||||
*/
|
||||
void dlg_button_focus_nth(GtkWidget *hbox, gint focus_item);
|
||||
|
||||
#endif
|
|
@ -1,67 +0,0 @@
|
|||
# @configure_input@
|
||||
|
||||
# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
|
||||
# by quotes) that should identify the project.
|
||||
|
||||
PROJECT_NAME = Wireshark-GTK
|
||||
|
||||
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
|
||||
# This could be handy for archiving the generated documentation or
|
||||
# if some version control system is used.
|
||||
|
||||
PROJECT_NUMBER = @VERSION@
|
||||
|
||||
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
|
||||
# base path where the generated documentation will be put.
|
||||
# If a relative path is entered, it will be relative to the location
|
||||
# where doxygen was started. If left blank the current directory will be used.
|
||||
|
||||
OUTPUT_DIRECTORY =
|
||||
|
||||
# The INPUT tag can be used to specify the files and/or directories that contain
|
||||
# documented source files. You may enter file names like "myfile.cpp" or
|
||||
# directories like "/usr/src/myproject". Separate the files or directories
|
||||
# with spaces.
|
||||
|
||||
INPUT = . ../progress_dlg.h ../simple_dialog.h
|
||||
|
||||
# If the value of the INPUT tag contains directories, you can use the
|
||||
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
|
||||
# and *.h) to filter out the source-files in the directories. If left
|
||||
# blank the following patterns are tested:
|
||||
# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp
|
||||
# *.h++ *.idl *.odl *.cs *.php *.php3 *.inc
|
||||
|
||||
FILE_PATTERNS = *.h
|
||||
|
||||
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
|
||||
# should be searched for input files as well. Possible values are YES and NO.
|
||||
# If left blank NO is used.
|
||||
|
||||
RECURSIVE = YES
|
||||
|
||||
# The EXCLUDE tag can be used to specify files and/or directories that should
|
||||
# excluded from the INPUT source files. This way you can easily exclude a
|
||||
# subdirectory from a directory tree whose root is specified with the INPUT tag.
|
||||
|
||||
EXCLUDE =
|
||||
|
||||
# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories
|
||||
# that are symbolic links (a Unix filesystem feature) are excluded from the input.
|
||||
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
|
||||
# If the value of the INPUT tag contains directories, you can use the
|
||||
# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
|
||||
# certain files from those directories.
|
||||
|
||||
EXCLUDE_PATTERNS =
|
||||
|
||||
# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
|
||||
# be used to specify the file name of the resulting .chm file. You
|
||||
# can add a path in front of the file if the result should not be
|
||||
# written to the html output directory.
|
||||
|
||||
CHM_FILE = wireshark-gtk.chm
|
||||
|
||||
@INCLUDE = ../../doxygen_global.cfg
|
|
@ -1,316 +0,0 @@
|
|||
/* drag_and_drop.c
|
||||
* Drag and Drop
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
|
||||
#include "../../file.h"
|
||||
#ifdef HAVE_LIBPCAP
|
||||
#include "ui/capture.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBPCAP
|
||||
#include "ui/capture_globals.h"
|
||||
#endif
|
||||
#include "ui/recent_utils.h"
|
||||
#include "ui/simple_dialog.h"
|
||||
|
||||
#include "ui/gtk/gtkglobals.h"
|
||||
#include "ui/gtk/capture_file_dlg.h"
|
||||
#include "ui/gtk/drag_and_drop.h"
|
||||
#include "ui/gtk/main.h"
|
||||
|
||||
#include "ui/gtk/old-gtk-compat.h"
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
enum { DND_TARGET_STRING, DND_TARGET_ROOTWIN, DND_TARGET_URL };
|
||||
|
||||
/* convert drag and drop URI to a local filename */
|
||||
static gchar *
|
||||
dnd_uri2filename(gchar *cf_name)
|
||||
{
|
||||
gchar *src, *dest;
|
||||
gint ret;
|
||||
guint i;
|
||||
gchar esc[3];
|
||||
|
||||
|
||||
/* Remove URI header.
|
||||
* we have to remove the prefix to get a valid filename. */
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
* On win32 (at least WinXP), this prefix looks like (UNC):
|
||||
* file:////servername/sharename/dir1/dir2/capture-file.cap
|
||||
* or (local filename):
|
||||
* file:///d:/dir1/dir2/capture-file.cap
|
||||
*/
|
||||
if (strncmp("file:////", cf_name, 9) == 0) {
|
||||
/* win32 UNC: now becoming: //servername/sharename/dir1/dir2/capture-file.cap */
|
||||
cf_name += 7;
|
||||
} else if (strncmp("file:///", cf_name, 8) == 0) {
|
||||
/* win32 local: now becoming: d:/dir1/dir2/capture-file.cap */
|
||||
cf_name += 8;
|
||||
}
|
||||
#else
|
||||
/*
|
||||
* On UNIX (at least KDE 3.0 Konqueror), this prefix looks like:
|
||||
* file:/dir1/dir2/capture-file.cap
|
||||
*
|
||||
* On UNIX (at least GNOME Nautilus 2.8.2), this prefix looks like:
|
||||
* file:///dir1/dir2/capture-file.cap
|
||||
*/
|
||||
if (strncmp("file:", cf_name, 5) == 0) {
|
||||
/* now becoming: /dir1/dir2/capture-file.cap or ///dir1/dir2/capture-file.cap */
|
||||
cf_name += 5;
|
||||
/* shorten //////thing to /thing */
|
||||
for(; cf_name[1] == '/'; ++cf_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* unescape the escaped URI characters (spaces, ...)
|
||||
*
|
||||
* we have to replace escaped chars to their equivalents,
|
||||
* e.g. %20 (always a two digit hexstring) -> ' '
|
||||
* the percent character '%' is escaped be a double one "%%"
|
||||
*
|
||||
* we do this conversation "in place" as the result is always
|
||||
* equal or smaller in size.
|
||||
*/
|
||||
src = cf_name;
|
||||
dest = cf_name;
|
||||
while (*src) {
|
||||
if (*src == '%') {
|
||||
src++;
|
||||
if (*src == '%') {
|
||||
/* this is an escaped '%' char (was: "%%") */
|
||||
*dest = *src;
|
||||
src++;
|
||||
dest++;
|
||||
} else {
|
||||
/* convert escaped hexnumber to unscaped character */
|
||||
esc[0] = src[0];
|
||||
esc[1] = src[1];
|
||||
esc[2] = '\0';
|
||||
ret = sscanf(esc, "%x", &i);
|
||||
if (ret == 1) {
|
||||
src+=2;
|
||||
*dest = (gchar) i;
|
||||
dest++;
|
||||
} else {
|
||||
/* somethings wrong, just jump over that char
|
||||
* this will result in a wrong string, but we might get
|
||||
* user feedback and can fix it later ;-) */
|
||||
src++;
|
||||
}
|
||||
}
|
||||
#ifdef _WIN32
|
||||
} else if (*src == '/') {
|
||||
*dest = '\\';
|
||||
src++;
|
||||
dest++;
|
||||
#endif
|
||||
} else {
|
||||
*dest = *src;
|
||||
src++;
|
||||
dest++;
|
||||
}
|
||||
}
|
||||
*dest = '\0';
|
||||
|
||||
return cf_name;
|
||||
}
|
||||
|
||||
/* open/merge the dnd file */
|
||||
void
|
||||
dnd_open_file_cmd(gchar *cf_names_freeme)
|
||||
{
|
||||
int err;
|
||||
gchar *cf_name;
|
||||
int in_file_count;
|
||||
int files_work;
|
||||
char **in_filenames;
|
||||
char *tmpname;
|
||||
|
||||
if (cf_names_freeme == NULL) return;
|
||||
|
||||
/* DND_TARGET_URL:
|
||||
* The cf_name_freeme is a single string, containing one or more URI's,
|
||||
* terminated by CR/NL chars. The length of the whole field can be found
|
||||
* in the selection_data->length field. If it contains one file, simply open it,
|
||||
* If it contains more than one file, ask to merge these files. */
|
||||
|
||||
/* count the number of input files */
|
||||
cf_name = cf_names_freeme;
|
||||
for(in_file_count = 0; (cf_name = strstr(cf_name, "\r\n")) != NULL; ) {
|
||||
cf_name += 2;
|
||||
in_file_count++;
|
||||
}
|
||||
if (in_file_count == 0) {
|
||||
g_free(cf_names_freeme);
|
||||
return;
|
||||
}
|
||||
|
||||
in_filenames = (char **)g_malloc(sizeof(char*) * in_file_count);
|
||||
|
||||
/* store the starts of the file entries in a gchar array */
|
||||
cf_name = cf_names_freeme;
|
||||
in_filenames[0] = cf_name;
|
||||
for(files_work = 1; (cf_name = strstr(cf_name, "\r\n")) != NULL && files_work < in_file_count; ) {
|
||||
cf_name += 2;
|
||||
in_filenames[files_work] = cf_name;
|
||||
files_work++;
|
||||
}
|
||||
|
||||
/* replace trailing CR NL simply with zeroes (in place), so we get valid terminated strings */
|
||||
cf_name = cf_names_freeme;
|
||||
g_strdelimit(cf_name, "\r\n", '\0');
|
||||
|
||||
/* convert all filenames from URI to local filename (in place) */
|
||||
for(files_work = 0; files_work < in_file_count; files_work++) {
|
||||
in_filenames[files_work] = dnd_uri2filename(in_filenames[files_work]);
|
||||
}
|
||||
|
||||
if (in_file_count == 1) {
|
||||
/* open and read the capture file (this will close an existing file) */
|
||||
if (cf_open(&cfile, in_filenames[0], WTAP_TYPE_AUTO, FALSE, &err) == CF_OK) {
|
||||
/* XXX - add this to the menu if the read fails? */
|
||||
cf_read(&cfile, FALSE);
|
||||
add_menu_recent_capture_file(in_filenames[0]);
|
||||
} else {
|
||||
/* the capture file couldn't be read (doesn't exist, file format unknown, ...) */
|
||||
}
|
||||
} else {
|
||||
/* merge the files in chronological order */
|
||||
if (cf_merge_files_to_tempfile(top_level, &tmpname, in_file_count, in_filenames,
|
||||
WTAP_FILE_TYPE_SUBTYPE_PCAPNG, FALSE) == CF_OK) {
|
||||
/* Merge succeeded; close the currently-open file and try
|
||||
to open the merged capture file. */
|
||||
cf_close(&cfile);
|
||||
if (cf_open(&cfile, tmpname, WTAP_TYPE_AUTO, TRUE /* temporary file */, &err) == CF_OK) {
|
||||
g_free(tmpname);
|
||||
cf_read(&cfile, FALSE);
|
||||
} else {
|
||||
/* The merged file couldn't be read. */
|
||||
g_free(tmpname);
|
||||
}
|
||||
} else {
|
||||
/* merge failed */
|
||||
g_free(tmpname);
|
||||
}
|
||||
}
|
||||
|
||||
g_free(in_filenames);
|
||||
g_free(cf_names_freeme);
|
||||
}
|
||||
|
||||
/* we have received some drag and drop data */
|
||||
/* (as we only registered to "text/uri-list", we will only get a file list here) */
|
||||
static void
|
||||
dnd_data_received(GtkWidget *widget _U_, GdkDragContext *dc _U_, gint x _U_, gint y _U_,
|
||||
GtkSelectionData *selection_data, guint info, guint t _U_, gpointer data _U_)
|
||||
{
|
||||
gchar *cf_names_freeme;
|
||||
const guchar *sel_data_data;
|
||||
gint sel_data_len;
|
||||
|
||||
if (info == DND_TARGET_URL) {
|
||||
/* Usually we block incoming events by disabling the corresponding menu/toolbar items.
|
||||
* This is the only place where an incoming event won't be blocked in such a way,
|
||||
* so we have to take care of NOT loading a new file while a different process
|
||||
* (e.g. capture/load/...) is still in progress. */
|
||||
|
||||
#ifdef HAVE_LIBPCAP
|
||||
/* if a capture is running, do nothing but warn the user */
|
||||
if((global_capture_session.state != CAPTURE_STOPPED)) {
|
||||
simple_dialog(ESD_TYPE_CONFIRMATION,
|
||||
ESD_BTN_OK,
|
||||
"%sDrag and Drop currently not possible.%s\n\n"
|
||||
"Dropping a file isn't possible while a capture is in progress.",
|
||||
simple_dialog_primary_start(), simple_dialog_primary_end());
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* if another file read is still in progress, do nothing but warn the user */
|
||||
if(cfile.state == FILE_READ_IN_PROGRESS) {
|
||||
simple_dialog(ESD_TYPE_CONFIRMATION,
|
||||
ESD_BTN_OK,
|
||||
"%sDrag and Drop currently not possible.%s\n\n"
|
||||
"Dropping a file isn't possible while loading another capture file.",
|
||||
simple_dialog_primary_start(), simple_dialog_primary_end());
|
||||
return;
|
||||
}
|
||||
|
||||
/* the selection_data will soon be gone, make a copy first */
|
||||
/* the data string is not zero terminated -> make a zero terminated "copy" of it */
|
||||
sel_data_len = gtk_selection_data_get_length(selection_data);
|
||||
sel_data_data = gtk_selection_data_get_data(selection_data);
|
||||
cf_names_freeme = (gchar *)g_malloc(sel_data_len + 1);
|
||||
memcpy(cf_names_freeme, sel_data_data, sel_data_len);
|
||||
cf_names_freeme[sel_data_len] = '\0';
|
||||
|
||||
/* If there's unsaved data, let the user save it first.
|
||||
If they cancel out of it, don't open the file. */
|
||||
if (do_file_close(&cfile, FALSE, " before opening a new capture file"))
|
||||
dnd_open_file_cmd(cf_names_freeme);
|
||||
}
|
||||
}
|
||||
|
||||
/* init the drag and drop functionality */
|
||||
void
|
||||
dnd_init(GtkWidget *w)
|
||||
{
|
||||
/* we are only interested in the URI list containing filenames */
|
||||
static GtkTargetEntry target_entry[] = {
|
||||
/*{"STRING", 0, DND_TARGET_STRING},*/
|
||||
/*{"text/plain", 0, DND_TARGET_STRING},*/
|
||||
{"text/uri-list", 0, DND_TARGET_URL}
|
||||
};
|
||||
|
||||
/* set this window as a dnd destination */
|
||||
gtk_drag_dest_set(
|
||||
w, GTK_DEST_DEFAULT_ALL, target_entry,
|
||||
sizeof(target_entry) / sizeof(GtkTargetEntry),
|
||||
(GdkDragAction)(GDK_ACTION_MOVE | GDK_ACTION_COPY) );
|
||||
|
||||
/* get notified, if some dnd coming in */
|
||||
g_signal_connect(w, "drag_data_received", G_CALLBACK(dnd_data_received), NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
||||
* :indentSize=4:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -1,38 +0,0 @@
|
|||
/* drag_and_drop.h
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __DRAG_AND_DROP_H__
|
||||
#define __DRAG_AND_DROP_H__
|
||||
|
||||
|
||||
/** Init the drag-n-drop functionality.
|
||||
*
|
||||
* @param w the target widget for this dnd operations
|
||||
*/
|
||||
extern void dnd_init(GtkWidget *w);
|
||||
|
||||
/** Open a new file coming from drag and drop.
|
||||
* @param cf_names_freeme the selection data reported from GTK
|
||||
*/
|
||||
extern void dnd_open_file_cmd(gchar *cf_names_freeme);
|
||||
|
||||
|
||||
#endif /* __DRAG_AND_DROP_H__ */
|
|
@ -1,259 +0,0 @@
|
|||
/* edit_packet_comment_dlg.c
|
||||
* Dialog box for editing or adding packet comments.
|
||||
* Copyright 2012 Anders Broman <anders.broman@ericsson.com>
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "ui/main_statusbar.h"
|
||||
|
||||
#include "ui/gtk/dlg_utils.h"
|
||||
#include "ui/gtk/expert_comp_dlg.h"
|
||||
#include "ui/gtk/gui_utils.h"
|
||||
#include "ui/gtk/main.h"
|
||||
#include "ui/gtk/packet_list.h"
|
||||
#include "ui/gtk/edit_packet_comment_dlg.h"
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
static GtkWidget *edit_or_add_pkt_comment_dlg = NULL;
|
||||
static GtkWidget *edit_or_add_capture_comment_dlg = NULL;
|
||||
|
||||
static void
|
||||
pkt_comment_text_buff_ok_cb(GtkWidget *w _U_, GtkWidget *view)
|
||||
{
|
||||
GtkTextBuffer *buffer;
|
||||
GtkTextIter start_iter;
|
||||
GtkTextIter end_iter;
|
||||
gchar *new_packet_comment;
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
gtk_text_buffer_get_start_iter (buffer, &start_iter);
|
||||
gtk_text_buffer_get_end_iter (buffer, &end_iter);
|
||||
|
||||
new_packet_comment = gtk_text_buffer_get_text (buffer, &start_iter, &end_iter, FALSE /* whether to include invisible text */);
|
||||
|
||||
/*g_warning("The new comment is '%s'",new_packet_comment);*/
|
||||
|
||||
packet_list_update_packet_comment(new_packet_comment);
|
||||
expert_comp_packet_comment_updated();
|
||||
status_expert_update();
|
||||
|
||||
window_destroy(edit_or_add_pkt_comment_dlg);
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
capture_comment_text_buff_ok_cb(GtkWidget *w _U_, GtkWidget *view)
|
||||
{
|
||||
GtkTextBuffer *buffer;
|
||||
GtkTextIter start_iter;
|
||||
GtkTextIter end_iter;
|
||||
gchar *new_capture_comment;
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
gtk_text_buffer_get_start_iter (buffer, &start_iter);
|
||||
gtk_text_buffer_get_end_iter (buffer, &end_iter);
|
||||
|
||||
new_capture_comment = gtk_text_buffer_get_text (buffer, &start_iter, &end_iter, FALSE /* whether to include invisible text */);
|
||||
|
||||
/*g_warning("The new comment is '%s'",new_capture_comment);*/
|
||||
cf_update_section_comment(&cfile, new_capture_comment);
|
||||
|
||||
/* Update the main window as appropriate */
|
||||
main_update_for_unsaved_changes(&cfile);
|
||||
|
||||
status_capture_comment_update();
|
||||
|
||||
window_destroy(edit_or_add_capture_comment_dlg);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
edit_packet_comment_dlg (GtkAction *action _U_, gpointer data _U_)
|
||||
{
|
||||
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *view;
|
||||
GtkWidget *scroll;
|
||||
GtkWidget *bbox;
|
||||
GtkWidget *ok_bt, *cancel_bt, *help_bt;
|
||||
GtkTextBuffer *buffer;
|
||||
gchar *opt_comment;
|
||||
|
||||
edit_or_add_pkt_comment_dlg = dlg_window_new ("Edit or Add Packet Comments");
|
||||
gtk_widget_set_size_request (edit_or_add_pkt_comment_dlg, 500, 160);
|
||||
gtk_window_set_resizable (GTK_WINDOW (edit_or_add_pkt_comment_dlg), TRUE);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (edit_or_add_pkt_comment_dlg), DLG_OUTER_MARGIN);
|
||||
|
||||
vbox = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, DLG_UNRELATED_SPACING, FALSE);
|
||||
gtk_container_add (GTK_CONTAINER (edit_or_add_pkt_comment_dlg), vbox);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
view = gtk_text_view_new ();
|
||||
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_WORD);
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
gtk_widget_show (view);
|
||||
|
||||
scroll = gtk_scrolled_window_new(NULL, NULL);
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
|
||||
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
||||
gtk_container_add(GTK_CONTAINER(scroll), view);
|
||||
gtk_widget_show(scroll);
|
||||
gtk_box_pack_start(GTK_BOX (vbox), scroll, TRUE, TRUE, 0);
|
||||
|
||||
/* Get the comment */
|
||||
opt_comment = packet_list_get_packet_comment();
|
||||
/*g_warning("Fetched comment '%s'",opt_comment);*/
|
||||
|
||||
if(opt_comment){
|
||||
gtk_text_buffer_set_text(buffer, opt_comment, -1);
|
||||
g_free(opt_comment);
|
||||
}
|
||||
|
||||
/* Button row. */
|
||||
bbox = dlg_button_row_new (GTK_STOCK_OK, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
|
||||
gtk_box_pack_end (GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
|
||||
|
||||
ok_bt = (GtkWidget *)g_object_get_data (G_OBJECT(bbox), GTK_STOCK_OK);
|
||||
g_signal_connect (ok_bt, "clicked", G_CALLBACK(pkt_comment_text_buff_ok_cb), view);
|
||||
gtk_widget_set_sensitive (ok_bt, TRUE);
|
||||
|
||||
cancel_bt = (GtkWidget *)g_object_get_data (G_OBJECT(bbox), GTK_STOCK_CANCEL);
|
||||
window_set_cancel_button (edit_or_add_pkt_comment_dlg, cancel_bt, window_cancel_button_cb);
|
||||
|
||||
help_bt = (GtkWidget *)g_object_get_data (G_OBJECT(bbox), GTK_STOCK_HELP);
|
||||
#if 0
|
||||
g_signal_connect (help_bt, "clicked",/* G_CALLBACK(topic_cb)*/NULL, /*(gpointer)HELP_MANUAL_ADDR_RESOLVE_DIALOG*/NULL);
|
||||
#endif
|
||||
gtk_widget_set_sensitive (help_bt, FALSE);
|
||||
|
||||
gtk_widget_grab_default (ok_bt);
|
||||
g_signal_connect (edit_or_add_pkt_comment_dlg, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
||||
|
||||
|
||||
gtk_widget_show (edit_or_add_pkt_comment_dlg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
edit_capture_comment_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
|
||||
{
|
||||
/* Note that we no longer have an "Edit Capture Comment" dialog box. */
|
||||
edit_or_add_capture_comment_dlg = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
edit_capture_comment_dlg_launch (GtkAction *action _U_, gpointer data _U_)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *view;
|
||||
GtkWidget *scroll;
|
||||
GtkWidget *bbox;
|
||||
GtkWidget *ok_bt, *cancel_bt, *help_bt;
|
||||
GtkTextBuffer *buffer = NULL;
|
||||
const gchar *comment_str = NULL;
|
||||
|
||||
if (edit_or_add_capture_comment_dlg != NULL) {
|
||||
/* There's already an "Edit Capture Comment" dialog box; reactivate it. */
|
||||
reactivate_window(edit_or_add_capture_comment_dlg);
|
||||
return;
|
||||
}
|
||||
|
||||
edit_or_add_capture_comment_dlg = dlg_window_new ("Edit or Add Capture Comments");
|
||||
gtk_widget_set_size_request (edit_or_add_capture_comment_dlg, 500, 160);
|
||||
gtk_window_set_resizable (GTK_WINDOW (edit_or_add_capture_comment_dlg), TRUE);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (edit_or_add_capture_comment_dlg), DLG_OUTER_MARGIN);
|
||||
|
||||
g_signal_connect(edit_or_add_capture_comment_dlg, "destroy",
|
||||
G_CALLBACK(edit_capture_comment_destroy_cb), NULL);
|
||||
|
||||
vbox = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, DLG_UNRELATED_SPACING, FALSE);
|
||||
gtk_container_add (GTK_CONTAINER (edit_or_add_capture_comment_dlg), vbox);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
view = gtk_text_view_new ();
|
||||
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_WORD);
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||
gtk_widget_show (view);
|
||||
|
||||
scroll = gtk_scrolled_window_new(NULL, NULL);
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
|
||||
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
||||
gtk_container_add(GTK_CONTAINER(scroll), view);
|
||||
gtk_widget_show(scroll);
|
||||
gtk_box_pack_start(GTK_BOX (vbox), scroll, TRUE, TRUE, 0);
|
||||
|
||||
/* Get the comment */
|
||||
comment_str = cf_read_section_comment(&cfile);
|
||||
if(comment_str != NULL){
|
||||
gtk_text_buffer_set_text (buffer, comment_str, -1);
|
||||
}
|
||||
|
||||
/* Button row. */
|
||||
bbox = dlg_button_row_new (GTK_STOCK_OK, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
|
||||
gtk_box_pack_end (GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
|
||||
|
||||
ok_bt = (GtkWidget *)g_object_get_data (G_OBJECT(bbox), GTK_STOCK_OK);
|
||||
g_signal_connect (ok_bt, "clicked", G_CALLBACK(capture_comment_text_buff_ok_cb), view);
|
||||
gtk_widget_set_sensitive (ok_bt, TRUE);
|
||||
|
||||
cancel_bt = (GtkWidget *)g_object_get_data (G_OBJECT(bbox), GTK_STOCK_CANCEL);
|
||||
window_set_cancel_button (edit_or_add_capture_comment_dlg, cancel_bt, window_cancel_button_cb);
|
||||
|
||||
help_bt = (GtkWidget *)g_object_get_data (G_OBJECT(bbox), GTK_STOCK_HELP);
|
||||
#if 0
|
||||
g_signal_connect (help_bt, "clicked",/* G_CALLBACK(topic_cb)*/NULL, /*(gpointer)HELP_MANUAL_ADDR_RESOLVE_DIALOG*/NULL);
|
||||
#endif
|
||||
gtk_widget_set_sensitive (help_bt, FALSE);
|
||||
|
||||
gtk_widget_grab_default (ok_bt);
|
||||
g_signal_connect (edit_or_add_capture_comment_dlg, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
||||
|
||||
gtk_widget_show (edit_or_add_capture_comment_dlg);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
edit_capture_comment_dlg_hide(void)
|
||||
{
|
||||
window_destroy(edit_or_add_capture_comment_dlg);
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local Variables:
|
||||
* c-basic-offset: 2
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=2 tabstop=8 expandtab:
|
||||
* :indentSize=2:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -1,30 +0,0 @@
|
|||
/* edit_packet_comment_dlg.h
|
||||
* Dialog box for editing or adding packet comments.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __EDIT_PACKET_COMMENTS_H__
|
||||
#define __EDIT_PACKET_COMMENTS_H__
|
||||
|
||||
void edit_packet_comment_dlg (GtkAction *action, gpointer data);
|
||||
void edit_capture_comment_dlg_launch (GtkAction *action, gpointer data);
|
||||
void edit_capture_comment_dlg_hide (void);
|
||||
|
||||
#endif /* __EDIT_PACKET_COMMENTS_H__ */
|
File diff suppressed because it is too large
Load Diff
|
@ -1,29 +0,0 @@
|
|||
/* expert_comp_dlg.h
|
||||
* expert_comp_dlg 2005 Greg Morris
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __EXPERT_COMP_DLG_H__
|
||||
#define __EXPERT_COMP_DLG_H__
|
||||
|
||||
void expert_comp_dlg_launch(void);
|
||||
void expert_comp_packet_comment_updated(void);
|
||||
|
||||
#endif /* __EXPERT_COMP_DLG_H__ */
|
|
@ -1,877 +0,0 @@
|
|||
/* expert_comp_table.c
|
||||
* expert_comp_table 2005 Greg Morris
|
||||
* Portions copied from service_response_time_table.c by Ronnie Sahlberg
|
||||
* Helper routines common to all composite expert statistics
|
||||
* tap.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "epan/packet_info.h"
|
||||
#include "epan/strutil.h"
|
||||
|
||||
#include "ui/simple_dialog.h"
|
||||
|
||||
#include <wsutil/utf8_entities.h>
|
||||
#include <wsutil/strtoi.h>
|
||||
|
||||
#include "ui/gtk/expert_comp_table.h"
|
||||
#include "ui/gtk/filter_utils.h"
|
||||
#include "ui/gtk/find_dlg.h"
|
||||
#include "ui/gtk/color_dlg.h"
|
||||
#include "ui/gtk/main.h"
|
||||
#include "ui/gtk/gui_utils.h"
|
||||
#include "ui/gtk/gtkglobals.h"
|
||||
#include "ui/gtk/webbrowser.h"
|
||||
#include "ui/gtk/stock_icons.h"
|
||||
|
||||
#include "ui/gtk/old-gtk-compat.h"
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
const char *packet = "Packet:";
|
||||
|
||||
enum
|
||||
{
|
||||
GROUP_COLUMN,
|
||||
PROTOCOL_COLUMN,
|
||||
SUMMARY_COLUMN,
|
||||
COUNT_COLUMN,
|
||||
N_COLUMNS
|
||||
};
|
||||
|
||||
static void
|
||||
proto_data_func (GtkTreeViewColumn *column _U_,
|
||||
GtkCellRenderer *renderer,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer user_data)
|
||||
{
|
||||
gchar *str = NULL;
|
||||
gchar *grp = NULL; /* type pointer, don't free */
|
||||
|
||||
/* The col to get data from is in userdata */
|
||||
gint data_column = GPOINTER_TO_INT(user_data);
|
||||
|
||||
gtk_tree_model_get(model, iter, data_column, &str, -1);
|
||||
gtk_tree_model_get(model, iter, GROUP_COLUMN, &grp, -1);
|
||||
/* XXX should we check that str is non NULL and print a warning or do assert? */
|
||||
|
||||
g_object_set(renderer, "text", str, NULL);
|
||||
if (grp == packet) {
|
||||
/* it's a number right align */
|
||||
g_object_set(renderer, "xalign", 1.0, NULL);
|
||||
}
|
||||
else {
|
||||
g_object_set(renderer, "xalign", 0.0, NULL);
|
||||
}
|
||||
g_free(str);
|
||||
}
|
||||
|
||||
static gint
|
||||
proto_sort_func(GtkTreeModel *model,
|
||||
GtkTreeIter *a,
|
||||
GtkTreeIter *b,
|
||||
gpointer user_data)
|
||||
{
|
||||
gchar *str_a = NULL;
|
||||
gchar *str_b = NULL;
|
||||
gchar *grp = NULL; /* type pointer, don't free */
|
||||
gint ret = 0;
|
||||
|
||||
/* The col to get data from is in userdata */
|
||||
gint data_column = GPOINTER_TO_INT(user_data);
|
||||
|
||||
gtk_tree_model_get(model, a, data_column, &str_a, -1);
|
||||
gtk_tree_model_get(model, b, data_column, &str_b, -1);
|
||||
gtk_tree_model_get(model, a, GROUP_COLUMN, &grp, -1);
|
||||
|
||||
if (str_a == str_b) {
|
||||
ret = 0;
|
||||
}
|
||||
else if (str_a == NULL || str_b == NULL) {
|
||||
ret = (str_a == NULL) ? -1 : 1;
|
||||
}
|
||||
else {
|
||||
if (grp == packet) {
|
||||
gint int_a = 0;
|
||||
gint int_b = 0;
|
||||
if (!ws_strtoi32(str_a, NULL, &int_a) || !ws_strtoi32(str_b, NULL, &int_b) ||
|
||||
int_a == int_b)
|
||||
ret = 0;
|
||||
else if (int_a < int_b)
|
||||
ret = -1;
|
||||
else
|
||||
ret = 1;
|
||||
}
|
||||
else
|
||||
ret = g_ascii_strcasecmp(str_a,str_b);
|
||||
}
|
||||
g_free(str_a);
|
||||
g_free(str_b);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gint find_summary_data(error_equiv_table *err, const expert_info_t *expert_data)
|
||||
{
|
||||
guint i;
|
||||
error_procedure_t *procedure;
|
||||
|
||||
/* First time thru values will be 0 */
|
||||
if (err->num_procs==0) {
|
||||
return -1;
|
||||
}
|
||||
for (i=0;i<err->num_procs;i++) {
|
||||
procedure = &g_array_index(err->procs_array, error_procedure_t, i);
|
||||
if (strcmp(procedure->entries[0], expert_data->protocol) == 0 &&
|
||||
strcmp(procedure->entries[1], expert_data->summary) == 0) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void
|
||||
error_select_filter_cb(GtkWidget *widget _U_, gpointer callback_data, guint callback_action)
|
||||
{
|
||||
int action, type, selection;
|
||||
error_equiv_table *err = (error_equiv_table *)callback_data;
|
||||
char str[512];
|
||||
const char *current_filter;
|
||||
error_procedure_t *procedure;
|
||||
|
||||
GtkTreeIter iter;
|
||||
GtkTreeModel *model;
|
||||
expert_info_t expert_data;
|
||||
gchar *grp;
|
||||
|
||||
action=FILTER_ACTION(callback_action);
|
||||
type=FILTER_ACTYPE(callback_action);
|
||||
|
||||
|
||||
if(!gtk_tree_selection_get_selected(err->select, &model, &iter)){
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "No selection made or the table is empty");
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_tree_model_get (model, &iter,
|
||||
GROUP_COLUMN, &grp,
|
||||
PROTOCOL_COLUMN, &expert_data.protocol,
|
||||
SUMMARY_COLUMN, &expert_data.summary,
|
||||
-1);
|
||||
|
||||
if (strcmp(grp, packet)==0) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "You cannot filter or search for packet number. Click on a valid item header.");
|
||||
g_free(expert_data.summary);
|
||||
return;
|
||||
}
|
||||
|
||||
/* XXX: find_summary_data doesn't (currently) reference expert_data.group. */
|
||||
/* If "group" is required, then the message from GROUP_COLUMN will need */
|
||||
/* to be translated to the group number (or the actual group number */
|
||||
/* will also need to be stored in the TreeModel). */
|
||||
selection = find_summary_data(err, &expert_data);
|
||||
/* g_free(expert_data.protocol); - const */
|
||||
g_free(expert_data.summary);
|
||||
|
||||
if(selection>=(int)err->num_procs){
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "No items are selected");
|
||||
return;
|
||||
}
|
||||
current_filter=gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
|
||||
|
||||
/* Some expert data doesn't pass an expert item. Without this we cannot create a filter */
|
||||
/* But allow for searching of internet for error string */
|
||||
procedure = &g_array_index(err->procs_array, error_procedure_t, selection);
|
||||
|
||||
if (action != ACTION_WEB_LOOKUP && action != ACTION_COPY) {
|
||||
char *msg;
|
||||
#if 0
|
||||
if (procedure->fvalue_value==NULL) {
|
||||
if (action != ACTION_FIND_FRAME && action != ACTION_FIND_NEXT && action != ACTION_FIND_PREVIOUS) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Wireshark cannot create a filter on this item - %s, try using find instead.",
|
||||
procedure->entries[1]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
msg = (char *)g_malloc(escape_string_len(procedure->entries[1]));
|
||||
escape_string(msg, procedure->entries[1]);
|
||||
switch(type){
|
||||
case ACTYPE_SELECTED:
|
||||
/* if no expert item was passed */
|
||||
if (procedure->fvalue_value==NULL) {
|
||||
g_snprintf(str, sizeof(str), "_ws.expert.message==%s", msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* expert item exists. Use it. */
|
||||
g_strlcpy(str, procedure->fvalue_value, sizeof(str));
|
||||
}
|
||||
break;
|
||||
case ACTYPE_NOT_SELECTED:
|
||||
/* if no expert item was passed */
|
||||
if (procedure->fvalue_value==NULL) {
|
||||
g_snprintf(str, sizeof(str), "!(_ws.expert.message==%s)", msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* expert item exists. Use it. */
|
||||
g_snprintf(str, sizeof(str), "!(%s)", procedure->fvalue_value);
|
||||
}
|
||||
break;
|
||||
/* the remaining cases will only exist if the expert item exists so no need to check */
|
||||
case ACTYPE_AND_SELECTED:
|
||||
if ((!current_filter) || (0 == strlen(current_filter)))
|
||||
g_snprintf(str, sizeof(str), "_ws.expert.message==%s", msg);
|
||||
else
|
||||
g_snprintf(str, sizeof(str), "(%s) && (_ws.expert.message==%s)", current_filter, msg);
|
||||
break;
|
||||
case ACTYPE_OR_SELECTED:
|
||||
if ((!current_filter) || (0 == strlen(current_filter)))
|
||||
g_snprintf(str, sizeof(str), "_ws.expert.message==%s", msg);
|
||||
else
|
||||
g_snprintf(str, sizeof(str), "(%s) || (_ws.expert.message==%s)", current_filter, msg);
|
||||
break;
|
||||
case ACTYPE_AND_NOT_SELECTED:
|
||||
if ((!current_filter) || (0 == strlen(current_filter)))
|
||||
g_snprintf(str, sizeof(str), "!(_ws.expert.message==%s)", msg);
|
||||
else
|
||||
g_snprintf(str, sizeof(str), "(%s) && !(_ws.expert.message==%s)", current_filter, msg);
|
||||
break;
|
||||
case ACTYPE_OR_NOT_SELECTED:
|
||||
if ((!current_filter) || (0 == strlen(current_filter)))
|
||||
g_snprintf(str, sizeof(str), "!(_ws.expert.message==%s)", msg);
|
||||
else
|
||||
g_snprintf(str, sizeof(str), "(%s) || !(_ws.expert.message==%s)", current_filter, msg);
|
||||
break;
|
||||
default:
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Can't find menu type - %u", type);
|
||||
}
|
||||
g_free(msg);
|
||||
}
|
||||
|
||||
switch(action){
|
||||
case ACTION_MATCH:
|
||||
gtk_entry_set_text(GTK_ENTRY(main_display_filter_widget), str);
|
||||
main_filter_packets(&cfile, str, FALSE);
|
||||
gdk_window_raise(gtk_widget_get_window(top_level));
|
||||
break;
|
||||
case ACTION_PREPARE:
|
||||
gtk_entry_set_text(GTK_ENTRY(main_display_filter_widget), str);
|
||||
break;
|
||||
case ACTION_FIND_FRAME:
|
||||
/* When trying to perform a find without expert item, we must pass
|
||||
* the expert string to the find window. The user might need to modify
|
||||
* the string and click on the text search to locate the packet in question.
|
||||
* So regardless of the type we will just bring up the find window and allow
|
||||
* the user to modify the search criteria and options.
|
||||
*/
|
||||
find_frame_with_filter(str);
|
||||
break;
|
||||
case ACTION_FIND_NEXT:
|
||||
/* In the case of find next, if there was no expert item, then most likely the expert
|
||||
* string was modified to locate the text inside the message. So we can't just perform
|
||||
* a find with the expert string or we will not really be performing a find next.
|
||||
* In an effort to allow the user to modify the string and/or continue searching, we
|
||||
* will just present the user with the find window again with the default expert string.
|
||||
* A better aproach would be to attempt in capturing the last find string and utilize this
|
||||
* with a find next/previous. Also a better approach might be to just send a <Ctl-N> keystroke.
|
||||
*/
|
||||
/* Fall trough */
|
||||
case ACTION_FIND_PREVIOUS:
|
||||
/* In the case of find previous, if there was no expert item, then most likely the expert
|
||||
* string was modified to locate the text inside the message. So we can't just perform
|
||||
* a find with the expert string or we will not really be performing a find previous.
|
||||
* In an effort to allow the user to modify the string and/or continue searching, we
|
||||
* will just present the user with the find window again with the default expert string.
|
||||
* A better aproach would be to attempt in capturing the last find string and utilize this
|
||||
* with a find next/previous. Also a better approach might be to just send a <Ctl-B> keystroke.
|
||||
*/
|
||||
if (procedure->fvalue_value==NULL) {
|
||||
find_frame_with_filter(str);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We have an expert item so just continue search without find dialog. */
|
||||
cf_find_packet_dfilter_string(&cfile, str, SD_FORWARD);
|
||||
}
|
||||
break;
|
||||
case ACTION_COLORIZE:
|
||||
color_display_with_filter(str);
|
||||
break;
|
||||
case ACTION_WEB_LOOKUP:
|
||||
/* Lookup expert string on internet. Default search via www.google.com */
|
||||
g_snprintf(str, sizeof(str), "https://www.google.com/search?hl=en&q=%s+'%s'", procedure->entries[0], procedure->entries[1]);
|
||||
browser_open_url(str);
|
||||
break;
|
||||
case ACTION_COPY:
|
||||
{
|
||||
GString *copyString = g_string_sized_new(0);
|
||||
g_string_printf(copyString, "%s: %s",
|
||||
procedure->entries[0], procedure->entries[1]);
|
||||
copy_to_clipboard(copyString);
|
||||
g_string_free(copyString, TRUE);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Can't find menu action - %u", action);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
error_show_popup_menu_cb(void *widg _U_, GdkEvent *event, gpointer user_data)
|
||||
{
|
||||
error_equiv_table *err = (error_equiv_table *)user_data;
|
||||
GdkEventButton *bevent = (GdkEventButton *)event;
|
||||
|
||||
if(event->type==GDK_BUTTON_PRESS && bevent->button==3){
|
||||
gtk_menu_popup(GTK_MENU(err->menu), NULL, NULL, NULL, NULL,
|
||||
bevent->button, bevent->time);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
apply_as_selected_cb(GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
error_select_filter_cb( widget , user_data, CALLBACK_MATCH(ACTYPE_SELECTED, 0));
|
||||
}
|
||||
static void
|
||||
apply_as_not_selected_cb(GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
error_select_filter_cb( widget , user_data, CALLBACK_MATCH(ACTYPE_NOT_SELECTED, 0));
|
||||
}
|
||||
static void
|
||||
apply_as_and_selected_cb(GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
error_select_filter_cb( widget , user_data, CALLBACK_MATCH(ACTYPE_AND_SELECTED, 0));
|
||||
}
|
||||
static void
|
||||
apply_as_or_selected_cb(GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
error_select_filter_cb( widget , user_data, CALLBACK_MATCH(ACTYPE_OR_SELECTED, 0));
|
||||
}
|
||||
static void
|
||||
apply_as_and_not_selected_cb(GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
error_select_filter_cb( widget , user_data, CALLBACK_MATCH(ACTYPE_AND_NOT_SELECTED, 0));
|
||||
}
|
||||
static void
|
||||
apply_as_or_not_selected_cb(GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
error_select_filter_cb( widget , user_data, CALLBACK_MATCH(ACTYPE_OR_NOT_SELECTED, 0));
|
||||
}
|
||||
|
||||
static void
|
||||
prep_as_selected_cb(GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
error_select_filter_cb( widget , user_data, CALLBACK_PREPARE(ACTYPE_SELECTED, 0));
|
||||
}
|
||||
static void
|
||||
prep_as_not_selected_cb(GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
error_select_filter_cb( widget , user_data, CALLBACK_PREPARE(ACTYPE_NOT_SELECTED, 0));
|
||||
}
|
||||
static void
|
||||
prep_as_and_selected_cb(GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
error_select_filter_cb( widget , user_data, CALLBACK_PREPARE(ACTYPE_AND_SELECTED, 0));
|
||||
}
|
||||
static void
|
||||
prep_as_or_selected_cb(GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
error_select_filter_cb( widget , user_data, CALLBACK_PREPARE(ACTYPE_OR_SELECTED, 0));
|
||||
}
|
||||
static void
|
||||
prep_as_and_not_selected_cb(GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
error_select_filter_cb( widget , user_data, CALLBACK_PREPARE(ACTYPE_AND_NOT_SELECTED, 0));
|
||||
}
|
||||
static void
|
||||
prep_as_or_not_selected_cb(GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
error_select_filter_cb( widget , user_data, CALLBACK_PREPARE(ACTYPE_OR_NOT_SELECTED, 0));
|
||||
}
|
||||
|
||||
static void
|
||||
find_selected_cb(GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
error_select_filter_cb( widget , user_data, CALLBACK_FIND_FRAME(ACTYPE_SELECTED, 0));
|
||||
}
|
||||
static void
|
||||
find_not_selected_cb(GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
error_select_filter_cb( widget , user_data, CALLBACK_FIND_FRAME(ACTYPE_NOT_SELECTED, 0));
|
||||
}
|
||||
static void
|
||||
find_prev_selected_cb(GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
error_select_filter_cb( widget , user_data, CALLBACK_FIND_PREVIOUS(ACTYPE_SELECTED, 0));
|
||||
}
|
||||
static void
|
||||
find_prev_not_selected_cb(GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
error_select_filter_cb( widget , user_data, CALLBACK_FIND_PREVIOUS(ACTYPE_NOT_SELECTED, 0));
|
||||
}
|
||||
static void
|
||||
find_next_selected_cb(GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
error_select_filter_cb( widget , user_data, CALLBACK_FIND_NEXT(ACTYPE_SELECTED, 0));
|
||||
}
|
||||
static void
|
||||
find_next_not_selected_cb(GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
error_select_filter_cb( widget , user_data, CALLBACK_FIND_NEXT(ACTYPE_NOT_SELECTED, 0));
|
||||
}
|
||||
static void
|
||||
color_selected_cb(GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
error_select_filter_cb( widget , user_data, CALLBACK_COLORIZE(ACTYPE_SELECTED, 0));
|
||||
}
|
||||
static void
|
||||
color_not_selected_cb(GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
error_select_filter_cb( widget , user_data, CALLBACK_COLORIZE(ACTYPE_SELECTED, 0));
|
||||
}
|
||||
static void
|
||||
internet_search_cb(GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
error_select_filter_cb( widget , user_data, CALLBACK_WEB_LOOKUP);
|
||||
}
|
||||
static void
|
||||
copy_cb(GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
error_select_filter_cb( widget , user_data, CALLBACK_COPY);
|
||||
}
|
||||
|
||||
static const char *ui_desc_expert_filter_popup =
|
||||
"<ui>\n"
|
||||
" <popup name='ExpertFilterPopup'>\n"
|
||||
" <menu action='/Apply as Filter'>\n"
|
||||
" <menuitem action='/Apply as Filter/Selected'/>\n"
|
||||
" <menuitem action='/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS " not Selected'/>\n"
|
||||
" <menuitem action='/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS " and Selected'/>\n"
|
||||
" <menuitem action='/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS " or Selected'/>\n"
|
||||
" <menuitem action='/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS " and not Selected'/>\n"
|
||||
" <menuitem action='/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS " or not Selected'/>\n"
|
||||
" </menu>\n"
|
||||
" <menu action='/Prepare a Filter'>\n"
|
||||
" <menuitem action='/Prepare a Filter/Selected'/>\n"
|
||||
" <menuitem action='/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS " not Selected'/>\n"
|
||||
" <menuitem action='/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS " and Selected'/>\n"
|
||||
" <menuitem action='/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS " or Selected'/>\n"
|
||||
" <menuitem action='/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS " and not Selected'/>\n"
|
||||
" <menuitem action='/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS " or not Selected'/>\n"
|
||||
" </menu>\n"
|
||||
" <menu action='/Find Frame'>\n"
|
||||
" <menu action='/Find Frame/Find Frame'>\n"
|
||||
" <menuitem action='/Find Frame/Selected'/>\n"
|
||||
" <menuitem action='/Find Frame/Not Selected'/>\n"
|
||||
" </menu>\n"
|
||||
" <menu action='/Find Frame/Find Next'>\n"
|
||||
" <menuitem action='/Find Next/Selected'/>\n"
|
||||
" <menuitem action='/Find Next/Not Selected'/>\n"
|
||||
" </menu>\n"
|
||||
" <menu action='/Find Frame/Find Previous'>\n"
|
||||
" <menuitem action='/Find Previous/Selected'/>\n"
|
||||
" <menuitem action='/Find Previous/Not Selected'/>\n"
|
||||
" </menu>\n"
|
||||
" </menu>\n"
|
||||
" <menu action='/Colorize Procedure'>\n"
|
||||
" <menuitem action='/Colorize Procedure/Selected'/>\n"
|
||||
" <menuitem action='/Colorize Procedure/Not Selected'/>\n"
|
||||
" </menu>\n"
|
||||
" <menu action='/Internet Search'>\n"
|
||||
" <menuitem action='/For Info Text'/>\n"
|
||||
" </menu>\n"
|
||||
" <menu action='/Copy'>\n"
|
||||
" <menuitem action='/Copy/Protocol Plus Summary'/>\n"
|
||||
" </menu>\n"
|
||||
" </popup>\n"
|
||||
"</ui>\n";
|
||||
|
||||
|
||||
/*
|
||||
* GtkActionEntry
|
||||
* typedef struct {
|
||||
* const gchar *name;
|
||||
* const gchar *stock_id;
|
||||
* const gchar *label;
|
||||
* const gchar *accelerator;
|
||||
* const gchar *tooltip;
|
||||
* GCallback callback;
|
||||
* } GtkActionEntry;
|
||||
* const gchar *name; The name of the action.
|
||||
* const gchar *stock_id; The stock id for the action, or the name of an icon from the icon theme.
|
||||
* const gchar *label; The label for the action. This field should typically be marked for translation,
|
||||
* see gtk_action_group_set_translation_domain().
|
||||
* If label is NULL, the label of the stock item with id stock_id is used.
|
||||
* const gchar *accelerator; The accelerator for the action, in the format understood by gtk_accelerator_parse().
|
||||
* const gchar *tooltip; The tooltip for the action. This field should typically be marked for translation,
|
||||
* see gtk_action_group_set_translation_domain().
|
||||
* GCallback callback; The function to call when the action is activated.
|
||||
*
|
||||
*/
|
||||
static const GtkActionEntry expert_popup_entries[] = {
|
||||
{ "/Apply as Filter", NULL, "Apply as Filter", NULL, NULL, NULL },
|
||||
{ "/Prepare a Filter", NULL, "Prepare a Filter", NULL, NULL, NULL },
|
||||
{ "/Find Frame", NULL, "Find Frame", NULL, NULL, NULL },
|
||||
{ "/Find Frame/Find Frame", NULL, "Find Frame", NULL, NULL, NULL },
|
||||
{ "/Find Frame/Find Next", NULL, "Find Next" , NULL, NULL, NULL },
|
||||
{ "/Find Frame/Find Previous", NULL, "Find Previous", NULL, NULL, NULL },
|
||||
{ "/Colorize Procedure", NULL, "Colorize Procedure", NULL, NULL, NULL },
|
||||
{ "/Apply as Filter/Selected", NULL, "Selected", NULL, "Selected", G_CALLBACK(apply_as_selected_cb) },
|
||||
{ "/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS " not Selected", NULL, UTF8_HORIZONTAL_ELLIPSIS " not Selected", NULL, UTF8_HORIZONTAL_ELLIPSIS " not Selected", G_CALLBACK(apply_as_not_selected_cb) },
|
||||
{ "/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS " and Selected", NULL, UTF8_HORIZONTAL_ELLIPSIS " and Selected", NULL, UTF8_HORIZONTAL_ELLIPSIS " and Selected", G_CALLBACK(apply_as_and_selected_cb) },
|
||||
{ "/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS " or Selected", NULL, UTF8_HORIZONTAL_ELLIPSIS " or Selected", NULL, UTF8_HORIZONTAL_ELLIPSIS " or Selected", G_CALLBACK(apply_as_or_selected_cb) },
|
||||
{ "/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS " and not Selected", NULL, UTF8_HORIZONTAL_ELLIPSIS " and not Selected", NULL, UTF8_HORIZONTAL_ELLIPSIS " and not Selected", G_CALLBACK(apply_as_and_not_selected_cb) },
|
||||
{ "/Apply as Filter/" UTF8_HORIZONTAL_ELLIPSIS " or not Selected", NULL, UTF8_HORIZONTAL_ELLIPSIS " or not Selected", NULL, UTF8_HORIZONTAL_ELLIPSIS " or not Selected", G_CALLBACK(apply_as_or_not_selected_cb) },
|
||||
{ "/Prepare a Filter/Selected", NULL, "Selected", NULL, "selcted", G_CALLBACK(prep_as_selected_cb) },
|
||||
{ "/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS " not Selected", NULL, UTF8_HORIZONTAL_ELLIPSIS " not Selected", NULL, UTF8_HORIZONTAL_ELLIPSIS " not Selected", G_CALLBACK(prep_as_not_selected_cb) },
|
||||
{ "/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS " and Selected", NULL, UTF8_HORIZONTAL_ELLIPSIS " and Selected", NULL, UTF8_HORIZONTAL_ELLIPSIS " and Selected", G_CALLBACK(prep_as_and_selected_cb) },
|
||||
{ "/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS " or Selected", NULL, UTF8_HORIZONTAL_ELLIPSIS " or Selected", NULL, UTF8_HORIZONTAL_ELLIPSIS " or Selected", G_CALLBACK(prep_as_or_selected_cb) },
|
||||
{ "/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS " and not Selected", NULL, UTF8_HORIZONTAL_ELLIPSIS " and not Selected", NULL, UTF8_HORIZONTAL_ELLIPSIS " and not Selected", G_CALLBACK(prep_as_and_not_selected_cb) },
|
||||
{ "/Prepare a Filter/" UTF8_HORIZONTAL_ELLIPSIS " or not Selected", NULL, UTF8_HORIZONTAL_ELLIPSIS " or not Selected", NULL, UTF8_HORIZONTAL_ELLIPSIS " or not Selected", G_CALLBACK(prep_as_or_not_selected_cb) },
|
||||
{ "/Find Frame/Selected", NULL, "Selected", NULL, "Selected", G_CALLBACK(find_selected_cb) },
|
||||
{ "/Find Frame/Not Selected", NULL, "Not Selected", NULL, "Not Selected", G_CALLBACK(find_not_selected_cb) },
|
||||
{ "/Find Previous/Selected", NULL, "Selected", NULL, "Selected", G_CALLBACK(find_prev_selected_cb) },
|
||||
{ "/Find Previous/Not Selected", NULL, "Not Selected", NULL, "Not Selected", G_CALLBACK(find_prev_not_selected_cb) },
|
||||
{ "/Find Next/Selected", NULL, "Selected", NULL, "Selected", G_CALLBACK(find_next_selected_cb) },
|
||||
{ "/Find Next/Not Selected", NULL, "Not Selected", NULL, "Not Selected", G_CALLBACK(find_next_not_selected_cb) },
|
||||
{ "/Colorize Procedure/Selected", NULL, "Selected", NULL, "Selected", G_CALLBACK(color_selected_cb) },
|
||||
{ "/Colorize Procedure/Not Selected", NULL, "Not Selected", NULL, "Not Selected", G_CALLBACK(color_not_selected_cb) },
|
||||
{ "/Internet Search", WIRESHARK_STOCK_INTERNET, "Internet Search", NULL, "Internet Search", NULL },
|
||||
{ "/For Info Text", NULL, "For Info Text", NULL, "For Info Text", G_CALLBACK(internet_search_cb) },
|
||||
{ "/Copy", NULL, "Copy", NULL, "Copy", NULL },
|
||||
{ "/Copy/Protocol Plus Summary", NULL, "Protocol Plus Summary", NULL, "Protocol Plus Summary", G_CALLBACK(copy_cb) },
|
||||
};
|
||||
|
||||
int gselection_count = 0;
|
||||
|
||||
static void
|
||||
expert_goto_pkt_cb (GtkTreeSelection *selection, gpointer data _U_)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GtkTreeModel *model;
|
||||
gchar *pkt;
|
||||
gint32 pkt_num = 0;
|
||||
gchar *grp;
|
||||
|
||||
if (gtk_tree_selection_get_selected (selection, &model, &iter))
|
||||
{
|
||||
gselection_count++;
|
||||
|
||||
gtk_tree_model_get (model, &iter,
|
||||
PROTOCOL_COLUMN, &pkt,
|
||||
GROUP_COLUMN, &grp,
|
||||
-1);
|
||||
|
||||
if (strcmp(grp, packet)==0) {
|
||||
if (ws_strtoi32(pkt, NULL, &pkt_num))
|
||||
cf_goto_frame(&cfile, pkt_num);
|
||||
}
|
||||
g_free (pkt);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
error_create_popup_menu(error_equiv_table *err)
|
||||
{
|
||||
GtkUIManager *ui_manager;
|
||||
GtkActionGroup *action_group;
|
||||
GError *error = NULL;
|
||||
|
||||
err->select = gtk_tree_view_get_selection (GTK_TREE_VIEW (err->tree_view));
|
||||
gtk_tree_selection_set_mode (err->select, GTK_SELECTION_SINGLE);
|
||||
g_signal_connect (G_OBJECT (err->select), "changed", G_CALLBACK(expert_goto_pkt_cb), NULL);
|
||||
|
||||
action_group = gtk_action_group_new ("ExpertFilterPopupActionGroup");
|
||||
gtk_action_group_add_actions (action_group, /* the action group */
|
||||
(GtkActionEntry *)expert_popup_entries, /* an array of action descriptions */
|
||||
G_N_ELEMENTS(expert_popup_entries), /* the number of entries */
|
||||
err); /* data to pass to the action callbacks */
|
||||
|
||||
ui_manager = gtk_ui_manager_new ();
|
||||
gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
|
||||
gtk_ui_manager_add_ui_from_string (ui_manager,ui_desc_expert_filter_popup, -1, &error);
|
||||
if (error != NULL)
|
||||
{
|
||||
fprintf (stderr, "Warning: building expert filter popup failed: %s\n",
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
error = NULL;
|
||||
}
|
||||
err->menu = gtk_ui_manager_get_widget(ui_manager, "/ExpertFilterPopup");
|
||||
g_signal_connect(err->tree_view, "button_press_event", G_CALLBACK(error_show_popup_menu_cb), err);
|
||||
}
|
||||
|
||||
void
|
||||
init_error_table(error_equiv_table *err, guint num_procs, GtkWidget *vbox)
|
||||
{
|
||||
GtkTreeStore *store;
|
||||
GtkWidget *tree;
|
||||
GtkTreeViewColumn *column;
|
||||
GtkCellRenderer *renderer;
|
||||
GtkTreeSortable *sortable;
|
||||
|
||||
/* Create the store */
|
||||
store = gtk_tree_store_new (4, /* Total number of columns */
|
||||
G_TYPE_POINTER, /* Group */
|
||||
G_TYPE_STRING, /* Protocol */
|
||||
G_TYPE_STRING, /* Summary */
|
||||
G_TYPE_INT); /* Count */
|
||||
|
||||
/* Create a view */
|
||||
tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
|
||||
err->tree_view = GTK_TREE_VIEW(tree);
|
||||
sortable = GTK_TREE_SORTABLE(store);
|
||||
|
||||
/* Speed up the list display */
|
||||
gtk_tree_view_set_fixed_height_mode(err->tree_view, TRUE);
|
||||
|
||||
gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW (tree), FALSE);
|
||||
|
||||
/* The view now holds a reference. We can get rid of our own reference */
|
||||
g_object_unref (G_OBJECT (store));
|
||||
|
||||
/* Create a cell renderer */
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
|
||||
/* Create the first column, associating the "text" attribute of the
|
||||
* cell_renderer to the first column of the model
|
||||
*/
|
||||
column = gtk_tree_view_column_new_with_attributes ("Group", renderer, NULL);
|
||||
gtk_tree_view_column_set_sort_column_id(column, GROUP_COLUMN);
|
||||
gtk_tree_view_column_set_resizable(column, TRUE);
|
||||
gtk_tree_view_column_set_cell_data_func(column, renderer, str_ptr_data_func,
|
||||
GINT_TO_POINTER(GROUP_COLUMN), NULL);
|
||||
|
||||
gtk_tree_sortable_set_sort_func(sortable, GROUP_COLUMN, str_ptr_sort_func,
|
||||
GINT_TO_POINTER(GROUP_COLUMN), NULL);
|
||||
|
||||
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
gtk_tree_view_column_set_min_width(column, 80);
|
||||
gtk_tree_view_column_set_fixed_width(column, 80);
|
||||
/* Add the column to the view. */
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (err->tree_view), column);
|
||||
|
||||
/* Second column.. Protocol. */
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
column = gtk_tree_view_column_new_with_attributes ("Protocol", renderer, "text", PROTOCOL_COLUMN, NULL);
|
||||
gtk_tree_view_column_set_sort_column_id(column, PROTOCOL_COLUMN);
|
||||
gtk_tree_view_column_set_resizable(column, TRUE);
|
||||
gtk_tree_view_column_set_cell_data_func(column, renderer, proto_data_func,
|
||||
GINT_TO_POINTER(PROTOCOL_COLUMN), NULL);
|
||||
|
||||
gtk_tree_sortable_set_sort_func(sortable, PROTOCOL_COLUMN, proto_sort_func,
|
||||
GINT_TO_POINTER(PROTOCOL_COLUMN), NULL);
|
||||
|
||||
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
gtk_tree_view_column_set_min_width(column, 80);
|
||||
gtk_tree_view_column_set_fixed_width(column, 100);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (err->tree_view), column);
|
||||
|
||||
/* Third column.. Summary. */
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
column = gtk_tree_view_column_new_with_attributes ("Summary", renderer, "text", SUMMARY_COLUMN, NULL);
|
||||
gtk_tree_view_column_set_sort_column_id(column, SUMMARY_COLUMN);
|
||||
gtk_tree_view_column_set_resizable(column, TRUE);
|
||||
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
gtk_tree_view_column_set_min_width(column, 300);
|
||||
gtk_tree_view_column_set_fixed_width(column,
|
||||
700 /* window size */ -
|
||||
(80 /* group */ + 100 /* protocol */ + 80 /* count */ +
|
||||
24 /* border */ + 22 /* vbar */));
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (err->tree_view), column);
|
||||
|
||||
/* Last column.. Count. */
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
/* right align */
|
||||
g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL);
|
||||
column = gtk_tree_view_column_new_with_attributes ("Count", renderer, "text", COUNT_COLUMN, NULL);
|
||||
gtk_tree_view_column_set_sort_column_id(column, COUNT_COLUMN);
|
||||
gtk_tree_view_column_set_resizable(column, TRUE);
|
||||
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
gtk_tree_view_column_set_min_width(column, 80);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (err->tree_view), column);
|
||||
|
||||
err->scrolled_window=scrolled_window_new(NULL, NULL);
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(err->scrolled_window), GTK_WIDGET (err->tree_view));
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(vbox), err->scrolled_window, TRUE, TRUE, 0);
|
||||
|
||||
gtk_tree_view_set_search_column (err->tree_view, SUMMARY_COLUMN); /* Allow searching the summary */
|
||||
gtk_tree_view_set_reorderable (err->tree_view, TRUE); /* Allow user to reorder data with drag n drop */
|
||||
|
||||
/* Now enable the sorting of each column */
|
||||
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(err->tree_view), TRUE);
|
||||
gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(err->tree_view), TRUE);
|
||||
|
||||
gtk_widget_show(err->scrolled_window);
|
||||
|
||||
err->num_procs=num_procs;
|
||||
|
||||
err->text = g_string_chunk_new(100);
|
||||
err->procs_array = g_array_sized_new(FALSE, FALSE, sizeof(error_procedure_t), num_procs);
|
||||
|
||||
/* create popup menu for this table */
|
||||
error_create_popup_menu(err);
|
||||
}
|
||||
|
||||
void
|
||||
init_error_table_row(error_equiv_table *err, const expert_info_t *expert_data)
|
||||
{
|
||||
guint old_num_procs=err->num_procs;
|
||||
gint row;
|
||||
error_procedure_t *procedure;
|
||||
GtkTreeStore *store;
|
||||
GtkTreeIter new_iter;
|
||||
gchar num[10];
|
||||
|
||||
/* we have discovered a new procedure. Extend the table accordingly */
|
||||
row = find_summary_data(err, expert_data);
|
||||
if(row==-1){
|
||||
error_procedure_t new_procedure;
|
||||
/* First time we have seen this event so initialize memory table */
|
||||
row = old_num_procs; /* Number of expert events since this is a new event */
|
||||
|
||||
new_procedure.count=0; /* count of events for this item */
|
||||
new_procedure.fvalue_value = NULL; /* Filter string value */
|
||||
|
||||
g_array_append_val(err->procs_array, new_procedure);
|
||||
procedure = &g_array_index(err->procs_array, error_procedure_t, row);
|
||||
|
||||
/* Create the item in our memory table */
|
||||
procedure->entries[0]=(char *)g_string_chunk_insert_const(err->text, expert_data->protocol); /* Protocol */
|
||||
procedure->entries[1]=(char *)g_string_chunk_insert_const(err->text, expert_data->summary); /* Summary */
|
||||
|
||||
/* Create a new item in our tree view */
|
||||
store = GTK_TREE_STORE(gtk_tree_view_get_model(err->tree_view)); /* Get store */
|
||||
gtk_tree_store_append (store, &procedure->iter, NULL); /* Acquire an iterator */
|
||||
|
||||
/* try_val_to_str return a static constant or null */
|
||||
gtk_tree_store_set (store, &procedure->iter,
|
||||
GROUP_COLUMN, try_val_to_str(expert_data->group, expert_group_vals),
|
||||
PROTOCOL_COLUMN, procedure->entries[0],
|
||||
SUMMARY_COLUMN, procedure->entries[1], -1);
|
||||
|
||||
/* If an expert item was passed then build the filter string */
|
||||
if (expert_data->pitem) {
|
||||
char *filter;
|
||||
|
||||
g_assert(PITEM_FINFO(expert_data->pitem));
|
||||
filter = proto_construct_match_selected_string(PITEM_FINFO(expert_data->pitem), NULL);
|
||||
if (filter != NULL)
|
||||
{
|
||||
procedure->fvalue_value = g_string_chunk_insert_const(err->text, filter);
|
||||
wmem_free(NULL, filter);
|
||||
}
|
||||
}
|
||||
/* Store the updated count of events */
|
||||
err->num_procs = ++old_num_procs;
|
||||
}
|
||||
|
||||
/* Update our memory table with event data */
|
||||
procedure = &g_array_index(err->procs_array, error_procedure_t, row);
|
||||
procedure->count++; /* increment the count of events for this item */
|
||||
|
||||
/* Update the tree with new count for this event */
|
||||
store = GTK_TREE_STORE(gtk_tree_view_get_model(err->tree_view));
|
||||
gtk_tree_store_set(store, &procedure->iter,
|
||||
COUNT_COLUMN, procedure->count,
|
||||
-1);
|
||||
|
||||
g_snprintf(num, sizeof(num), "%d", expert_data->packet_num);
|
||||
#if 0
|
||||
This does not have a big performance improvment :(
|
||||
gtk_tree_store_insert_with_values (store,
|
||||
&new_iter, /* *iter */
|
||||
&procedure->iter, /* *parent*/
|
||||
G_MAXINT, /* position */
|
||||
|
||||
#else
|
||||
|
||||
/* FIXME gtk is plagued with slow algorithms
|
||||
gtk_tree_store_append call new_path and its nice recursive linear search....
|
||||
*/
|
||||
if (procedure->count > 1000) {
|
||||
/* If there's more than 1000 sub rows give up and prepend new rows, at least
|
||||
it will end in a reasonable time. Anyway with so many rows it's not
|
||||
very useful and if sorted the right order is restored.
|
||||
*/
|
||||
gtk_tree_store_prepend(store, &new_iter, &procedure->iter);
|
||||
}
|
||||
else {
|
||||
gtk_tree_store_append(store, &new_iter, &procedure->iter);
|
||||
}
|
||||
gtk_tree_store_set(store, &new_iter,
|
||||
#endif
|
||||
GROUP_COLUMN, packet,
|
||||
PROTOCOL_COLUMN, num,
|
||||
COUNT_COLUMN, 1,
|
||||
-1);
|
||||
}
|
||||
|
||||
void
|
||||
reset_error_table_data(error_equiv_table *err)
|
||||
{
|
||||
GtkTreeStore *store;
|
||||
|
||||
store = GTK_TREE_STORE(gtk_tree_view_get_model(err->tree_view));
|
||||
gtk_tree_store_clear(store);
|
||||
err->num_procs = 0;
|
||||
/* g_string_chunk_clear() is introduced in glib 2.14 */
|
||||
g_string_chunk_free(err->text);
|
||||
err->text = g_string_chunk_new(100);
|
||||
|
||||
g_array_set_size(err->procs_array, 0);
|
||||
}
|
||||
|
||||
void
|
||||
free_error_table_data(error_equiv_table *err)
|
||||
{
|
||||
err->num_procs=0;
|
||||
g_string_chunk_free(err->text);
|
||||
g_array_free(err->procs_array, TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
||||
* :indentSize=4:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -1,91 +0,0 @@
|
|||
/* expert_comp_table.h
|
||||
* expert_comp_table 2005 Greg Morris
|
||||
* Portions copied from service_response_time_table.h by Ronnie Sahlberg
|
||||
* Helper routines common to all composite expert statistics
|
||||
* tap.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __EXPERT_COMP_TABLE_H__
|
||||
#define __EXPERT_COMP_TABLE_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <epan/expert.h>
|
||||
|
||||
typedef struct expert_tapdata_s expert_tapdata_t;
|
||||
|
||||
/** @file
|
||||
* Helper routines common to all error statistics tap.
|
||||
*/
|
||||
|
||||
/** Procedure data */
|
||||
typedef struct _error_procedure_t {
|
||||
char *entries[2]; /**< column entries */
|
||||
char *fvalue_value; /**< filter value */
|
||||
GtkTreeIter iter;
|
||||
guint count; /**< number of expert items encountered
|
||||
for this entry */
|
||||
} error_procedure_t;
|
||||
|
||||
/** Statistics table */
|
||||
typedef struct _error_equiv_table {
|
||||
GtkWidget *scrolled_window; /**< window widget */
|
||||
GtkTreeSelection *select; /**< item selected */
|
||||
GtkTreeView *tree_view; /**< Tree view */
|
||||
GtkWidget *menu; /**< context menu */
|
||||
guint num_procs; /**< number of elements on procedures array */
|
||||
GArray *procs_array; /**< the procedures array error_procedure_t *procedures */
|
||||
GStringChunk* text;
|
||||
}error_equiv_table;
|
||||
|
||||
/** Init an err table data structure.
|
||||
*
|
||||
* @param err the err table to init
|
||||
* @param num_procs number of procedures
|
||||
* @param vbox the corresponding GtkVBox to fill in
|
||||
*/
|
||||
void init_error_table(error_equiv_table *err, guint num_procs, GtkWidget *vbox);
|
||||
|
||||
/** Init an err table row data structure.
|
||||
*
|
||||
* @param err the err table
|
||||
* @param expert_data data
|
||||
*/
|
||||
void init_error_table_row(error_equiv_table *err, const expert_info_t *expert_data);
|
||||
|
||||
/** Draw the err table data.
|
||||
*
|
||||
* @param err the err table
|
||||
*/
|
||||
void draw_error_table_data(error_equiv_table *err);
|
||||
|
||||
/** Reset the err table data.
|
||||
*
|
||||
* @param err the err table
|
||||
*/
|
||||
void reset_error_table_data(error_equiv_table *err);
|
||||
|
||||
/** Free the err table data.
|
||||
*
|
||||
* @param err the err table
|
||||
*/
|
||||
void free_error_table_data(error_equiv_table *err);
|
||||
|
||||
#endif /* __EXPERT_COMP_TABLE_H__ */
|
|
@ -1,492 +0,0 @@
|
|||
/* export_object.c
|
||||
* Common routines for tracking & saving objects found in streams of data
|
||||
* Copyright 2007, Stephen Fisher (see AUTHORS file)
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <epan/packet_info.h>
|
||||
#include <epan/prefs.h>
|
||||
#include <epan/tap.h>
|
||||
|
||||
#include <wsutil/str_util.h>
|
||||
|
||||
#include <ui/export_object_ui.h>
|
||||
#include <ui/simple_dialog.h>
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
#include "dlg_utils.h"
|
||||
#include "file_dlg.h"
|
||||
#include "gui_utils.h"
|
||||
#include "help_dlg.h"
|
||||
#include "main.h"
|
||||
#include "stock_icons.h"
|
||||
#include "export_object_dlg.h"
|
||||
|
||||
enum {
|
||||
EO_PKT_NUM_COLUMN,
|
||||
EO_HOSTNAME_COLUMN,
|
||||
EO_CONTENT_TYPE_COLUMN,
|
||||
EO_BYTES_COLUMN,
|
||||
EO_FILENAME_COLUMN,
|
||||
EO_NUM_COLUMNS /* must be last */
|
||||
};
|
||||
|
||||
typedef struct _export_object_list_gui_t {
|
||||
GSList *entries;
|
||||
GtkWidget *tree, *dlg;
|
||||
GtkTreeView *tree_view;
|
||||
GtkTreeIter *iter;
|
||||
GtkTreeStore *store;
|
||||
gint row_selected;
|
||||
} export_object_list_gui_t;
|
||||
|
||||
static export_object_gui_reset_cb eo_protocoldata_reset = NULL;
|
||||
|
||||
static void
|
||||
eo_remember_this_row(GtkTreeModel *model _U_, GtkTreePath *path,
|
||||
GtkTreeIter *iter _U_, gpointer arg)
|
||||
{
|
||||
export_object_list_t *tap_object = (export_object_list_t *)arg;
|
||||
export_object_list_gui_t *object_list = (export_object_list_gui_t*)tap_object->gui_data;
|
||||
export_object_entry_t *entry;
|
||||
|
||||
gint *path_index;
|
||||
|
||||
if((path_index = gtk_tree_path_get_indices(path)) == NULL)
|
||||
/* Row not found in tree - shouldn't happen */
|
||||
return;
|
||||
|
||||
object_list->row_selected = path_index[0];
|
||||
|
||||
/* Select the corresponding packet in the packet list */
|
||||
entry = (export_object_entry_t *)g_slist_nth_data(object_list->entries,
|
||||
object_list->row_selected);
|
||||
cf_goto_frame(&cfile, entry->pkt_num);
|
||||
}
|
||||
|
||||
static void
|
||||
eo_remember_row_num(GtkTreeSelection *sel, gpointer data)
|
||||
{
|
||||
gtk_tree_selection_selected_foreach(sel, eo_remember_this_row, data);
|
||||
}
|
||||
|
||||
|
||||
/* Called when the Export Object window is closed in any way */
|
||||
static void
|
||||
eo_win_destroy_cb(GtkWindow *win _U_, gpointer data)
|
||||
{
|
||||
export_object_list_t *tap_object = (export_object_list_t *)data;
|
||||
export_object_list_gui_t *object_list = (export_object_list_gui_t*)tap_object->gui_data;
|
||||
export_object_entry_t *entry;
|
||||
GSList *slist = object_list->entries;
|
||||
|
||||
remove_tap_listener(tap_object);
|
||||
|
||||
/* Free the GSList attributes */
|
||||
while(slist) {
|
||||
entry = (export_object_entry_t *)slist->data;
|
||||
eo_free_entry(entry);
|
||||
|
||||
slist = slist->next;
|
||||
}
|
||||
|
||||
/* Free the GSList elements */
|
||||
g_slist_free(object_list->entries);
|
||||
g_free(object_list);
|
||||
|
||||
/* Free the private export_object_xxx data */
|
||||
if (eo_protocoldata_reset != NULL) eo_protocoldata_reset();
|
||||
}
|
||||
|
||||
static char *
|
||||
gtk_eo_save_object_as_file(export_object_list_gui_t *object_list, char *auxfilename)
|
||||
{
|
||||
GtkWidget *save_as_w;
|
||||
char *pathname;
|
||||
|
||||
save_as_w = file_selection_new("Wireshark: Save Object As ...",
|
||||
GTK_WINDOW(object_list->dlg),
|
||||
FILE_SELECTION_SAVE);
|
||||
|
||||
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(save_as_w),
|
||||
auxfilename);
|
||||
pathname = file_selection_run(save_as_w);
|
||||
if (pathname == NULL) {
|
||||
/* User cancelled or closed the dialog. */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* We've crosed the Rubicon; get rid of the dialog box. */
|
||||
window_destroy(save_as_w);
|
||||
|
||||
return pathname;
|
||||
}
|
||||
|
||||
static void
|
||||
eo_save_clicked_cb(GtkWidget *widget _U_, gpointer arg)
|
||||
{
|
||||
export_object_list_t *tap_object = (export_object_list_t *)arg;
|
||||
export_object_list_gui_t *object_list = (export_object_list_gui_t*)tap_object->gui_data;
|
||||
export_object_entry_t *entry;
|
||||
GString *safe_filename = NULL;
|
||||
char *pathname;
|
||||
|
||||
entry =(export_object_entry_t *) g_slist_nth_data(object_list->entries,
|
||||
object_list->row_selected);
|
||||
|
||||
if(!entry) {
|
||||
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, "No object was selected for saving. Please click on an object and click save again.");
|
||||
return;
|
||||
}
|
||||
|
||||
safe_filename = eo_massage_str(entry->filename, EXPORT_OBJECT_MAXFILELEN, 0);
|
||||
|
||||
/*
|
||||
* Loop until the user either selects a file or gives up.
|
||||
*/
|
||||
for (;;) {
|
||||
pathname = gtk_eo_save_object_as_file(object_list, safe_filename->str);
|
||||
if (pathname == NULL) {
|
||||
/* User gave up. */
|
||||
break;
|
||||
}
|
||||
if (eo_save_entry(pathname, entry, TRUE)) {
|
||||
/* We succeeded. */
|
||||
g_free(pathname);
|
||||
break;
|
||||
}
|
||||
/* Dump failed; let the user select another file
|
||||
or give up. */
|
||||
g_free(pathname);
|
||||
}
|
||||
|
||||
g_string_free(safe_filename, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
eo_save_all_clicked_cb(GtkWidget *widget _U_, gpointer arg)
|
||||
{
|
||||
gchar *save_as_fullpath = NULL;
|
||||
export_object_list_t *tap_object = (export_object_list_t *)arg;
|
||||
export_object_list_gui_t *object_list = (export_object_list_gui_t*)tap_object->gui_data;
|
||||
export_object_entry_t *entry;
|
||||
GtkWidget *save_in_w;
|
||||
GSList *slist = object_list->entries;
|
||||
gboolean all_saved = TRUE;
|
||||
gchar *save_in_path;
|
||||
GString *safe_filename;
|
||||
int count = 0;
|
||||
|
||||
save_in_w = file_selection_new("Wireshark: Save All Objects In ...",
|
||||
GTK_WINDOW(object_list->dlg),
|
||||
FILE_SELECTION_CREATE_FOLDER);
|
||||
|
||||
if (gtk_dialog_run(GTK_DIALOG(save_in_w)) == GTK_RESPONSE_ACCEPT) {
|
||||
while (slist) {
|
||||
entry = (export_object_entry_t *)slist->data;
|
||||
|
||||
save_in_path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(save_in_w));
|
||||
if ((strlen(save_in_path) < EXPORT_OBJECT_MAXFILELEN)) {
|
||||
do {
|
||||
g_free(save_as_fullpath);
|
||||
if (entry->filename) {
|
||||
safe_filename = eo_massage_str(entry->filename,
|
||||
EXPORT_OBJECT_MAXFILELEN - strlen(save_in_path), count);
|
||||
} else {
|
||||
char generic_name[EXPORT_OBJECT_MAXFILELEN+1];
|
||||
const char *ext;
|
||||
ext = eo_ct2ext(entry->content_type);
|
||||
g_snprintf(generic_name, sizeof(generic_name),
|
||||
"object%u%s%s", entry->pkt_num, ext ? "." : "",
|
||||
ext ? ext : "");
|
||||
safe_filename = eo_massage_str(generic_name,
|
||||
EXPORT_OBJECT_MAXFILELEN - strlen(save_in_path), count);
|
||||
}
|
||||
save_as_fullpath = g_build_filename(
|
||||
save_in_path, safe_filename->str, NULL);
|
||||
g_string_free(safe_filename, TRUE);
|
||||
} while (g_file_test(save_as_fullpath, G_FILE_TEST_EXISTS) && ++count < 1000);
|
||||
count = 0;
|
||||
if (!eo_save_entry(save_as_fullpath, entry, FALSE))
|
||||
all_saved = FALSE;
|
||||
g_free(save_as_fullpath);
|
||||
save_as_fullpath = NULL;
|
||||
}
|
||||
else
|
||||
all_saved = FALSE;
|
||||
|
||||
slist = slist->next;
|
||||
}
|
||||
}
|
||||
|
||||
if (!all_saved)
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Some files could not be saved.");
|
||||
|
||||
window_destroy(save_in_w);
|
||||
}
|
||||
|
||||
/* Runs at the beginning of tapping only */
|
||||
static void
|
||||
eo_reset(void *tapdata)
|
||||
{
|
||||
export_object_list_t *tap_object = (export_object_list_t *)tapdata;
|
||||
export_object_list_gui_t *object_list = (export_object_list_gui_t*)tap_object->gui_data;
|
||||
|
||||
object_list->entries = NULL;
|
||||
object_list->iter = NULL;
|
||||
object_list->row_selected = -1;
|
||||
|
||||
if (eo_protocoldata_reset != NULL) eo_protocoldata_reset();
|
||||
}
|
||||
|
||||
static void
|
||||
eo_draw(void *tapdata)
|
||||
{
|
||||
export_object_list_t *tap_object = (export_object_list_t *)tapdata;
|
||||
export_object_list_gui_t *object_list = (export_object_list_gui_t*)tap_object->gui_data;
|
||||
export_object_entry_t *eo_entry;
|
||||
gchar *size_str;
|
||||
|
||||
GSList *slist = object_list->entries;
|
||||
GtkTreeIter new_iter;
|
||||
|
||||
/* Free the tree first, since we may get called more than once for the same capture
|
||||
Not doing so caused duplicate entries and clicking them caused crashes.
|
||||
*/
|
||||
|
||||
gtk_tree_store_clear(object_list->store);
|
||||
|
||||
while(slist) {
|
||||
eo_entry = (export_object_entry_t *)slist->data;
|
||||
|
||||
gtk_tree_store_append(object_list->store, &new_iter,
|
||||
object_list->iter);
|
||||
|
||||
size_str = format_size(eo_entry->payload_len, (format_size_flags_e)(format_size_unit_bytes|format_size_prefix_si));
|
||||
gtk_tree_store_set(object_list->store, &new_iter,
|
||||
EO_PKT_NUM_COLUMN, eo_entry->pkt_num,
|
||||
EO_HOSTNAME_COLUMN, eo_entry->hostname,
|
||||
EO_CONTENT_TYPE_COLUMN, eo_entry->content_type,
|
||||
EO_BYTES_COLUMN, size_str,
|
||||
EO_FILENAME_COLUMN, eo_entry->filename,
|
||||
-1);
|
||||
g_free(size_str);
|
||||
|
||||
slist = slist->next;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
object_list_add_entry(void *gui_data, export_object_entry_t *entry)
|
||||
{
|
||||
export_object_list_gui_t *object_list = (export_object_list_gui_t*)gui_data;
|
||||
|
||||
object_list->entries = g_slist_append(object_list->entries, entry);
|
||||
}
|
||||
|
||||
static export_object_entry_t*
|
||||
object_list_get_entry(void *gui_data, int row) {
|
||||
export_object_list_gui_t *object_list = (export_object_list_gui_t*)gui_data;
|
||||
|
||||
return (export_object_entry_t *)g_slist_nth_data(object_list->entries, row);
|
||||
}
|
||||
|
||||
static void
|
||||
export_object_window(const gchar *tapname, const gchar *name, tap_packet_cb tap_packet, export_object_gui_reset_cb eo_protocoldata_resetfn)
|
||||
{
|
||||
GtkWidget *sw;
|
||||
GtkCellRenderer *renderer;
|
||||
GtkTreeViewColumn *column;
|
||||
GtkTreeSelection *selection;
|
||||
GtkWidget *vbox, *bbox, *help_bt, *cancel_bt, *save_bt, *save_all_bt;
|
||||
GString *error_msg;
|
||||
export_object_list_t *tap_data;
|
||||
export_object_list_gui_t *object_list;
|
||||
gchar *window_title;
|
||||
|
||||
/* Initialize the pointer to the private data clearing function */
|
||||
eo_protocoldata_reset = eo_protocoldata_resetfn;
|
||||
|
||||
/* Initialize our object list structure */
|
||||
tap_data = g_new0(export_object_list_t,1);
|
||||
object_list = g_new0(export_object_list_gui_t,1);
|
||||
|
||||
tap_data->add_entry = object_list_add_entry;
|
||||
tap_data->get_entry = object_list_get_entry;
|
||||
tap_data->gui_data = (void*)object_list;
|
||||
|
||||
/* Data will be gathered via a tap callback */
|
||||
error_msg = register_tap_listener(tapname, tap_data, NULL, 0,
|
||||
eo_reset,
|
||||
tap_packet,
|
||||
eo_draw);
|
||||
|
||||
if (error_msg) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Can't register %s tap: %s\n", name, error_msg->str);
|
||||
g_string_free(error_msg, TRUE);
|
||||
g_free(tap_data);
|
||||
g_free(object_list);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Setup our GUI window */
|
||||
window_title = g_strdup_printf("Wireshark: %s object list", name);
|
||||
object_list->dlg = dlg_window_new(window_title);
|
||||
g_free(window_title);
|
||||
|
||||
gtk_window_set_default_size(GTK_WINDOW(object_list->dlg),
|
||||
DEF_WIDTH, DEF_HEIGHT);
|
||||
|
||||
vbox = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 5, FALSE);
|
||||
|
||||
gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
|
||||
gtk_container_add(GTK_CONTAINER(object_list->dlg), vbox);
|
||||
|
||||
sw = scrolled_window_new(NULL, NULL);
|
||||
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
|
||||
GTK_SHADOW_IN);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX (vbox), sw, TRUE, TRUE, 0);
|
||||
|
||||
object_list->store = gtk_tree_store_new(EO_NUM_COLUMNS,
|
||||
G_TYPE_INT, G_TYPE_STRING,
|
||||
/* we need a UINT64
|
||||
(was G_TYPE_STRING, G_TYPE_INT,) */
|
||||
G_TYPE_STRING, G_TYPE_STRING,
|
||||
G_TYPE_STRING);
|
||||
|
||||
object_list->tree = tree_view_new(GTK_TREE_MODEL(object_list->store));
|
||||
g_object_unref(G_OBJECT(object_list->store));
|
||||
|
||||
object_list->tree_view = GTK_TREE_VIEW(object_list->tree);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes("Packet num",
|
||||
renderer,
|
||||
"text",
|
||||
EO_PKT_NUM_COLUMN,
|
||||
NULL);
|
||||
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
|
||||
gtk_tree_view_append_column(object_list->tree_view, column);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes("Hostname",
|
||||
renderer,
|
||||
"text",
|
||||
EO_HOSTNAME_COLUMN,
|
||||
NULL);
|
||||
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
|
||||
gtk_tree_view_append_column(object_list->tree_view, column);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes("Content Type",
|
||||
renderer,
|
||||
"text",
|
||||
EO_CONTENT_TYPE_COLUMN,
|
||||
NULL);
|
||||
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
|
||||
gtk_tree_view_append_column(object_list->tree_view, column);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes("Size",
|
||||
renderer,
|
||||
"text",
|
||||
EO_BYTES_COLUMN,
|
||||
NULL);
|
||||
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
|
||||
gtk_tree_view_append_column(object_list->tree_view, column);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes("Filename",
|
||||
renderer,
|
||||
"text",
|
||||
EO_FILENAME_COLUMN,
|
||||
NULL);
|
||||
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
|
||||
gtk_tree_view_append_column(object_list->tree_view, column);
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(sw), object_list->tree);
|
||||
|
||||
selection = gtk_tree_view_get_selection(object_list->tree_view);
|
||||
g_signal_connect(selection, "changed", G_CALLBACK(eo_remember_row_num), tap_data);
|
||||
|
||||
bbox = dlg_button_row_new(GTK_STOCK_HELP, WIRESHARK_STOCK_SAVE_ALL, GTK_STOCK_SAVE_AS, GTK_STOCK_CANCEL, NULL);
|
||||
|
||||
/* Help button */
|
||||
help_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
|
||||
g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb), (gpointer)HELP_EXPORT_OBJECT_LIST);
|
||||
gtk_widget_set_tooltip_text(help_bt, "Show help for this dialog.");
|
||||
|
||||
/* Save All button */
|
||||
save_all_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_SAVE_ALL);
|
||||
g_signal_connect(save_all_bt, "clicked", G_CALLBACK(eo_save_all_clicked_cb), tap_data);
|
||||
gtk_widget_set_tooltip_text(save_all_bt, "Save all listed objects with their displayed filenames.");
|
||||
|
||||
/* Save As button */
|
||||
save_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_SAVE_AS);
|
||||
g_signal_connect(save_bt, "clicked", G_CALLBACK(eo_save_clicked_cb), tap_data);
|
||||
gtk_widget_set_tooltip_text(save_bt, "Saves the currently selected content to a file.");
|
||||
|
||||
/* Cancel button */
|
||||
cancel_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
|
||||
gtk_widget_set_tooltip_text(cancel_bt, "Cancel this dialog.");
|
||||
|
||||
/* Pack the buttons into the "button box" */
|
||||
gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show(bbox);
|
||||
|
||||
/* Setup cancel/delete/destroy signal handlers */
|
||||
g_signal_connect(object_list->dlg, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
||||
g_signal_connect(object_list->dlg, "destroy", G_CALLBACK(eo_win_destroy_cb), tap_data);
|
||||
window_set_cancel_button(object_list->dlg, cancel_bt,
|
||||
window_cancel_button_cb);
|
||||
|
||||
/* Show the window */
|
||||
gtk_widget_show_all(object_list->dlg);
|
||||
window_present(object_list->dlg);
|
||||
|
||||
cf_retap_packets(&cfile);
|
||||
}
|
||||
|
||||
void exportobject_cb(register_eo_t *eo)
|
||||
{
|
||||
export_object_window(get_eo_tap_listener_name(eo), proto_get_protocol_short_name(find_protocol_by_id(get_eo_proto_id(eo))), get_eo_packet_func(eo), get_eo_reset_func(eo));
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
||||
* :indentSize=8:tabSize=8:noTabs=false:
|
||||
*/
|
|
@ -1,32 +0,0 @@
|
|||
/* export_object.h
|
||||
* Common routines for tracking & saving objects found in streams of data
|
||||
* Copyright 2007, Stephen Fisher (see AUTHORS file)
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*/
|
||||
|
||||
#ifndef __EXPORT_OBJECT_DLG_H__
|
||||
#define __EXPORT_OBJECT_DLG_H__
|
||||
|
||||
#include <epan/export_object.h>
|
||||
|
||||
void exportobject_cb(register_eo_t *eo);
|
||||
|
||||
#endif /* __EXPORT_OBJECT_DLG_H__ */
|
|
@ -1,187 +0,0 @@
|
|||
/* export_pdu_dlg.c
|
||||
* Dialog for exporting PDUs to file
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <wiretap/pcap-encap.h>
|
||||
|
||||
#include <epan/exported_pdu.h>
|
||||
|
||||
|
||||
#include "ui/gtk/old-gtk-compat.h"
|
||||
#include "ui/gtk/capture_file_dlg.h"
|
||||
#include "ui/gtk/dlg_utils.h"
|
||||
#include "ui/gtk/gui_utils.h"
|
||||
#include "ui/gtk/filter_dlg.h"
|
||||
#include "ui/gtk/gtkglobals.h"
|
||||
#include "ui/gtk/filter_autocomplete.h"
|
||||
#include "ui/gtk/stock_icons.h"
|
||||
|
||||
|
||||
#include "ui/tap_export_pdu.h"
|
||||
#include "ui/export_pdu_ui_utils.h"
|
||||
#include "ui/gtk/export_pdu_dlg.h"
|
||||
|
||||
static GtkWidget *export_pdu_dlg = NULL;
|
||||
|
||||
|
||||
typedef struct _exp_pdu_dlg_t {
|
||||
GtkWidget *filter_widget;
|
||||
GtkWidget *tap_name_widget;
|
||||
exp_pdu_t exp_pdu_tap_data;
|
||||
} exp_pdu_dlg_t;
|
||||
|
||||
|
||||
static void
|
||||
export_pdu_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
|
||||
{
|
||||
/* Note that we no longer have a export_pdu dialog box. */
|
||||
export_pdu_dlg = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
export_pdu_action(gpointer data)
|
||||
{
|
||||
const char *filter = NULL;
|
||||
exp_pdu_dlg_t *exp_pdu_dlg_data = (exp_pdu_dlg_t *)data;
|
||||
gchar *tap_name = NULL;
|
||||
|
||||
filter = gtk_entry_get_text(GTK_ENTRY(exp_pdu_dlg_data->filter_widget));
|
||||
tap_name = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(exp_pdu_dlg_data->tap_name_widget));
|
||||
|
||||
do_export_pdu(filter, tap_name, &(exp_pdu_dlg_data->exp_pdu_tap_data));
|
||||
window_destroy(export_pdu_dlg);
|
||||
g_free(exp_pdu_dlg_data);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
export_pdu_show_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||
{
|
||||
|
||||
GtkWidget *main_vb, *bbox, *close_bt, *ok_bt;
|
||||
GtkWidget *grid, *filter_bt;
|
||||
exp_pdu_dlg_t *exp_pdu_dlg_data;
|
||||
const char *filter = NULL;
|
||||
guint row;
|
||||
GSList *tap_name_list;
|
||||
|
||||
static construct_args_t args = {
|
||||
"Wireshark: Export PDUs Filter",
|
||||
TRUE, /* dialog should have an Apply button */
|
||||
FALSE, /* if parent text widget should be activated on "Ok" or "Apply" */
|
||||
FALSE /* dialog is modal and transient to the parent window */
|
||||
};
|
||||
|
||||
if (export_pdu_dlg != NULL) {
|
||||
/* There's already a export_pdu dialog box; reactivate it. */
|
||||
reactivate_window(export_pdu_dlg);
|
||||
return;
|
||||
}
|
||||
|
||||
exp_pdu_dlg_data = (exp_pdu_dlg_t *)g_malloc(sizeof(exp_pdu_dlg_t));
|
||||
exp_pdu_dlg_data->exp_pdu_tap_data.pkt_encap = wtap_wtap_encap_to_pcap_encap(WTAP_ENCAP_WIRESHARK_UPPER_PDU);
|
||||
|
||||
export_pdu_dlg = window_new(GTK_WINDOW_TOPLEVEL, "Wireshark: Export PDUs to pcapng file");
|
||||
|
||||
g_signal_connect(export_pdu_dlg, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
||||
g_signal_connect(export_pdu_dlg, "destroy", G_CALLBACK(export_pdu_destroy_cb), NULL);
|
||||
|
||||
main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(main_vb), 3);
|
||||
gtk_container_add(GTK_CONTAINER(export_pdu_dlg), main_vb);
|
||||
|
||||
/* grid */
|
||||
grid = ws_gtk_grid_new();
|
||||
ws_gtk_grid_set_column_spacing(GTK_GRID(grid), 6);
|
||||
ws_gtk_grid_set_row_spacing(GTK_GRID(grid), 3);
|
||||
gtk_box_pack_start(GTK_BOX(main_vb), grid, TRUE, TRUE, 0);
|
||||
row = 0;
|
||||
|
||||
/* Filter button */
|
||||
filter_bt=ws_gtk_button_new_from_stock(WIRESHARK_STOCK_DISPLAY_FILTER_ENTRY);
|
||||
g_signal_connect(filter_bt, "clicked", G_CALLBACK(display_filter_construct_cb), &args);
|
||||
ws_gtk_grid_attach_defaults(GTK_GRID(grid), filter_bt, 0, row, 1, 1);
|
||||
gtk_widget_show(filter_bt);
|
||||
|
||||
/* Entry */
|
||||
exp_pdu_dlg_data->filter_widget=gtk_entry_new();
|
||||
g_signal_connect(exp_pdu_dlg_data->filter_widget, "changed", G_CALLBACK(filter_te_syntax_check_cb), NULL);
|
||||
g_object_set_data(G_OBJECT(grid), E_FILT_AUTOCOMP_PTR_KEY, NULL);
|
||||
g_signal_connect(exp_pdu_dlg_data->filter_widget, "key-press-event", G_CALLBACK (filter_string_te_key_pressed_cb), NULL);
|
||||
g_object_set_data(G_OBJECT(filter_bt), E_FILT_TE_PTR_KEY, exp_pdu_dlg_data->filter_widget);
|
||||
|
||||
filter=gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
|
||||
if(filter){
|
||||
gtk_entry_set_text(GTK_ENTRY(exp_pdu_dlg_data->filter_widget), filter);
|
||||
} else {
|
||||
colorize_filter_te_as_empty(exp_pdu_dlg_data->filter_widget);
|
||||
}
|
||||
|
||||
ws_gtk_grid_attach_defaults(GTK_GRID(grid), exp_pdu_dlg_data->filter_widget, 1, row, 1, 1);
|
||||
gtk_widget_show(exp_pdu_dlg_data->filter_widget);
|
||||
row++;
|
||||
|
||||
/* Select which tap to run */
|
||||
/* Combo box */
|
||||
exp_pdu_dlg_data->tap_name_widget = gtk_combo_box_text_new();
|
||||
for (tap_name_list = get_export_pdu_tap_list(); tap_name_list; tap_name_list = g_slist_next(tap_name_list)) {
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(exp_pdu_dlg_data->tap_name_widget), (const char*)(tap_name_list->data));
|
||||
}
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(exp_pdu_dlg_data->tap_name_widget), 0);
|
||||
|
||||
ws_gtk_grid_attach_defaults(GTK_GRID(grid), exp_pdu_dlg_data->tap_name_widget, 0, row, 1, 1);
|
||||
gtk_widget_show(exp_pdu_dlg_data->tap_name_widget);
|
||||
|
||||
/* Setup the button row */
|
||||
|
||||
bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL);
|
||||
gtk_box_pack_end(GTK_BOX(main_vb), bbox, FALSE, FALSE, 3);
|
||||
|
||||
close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
|
||||
window_set_cancel_button(export_pdu_dlg, close_bt, window_cancel_button_cb);
|
||||
gtk_widget_set_tooltip_text(close_bt, "Close this dialog");
|
||||
|
||||
ok_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
|
||||
g_signal_connect(ok_bt, "clicked", G_CALLBACK(file_export_pdu_ok_cb), exp_pdu_dlg_data);
|
||||
gtk_widget_grab_default(ok_bt);
|
||||
gtk_widget_set_tooltip_text(ok_bt, "Export PDUs to a temporary capture file");
|
||||
|
||||
gtk_widget_show_all(export_pdu_dlg);
|
||||
window_present(export_pdu_dlg);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines
|
||||
*
|
||||
* Local Variables:
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* ex: set shiftwidth=4 tabstop=8 expandtab:
|
||||
* :indentSize=4:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -1,43 +0,0 @@
|
|||
/* export_pdu_dlg.h
|
||||
* Routines for dialogs for exporting PDUs to file
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __EXPORT_PDU_DLG_H__
|
||||
#define __EXPORT_PDU_DLG_H__
|
||||
|
||||
void export_pdu_show_cb(GtkWidget *widget, gpointer data);
|
||||
void export_pdu_action(gpointer data);
|
||||
|
||||
#endif /* __EXPORT_PDU_DLG_H__ */
|
||||
|
||||
/*
|
||||
* Editor modelines
|
||||
*
|
||||
* Local Variables:
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* ex: set shiftwidth=4 tabstop=8 expandtab:
|
||||
* :indentSize=4:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -1,196 +0,0 @@
|
|||
/* export_sslkeys.c
|
||||
*
|
||||
* Export SSL Session Keys dialog
|
||||
* by Sake Blok <sake@euronet.nl> (20110526)
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <wsutil/file_util.h>
|
||||
#include <wsutil/str_util.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
# include <gdk/gdkkeysyms-compat.h>
|
||||
#endif
|
||||
|
||||
#include <wsutil/filesystem.h>
|
||||
#include <epan/packet.h>
|
||||
#include <epan/epan_dissect.h>
|
||||
#include <epan/charsets.h>
|
||||
#include <epan/prefs.h>
|
||||
|
||||
#include "ui/alert_box.h"
|
||||
#include "ui/last_open_dir.h"
|
||||
#include "ui/progress_dlg.h"
|
||||
#include "ui/recent.h"
|
||||
#include "ui/simple_dialog.h"
|
||||
#include "ui/ssl_key_export.h"
|
||||
#include "ui/ws_ui_util.h"
|
||||
|
||||
#include "ui/gtk/keys.h"
|
||||
#include "ui/gtk/color_utils.h"
|
||||
#include "ui/gtk/packet_win.h"
|
||||
#include "ui/gtk/file_dlg.h"
|
||||
#include "ui/gtk/gui_utils.h"
|
||||
#include "ui/gtk/gtkglobals.h"
|
||||
#include "ui/gtk/font_utils.h"
|
||||
#include "ui/gtk/webbrowser.h"
|
||||
#include "ui/gtk/main.h"
|
||||
#include "ui/gtk/export_sslkeys.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <gdk/gdkwin32.h>
|
||||
#include <windows.h>
|
||||
#include "ui/win32/file_dlg_win32.h"
|
||||
#include "ui/gtk/old-gtk-compat.h"
|
||||
#endif
|
||||
|
||||
/* save the SSL Session Keys */
|
||||
static gboolean
|
||||
savesslkeys_save_clicked_cb(char *file, gchar *keylist)
|
||||
{
|
||||
int fd;
|
||||
|
||||
fd = ws_open(file, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0666);
|
||||
if (fd == -1) {
|
||||
open_failure_alert_box(file, errno, TRUE);
|
||||
return FALSE;
|
||||
}
|
||||
/*
|
||||
* Thanks, Microsoft, for not using size_t for the third argument to
|
||||
* _write(). Presumably this string will be <= 4GiB long....
|
||||
*/
|
||||
if (ws_write(fd, keylist, (unsigned int)strlen(keylist)) < 0) {
|
||||
write_failure_alert_box(file, errno);
|
||||
ws_close(fd);
|
||||
return FALSE;
|
||||
}
|
||||
if (ws_close(fd) < 0) {
|
||||
write_failure_alert_box(file, errno);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_free(keylist);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* Launch the dialog box to put up the file selection box etc */
|
||||
#ifdef _WIN32
|
||||
void
|
||||
savesslkeys_cb(GtkWidget * w _U_, gpointer data _U_)
|
||||
{
|
||||
win32_export_sslkeys_file(GDK_WINDOW_HWND(gtk_widget_get_window(top_level)));
|
||||
return;
|
||||
}
|
||||
#else
|
||||
static char *
|
||||
gtk_export_sslkeys_file(guint keylist_len)
|
||||
{
|
||||
GtkWidget *savesslkeys_dlg;
|
||||
gchar *label;
|
||||
GtkWidget *dlg_lb;
|
||||
char *pathname;
|
||||
|
||||
/*
|
||||
* Build the dialog box we need.
|
||||
*/
|
||||
savesslkeys_dlg = file_selection_new("Wireshark: Export SSL Session Keys",
|
||||
GTK_WINDOW(top_level),
|
||||
FILE_SELECTION_SAVE);
|
||||
|
||||
/* label */
|
||||
label = g_strdup_printf("Will save %u SSL Session %s to specified file.",
|
||||
keylist_len, plurality(keylist_len, "key", "keys"));
|
||||
dlg_lb = gtk_label_new(label);
|
||||
g_free(label);
|
||||
file_selection_set_extra_widget(savesslkeys_dlg, dlg_lb);
|
||||
gtk_widget_show(dlg_lb);
|
||||
|
||||
pathname = file_selection_run(savesslkeys_dlg);
|
||||
if (pathname == NULL) {
|
||||
/* User cancelled or closed the dialog. */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* We've crosed the Rubicon; get rid of the dialog box. */
|
||||
window_destroy(savesslkeys_dlg);
|
||||
|
||||
return pathname;
|
||||
}
|
||||
|
||||
void
|
||||
savesslkeys_cb(GtkWidget * w _U_, gpointer data _U_)
|
||||
{
|
||||
char *pathname;
|
||||
guint keylist_len;
|
||||
gchar *keylist;
|
||||
|
||||
keylist_len = ssl_session_key_count();
|
||||
/* don't show up the dialog, if no data has to be saved */
|
||||
if (keylist_len==0) {
|
||||
/* shouldn't happen as the menu item should have been greyed out */
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "There are no SSL Session Keys to save.");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieve the info we need
|
||||
*/
|
||||
keylist = ssl_export_sessions();
|
||||
|
||||
/*
|
||||
* Loop until the user either selects a file or gives up.
|
||||
*/
|
||||
for (;;) {
|
||||
pathname = gtk_export_sslkeys_file(keylist_len);
|
||||
if (pathname == NULL) {
|
||||
/* User gave up. */
|
||||
break;
|
||||
}
|
||||
if (savesslkeys_save_clicked_cb(pathname, keylist)) {
|
||||
/* We succeeded. */
|
||||
g_free(pathname);
|
||||
break;
|
||||
}
|
||||
/* Dump failed; let the user select another file or give up. */
|
||||
g_free(pathname);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
||||
* :indentSize=4:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -1,35 +0,0 @@
|
|||
/* export_sslkeys.h
|
||||
*
|
||||
* Export SSL Session Keys dialog
|
||||
* by Sake Blok <sake@euronet.nl> (20110526)
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __EXPORT_SSLKEYS_H__
|
||||
#define __EXPORT_SSLKEYS_H__
|
||||
|
||||
/** Callback for "Export SSL Session Keys" operation.
|
||||
*
|
||||
* @param w unused
|
||||
* @param data unused
|
||||
*/
|
||||
extern void savesslkeys_cb(GtkWidget * w, gpointer data);
|
||||
|
||||
#endif /* __EXPORT_SSLKEYS_H__ */
|
|
@ -1,960 +0,0 @@
|
|||
/* extcap_gtk.c
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include <ui/gtk/gui_utils.h>
|
||||
#include <wsutil/filesystem.h>
|
||||
|
||||
#include "extcap_gtk.h"
|
||||
#include "ui/gtk/old-gtk-compat.h"
|
||||
|
||||
#include "log.h"
|
||||
|
||||
static gboolean extcap_gtk_count_tree_elements(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
|
||||
{
|
||||
int *ptr_count = (int*)data;
|
||||
gboolean multi_enabled;
|
||||
(void)path;
|
||||
|
||||
g_assert(ptr_count != NULL);
|
||||
|
||||
gtk_tree_model_get(model, iter,
|
||||
EXTCAP_GTK_MULTI_COL_CHECK, &multi_enabled, -1);
|
||||
|
||||
if (multi_enabled)
|
||||
{
|
||||
++(*ptr_count);
|
||||
}
|
||||
|
||||
return FALSE; /* Continue iteration. */
|
||||
}
|
||||
|
||||
typedef struct _extcap_gtk_multi_fill_cb_data
|
||||
{
|
||||
gchar **list;
|
||||
int num;
|
||||
int max;
|
||||
} extcap_gtk_multi_fill_cb_data;
|
||||
|
||||
static gboolean extcap_gtk_fill_multi_list(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
|
||||
{
|
||||
extcap_gtk_multi_fill_cb_data *ptr_data = (extcap_gtk_multi_fill_cb_data*)data;
|
||||
gboolean multi_enabled;
|
||||
extcap_value *value;
|
||||
(void)path;
|
||||
|
||||
g_assert(ptr_data != NULL);
|
||||
|
||||
gtk_tree_model_get(model, iter,
|
||||
EXTCAP_GTK_MULTI_COL_CHECK, &multi_enabled,
|
||||
EXTCAP_GTK_MULTI_COL_VALUE, &value, -1);
|
||||
|
||||
if (multi_enabled)
|
||||
{
|
||||
g_assert(ptr_data->num < ptr_data->max);
|
||||
|
||||
if (ptr_data->num < ptr_data->max)
|
||||
{
|
||||
ptr_data->list[ptr_data->num] = g_strdup(value->call);
|
||||
ptr_data->num++;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE; /* Continue iteration. */
|
||||
}
|
||||
|
||||
typedef struct _extcap_gtk_multi_find_cb_data
|
||||
{
|
||||
gchar *parent;
|
||||
GtkTreeIter *parent_iter;
|
||||
} extcap_gtk_multi_find_cb_data;
|
||||
|
||||
static gboolean extcap_gtk_find_parent_in_multi_list(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
|
||||
{
|
||||
extcap_gtk_multi_find_cb_data *ptr_data = (extcap_gtk_multi_find_cb_data*)data;
|
||||
extcap_value *value;
|
||||
(void)path;
|
||||
|
||||
g_assert(ptr_data != NULL);
|
||||
|
||||
gtk_tree_model_get(model, iter,
|
||||
EXTCAP_GTK_MULTI_COL_VALUE, &value, -1);
|
||||
|
||||
if (0 == g_strcmp0(ptr_data->parent, value->call))
|
||||
{
|
||||
ptr_data->parent_iter = gtk_tree_iter_copy(iter);
|
||||
return TRUE; /* Stop iteration. */
|
||||
}
|
||||
|
||||
return FALSE; /* Continue iteration. */
|
||||
}
|
||||
|
||||
GHashTable *extcap_gtk_get_state(GtkWidget *widget) {
|
||||
GSList *widget_list, *widget_iter;
|
||||
GSList *radio_list = NULL, *radio_iter = NULL;
|
||||
|
||||
GtkWidget *list_widget, *radio_widget, *tree_widget, *entry_widget;
|
||||
|
||||
extcap_arg *arg = NULL;
|
||||
extcap_value *value = NULL;
|
||||
extcap_complex *parsed_complex = NULL;
|
||||
|
||||
GtkTreeSelection *treeselection;
|
||||
GtkTreeModel *treemodel;
|
||||
GtkTreeIter treeiter;
|
||||
|
||||
GHashTable *ret_hash;
|
||||
|
||||
gchar *call_string = NULL;
|
||||
|
||||
extcap_gtk_multi_fill_cb_data multi_data = { NULL, 0, 0 };
|
||||
|
||||
int multi_num = 0;
|
||||
|
||||
guint year = 0;
|
||||
guint month = 0;
|
||||
guint day = 0;
|
||||
guint64 unix_ts = 0;
|
||||
|
||||
widget_list = (GSList *) g_object_get_data(G_OBJECT(widget),
|
||||
EXTCAP_GTK_DATA_KEY_WIDGETLIST);
|
||||
|
||||
if (widget_list == NULL)
|
||||
return NULL ;
|
||||
|
||||
/* String hash */
|
||||
ret_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
|
||||
|
||||
for (widget_iter = widget_list; widget_iter; widget_iter =
|
||||
widget_iter->next) {
|
||||
list_widget = (GtkWidget *) widget_iter->data;
|
||||
|
||||
if ((arg = (extcap_arg *) g_object_get_data(G_OBJECT(list_widget),
|
||||
EXTCAP_GTK_DATA_KEY_ARGPTR)) == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (arg->arg_type) {
|
||||
case EXTCAP_ARG_INTEGER:
|
||||
case EXTCAP_ARG_UNSIGNED:
|
||||
case EXTCAP_ARG_LONG:
|
||||
case EXTCAP_ARG_DOUBLE:
|
||||
case EXTCAP_ARG_STRING:
|
||||
case EXTCAP_ARG_PASSWORD:
|
||||
parsed_complex = extcap_parse_complex(arg->arg_type,
|
||||
gtk_entry_get_text(GTK_ENTRY(list_widget)));
|
||||
if (parsed_complex == NULL) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case EXTCAP_ARG_BOOLEAN:
|
||||
case EXTCAP_ARG_BOOLFLAG:
|
||||
parsed_complex = extcap_parse_complex(arg->arg_type,
|
||||
gtk_toggle_button_get_active(
|
||||
GTK_TOGGLE_BUTTON(list_widget)) ? "true" : "false");
|
||||
break;
|
||||
case EXTCAP_ARG_FILESELECT:
|
||||
if ((entry_widget =
|
||||
(GtkWidget *) g_object_get_data(G_OBJECT(list_widget),
|
||||
EXTCAP_GTK_DATA_KEY_FILENAME)) == NULL) {
|
||||
continue;
|
||||
}
|
||||
parsed_complex = extcap_parse_complex(arg->arg_type,
|
||||
gtk_entry_get_text(GTK_ENTRY(entry_widget)));
|
||||
if (parsed_complex == NULL) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case EXTCAP_ARG_TIMESTAMP: {
|
||||
struct tm t;
|
||||
gtk_calendar_get_date((GtkCalendar*)list_widget, &year, &month, &day);
|
||||
t.tm_year = year;
|
||||
t.tm_mon = month;
|
||||
t.tm_mday = day;
|
||||
t.tm_hour = 0;
|
||||
t.tm_min = 0;
|
||||
t.tm_sec = 0;
|
||||
unix_ts = mktime(&t);
|
||||
call_string = g_strdup_printf("%" G_GINT64_MODIFIER "u", unix_ts);
|
||||
}
|
||||
break;
|
||||
case EXTCAP_ARG_RADIO:
|
||||
if ((radio_widget = (GtkWidget *) g_object_get_data(
|
||||
G_OBJECT(list_widget),
|
||||
EXTCAP_GTK_DATA_KEY_FIRSTRADIO)) == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((radio_list = gtk_radio_button_get_group(
|
||||
GTK_RADIO_BUTTON(radio_widget))) == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (radio_iter = radio_list; radio_iter;
|
||||
radio_iter = radio_iter->next) {
|
||||
GtkWidget *cur_radio = (GtkWidget *) radio_iter->data;
|
||||
|
||||
if (gtk_toggle_button_get_active(
|
||||
GTK_TOGGLE_BUTTON(cur_radio))) {
|
||||
if ((value = (extcap_value *) g_object_get_data(
|
||||
G_OBJECT(cur_radio),
|
||||
EXTCAP_GTK_DATA_KEY_VALPTR)) == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (value->is_default)
|
||||
continue;
|
||||
|
||||
call_string = g_strdup(value->call);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case EXTCAP_ARG_SELECTOR:
|
||||
if ((tree_widget = (GtkWidget *) g_object_get_data(
|
||||
G_OBJECT(list_widget),
|
||||
EXTCAP_GTK_DATA_KEY_TREEVIEW)) == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
treeselection = gtk_tree_view_get_selection(
|
||||
GTK_TREE_VIEW(tree_widget));
|
||||
treemodel = gtk_tree_view_get_model(GTK_TREE_VIEW(tree_widget));
|
||||
if (gtk_tree_selection_get_selected(treeselection, &treemodel,
|
||||
&treeiter)) {
|
||||
gtk_tree_model_get(treemodel, &treeiter, EXTCAP_GTK_COL_VALUE,
|
||||
&value, -1);
|
||||
|
||||
if (value->is_default)
|
||||
continue;
|
||||
|
||||
call_string = g_strdup(value->call);
|
||||
}
|
||||
|
||||
break;
|
||||
case EXTCAP_ARG_MULTICHECK:
|
||||
if ((tree_widget = (GtkWidget *) g_object_get_data(
|
||||
G_OBJECT(list_widget),
|
||||
EXTCAP_GTK_DATA_KEY_TREEVIEW)) == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_widget));
|
||||
treemodel = gtk_tree_view_get_model(GTK_TREE_VIEW(tree_widget));
|
||||
|
||||
multi_num = 0;
|
||||
|
||||
/* Count the # of items enabled */
|
||||
gtk_tree_model_foreach(treemodel, extcap_gtk_count_tree_elements,
|
||||
&multi_num);
|
||||
|
||||
if (multi_num > 0)
|
||||
{
|
||||
multi_data.list = g_new(gchar *, multi_num + 1);
|
||||
multi_data.num = 0;
|
||||
multi_data.max = multi_num;
|
||||
|
||||
multi_num = 0;
|
||||
|
||||
/* Get values list of items enabled */
|
||||
gtk_tree_model_foreach(treemodel, extcap_gtk_fill_multi_list,
|
||||
&multi_data);
|
||||
|
||||
multi_data.list[multi_data.max] = NULL;
|
||||
|
||||
call_string = g_strjoinv(",", multi_data.list);
|
||||
|
||||
g_strfreev(multi_data.list);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* There are no enabled items. Skip this argument from command line. */
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (parsed_complex == NULL && call_string == NULL)
|
||||
continue;
|
||||
|
||||
|
||||
/* Flags are set as is, and have not true/false switch */
|
||||
if (arg->arg_type == EXTCAP_ARG_BOOLFLAG)
|
||||
{
|
||||
if (extcap_complex_get_bool(parsed_complex) == TRUE)
|
||||
{
|
||||
/* Include boolflag call in list.
|
||||
* Only arg->call should appear in commandline arguments.
|
||||
* Setting call_string to NULL here makes it perform as desired.
|
||||
*/
|
||||
call_string = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Omit boolflag call from list. */
|
||||
g_free(parsed_complex);
|
||||
parsed_complex = NULL;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Comparing if the user has changed the value at all, and ignoring it if so.
|
||||
* This does not apply to EXTCAP_ARG_BOOLFLAG.
|
||||
*/
|
||||
if (extcap_compare_is_default(arg, parsed_complex))
|
||||
continue;
|
||||
|
||||
if (parsed_complex != NULL && call_string == NULL)
|
||||
call_string = extcap_get_complex_as_string(parsed_complex);
|
||||
}
|
||||
|
||||
g_hash_table_insert(ret_hash, g_strdup(arg->call),
|
||||
g_strdup(call_string));
|
||||
|
||||
g_free(call_string);
|
||||
call_string = NULL;
|
||||
|
||||
g_free(parsed_complex);
|
||||
parsed_complex = NULL;
|
||||
}
|
||||
|
||||
return ret_hash;
|
||||
}
|
||||
|
||||
static void extcap_gtk_treeview_vscroll_map_handler(GtkTreeView *treeView,
|
||||
gpointer data) {
|
||||
GtkWidget *padBox = (GtkWidget*) data;
|
||||
gint x, y;
|
||||
|
||||
g_assert(GTK_IS_BOX(padBox));
|
||||
|
||||
/* Set the padding above the scrollbar to the height of the tree header window */
|
||||
gtk_tree_view_convert_bin_window_to_widget_coords(GTK_TREE_VIEW(treeView),
|
||||
0, 0, &x, &y);
|
||||
gtk_widget_set_size_request(padBox, -1, y);
|
||||
}
|
||||
|
||||
static GtkWidget *extcap_gtk_wrap_scroll_treeview(GtkWidget *view) {
|
||||
GtkWidget *vscroll, *padbox, *hbox, *vbox;
|
||||
GtkAdjustment *padj;
|
||||
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
padj = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(view));
|
||||
#if GTK_CHECK_VERSION(3, 2, 0)
|
||||
vscroll = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, padj);
|
||||
#else
|
||||
vscroll = gtk_vscrollbar_new(padj);
|
||||
#endif
|
||||
#else
|
||||
padj = gtk_tree_view_get_vadjustment(GTK_TREE_VIEW(view));
|
||||
vscroll = gtk_vscrollbar_new(padj);
|
||||
#endif
|
||||
|
||||
hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0, FALSE);
|
||||
|
||||
/* First insert the tree view */
|
||||
gtk_box_pack_start(GTK_BOX(hbox), view, TRUE, TRUE, 0);
|
||||
gtk_widget_show(view);
|
||||
|
||||
/* Pack to the right a vbox containing a box for padding at top and scrollbar */
|
||||
vbox = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show(vbox);
|
||||
|
||||
padbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0, FALSE);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), padbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show(padbox);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(vbox), vscroll, TRUE, TRUE, 0);
|
||||
gtk_widget_show(vscroll);
|
||||
|
||||
g_object_set_data(G_OBJECT(hbox), EXTCAP_GTK_DATA_KEY_TREEVIEW, view);
|
||||
|
||||
g_signal_connect(view, "map",
|
||||
G_CALLBACK(extcap_gtk_treeview_vscroll_map_handler), padbox);
|
||||
|
||||
return hbox;
|
||||
}
|
||||
|
||||
GtkWidget *extcap_create_gtk_listwidget(extcap_arg *argument,
|
||||
GHashTable *prev_map) {
|
||||
GtkCellRenderer *renderer;
|
||||
GtkTreeModel *model;
|
||||
GtkWidget *view, *retview;
|
||||
GtkListStore *store;
|
||||
GtkTreeIter iter;
|
||||
GtkTreeSelection *selection;
|
||||
extcap_value *v = NULL;
|
||||
GList * walker = NULL;
|
||||
gchar *prev_item = NULL;
|
||||
|
||||
if (g_list_length(argument->values) == 0)
|
||||
return NULL ;
|
||||
|
||||
view = gtk_tree_view_new();
|
||||
|
||||
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
|
||||
|
||||
store = gtk_list_store_new(EXTCAP_GTK_NUM_COLS, G_TYPE_STRING,
|
||||
G_TYPE_POINTER);
|
||||
|
||||
model = GTK_TREE_MODEL(store);
|
||||
gtk_tree_view_set_model(GTK_TREE_VIEW(view), model);
|
||||
gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
|
||||
|
||||
if (prev_map != NULL)
|
||||
prev_item = (gchar *) g_hash_table_lookup(prev_map, argument->call);
|
||||
|
||||
for (walker = g_list_first(argument->values); walker != NULL ; walker =
|
||||
walker->next) {
|
||||
v = (extcap_value *) walker->data;
|
||||
if (v->display == NULL)
|
||||
break;
|
||||
|
||||
gtk_list_store_append(store, &iter);
|
||||
gtk_list_store_set(store, &iter, EXTCAP_GTK_COL_DISPLAY, v->display,
|
||||
EXTCAP_GTK_COL_VALUE, v, -1);
|
||||
|
||||
if (prev_item != NULL) {
|
||||
if (g_ascii_strcasecmp(prev_item, v->call) == 0) {
|
||||
gtk_tree_selection_select_iter(selection, &iter);
|
||||
}
|
||||
} else if (v->is_default) {
|
||||
gtk_tree_selection_select_iter(selection, &iter);
|
||||
}
|
||||
}
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), -1, "Name",
|
||||
renderer, "text", EXTCAP_GTK_COL_DISPLAY, NULL);
|
||||
|
||||
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);
|
||||
|
||||
retview = extcap_gtk_wrap_scroll_treeview(view);
|
||||
|
||||
if (gtk_tree_model_iter_n_children(model, NULL) > 3)
|
||||
gtk_widget_set_size_request(retview, 0, 100);
|
||||
|
||||
/* Tree view has own reference */
|
||||
g_object_unref(model);
|
||||
|
||||
return retview;
|
||||
}
|
||||
|
||||
GtkWidget *extcap_create_gtk_radiowidget(extcap_arg *argument,
|
||||
GHashTable *prev_map) {
|
||||
GtkWidget *radiobox = NULL, *last_radio = NULL;
|
||||
extcap_value *v = NULL;
|
||||
GList * walker = NULL;
|
||||
gchar *prev_item = NULL;
|
||||
|
||||
if (g_list_length(argument->values) == 0)
|
||||
return NULL ;
|
||||
|
||||
if (prev_map != NULL)
|
||||
prev_item = (gchar *) g_hash_table_lookup(prev_map, argument->call);
|
||||
|
||||
radiobox = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 1, FALSE);
|
||||
|
||||
for (walker = g_list_first(argument->values); walker != NULL ; walker =
|
||||
walker->next) {
|
||||
v = (extcap_value *) walker->data;
|
||||
|
||||
if (last_radio == NULL) {
|
||||
last_radio = gtk_radio_button_new_with_label(NULL, v->display);
|
||||
/* Set a pointer to the first radio button */
|
||||
g_object_set_data(G_OBJECT(radiobox),
|
||||
EXTCAP_GTK_DATA_KEY_FIRSTRADIO, last_radio);
|
||||
} else {
|
||||
last_radio = gtk_radio_button_new_with_label_from_widget(
|
||||
GTK_RADIO_BUTTON(last_radio), v->display);
|
||||
}
|
||||
|
||||
/* Set a pointer to the value used in this radio */
|
||||
g_object_set_data(G_OBJECT(last_radio), EXTCAP_GTK_DATA_KEY_VALPTR, v);
|
||||
|
||||
if (prev_item != NULL) {
|
||||
if (g_ascii_strcasecmp(prev_item, v->call) == 0) {
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(last_radio),
|
||||
TRUE);
|
||||
}
|
||||
} else if (v->is_default) {
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(last_radio), TRUE);
|
||||
}
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(radiobox), last_radio, TRUE, TRUE, 0);
|
||||
gtk_widget_show(last_radio);
|
||||
}
|
||||
|
||||
return radiobox;
|
||||
}
|
||||
|
||||
static void extcap_gtk_multicheck_toggled(GtkCellRendererToggle *cell _U_,
|
||||
gchar *path_str, gpointer data) {
|
||||
GtkTreeModel *model = (GtkTreeModel *) data;
|
||||
GtkTreeIter iter;
|
||||
GtkTreePath *path = gtk_tree_path_new_from_string(path_str);
|
||||
gboolean enabled;
|
||||
|
||||
gtk_tree_model_get_iter(model, &iter, path);
|
||||
gtk_tree_model_get(model, &iter, EXTCAP_GTK_MULTI_COL_CHECK, &enabled, -1);
|
||||
|
||||
enabled ^= 1;
|
||||
|
||||
gtk_tree_store_set(GTK_TREE_STORE(model), &iter, EXTCAP_GTK_MULTI_COL_CHECK,
|
||||
enabled, -1);
|
||||
|
||||
gtk_tree_path_free(path);
|
||||
}
|
||||
|
||||
GtkWidget *extcap_create_gtk_rangewidget(extcap_arg *argument,
|
||||
GHashTable *prev_map _U_) {
|
||||
GtkWidget *spinButton;
|
||||
GtkAdjustment *adjustment;
|
||||
|
||||
gfloat def = 0.0f, min = 0.0f, max = 0.0f;
|
||||
|
||||
switch (argument->arg_type) {
|
||||
case EXTCAP_ARG_INTEGER:
|
||||
def = (gfloat) extcap_complex_get_int(argument->default_complex);
|
||||
min = (gfloat) extcap_complex_get_int(argument->range_start);
|
||||
max = (gfloat) extcap_complex_get_int(argument->range_end);
|
||||
break;
|
||||
case EXTCAP_ARG_UNSIGNED:
|
||||
def = (gfloat) extcap_complex_get_uint(argument->default_complex);
|
||||
min = (gfloat) extcap_complex_get_uint(argument->range_start);
|
||||
max = (gfloat) extcap_complex_get_uint(argument->range_end);
|
||||
break;
|
||||
case EXTCAP_ARG_LONG:
|
||||
def = (gfloat) extcap_complex_get_long(argument->default_complex);
|
||||
min = (gfloat) extcap_complex_get_long(argument->range_start);
|
||||
max = (gfloat) extcap_complex_get_long(argument->range_end);
|
||||
break;
|
||||
case EXTCAP_ARG_DOUBLE:
|
||||
def = (gfloat) extcap_complex_get_double(argument->default_complex);
|
||||
min = (gfloat) extcap_complex_get_double(argument->range_start);
|
||||
max = (gfloat) extcap_complex_get_double(argument->range_end);
|
||||
break;
|
||||
default:
|
||||
return NULL ;
|
||||
break;
|
||||
}
|
||||
|
||||
adjustment = (GtkAdjustment *)gtk_adjustment_new(def, min, max, 1.0, 10.0, 0.0);
|
||||
|
||||
spinButton = gtk_spin_button_new(adjustment, 0, 0);
|
||||
gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(spinButton), TRUE);
|
||||
gtk_widget_set_size_request(spinButton, 80, -1);
|
||||
|
||||
return spinButton;
|
||||
}
|
||||
|
||||
static void extcap_file_selectiondialog( GtkWidget *widget _U_, gpointer data )
|
||||
{
|
||||
GtkWidget * filechooser = NULL;
|
||||
GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_SAVE;
|
||||
gchar *filename = NULL;
|
||||
gint res = 0;
|
||||
extcap_arg *argument = NULL;
|
||||
|
||||
if ( GTK_ENTRY(data) == NULL )
|
||||
return;
|
||||
|
||||
argument = (extcap_arg *)g_object_get_data(G_OBJECT(data), EXTCAP_GTK_DATA_KEY_ARGUMENT);
|
||||
if ( argument != NULL && argument->fileexists == TRUE )
|
||||
action = GTK_FILE_CHOOSER_ACTION_OPEN;
|
||||
|
||||
filechooser = gtk_file_chooser_dialog_new("Select file path", NULL, action,
|
||||
"_Cancel", GTK_RESPONSE_CANCEL, "_Open", GTK_RESPONSE_ACCEPT, NULL);
|
||||
|
||||
res = gtk_dialog_run (GTK_DIALOG (filechooser));
|
||||
if (res == GTK_RESPONSE_ACCEPT)
|
||||
{
|
||||
GtkFileChooser *chooser = GTK_FILE_CHOOSER (filechooser);
|
||||
filename = gtk_file_chooser_get_filename (chooser);
|
||||
|
||||
/* this check might not be necessary, but just to be on the safe side */
|
||||
if ( action == GTK_FILE_CHOOSER_ACTION_OPEN && ! file_exists ( filename ) )
|
||||
filename = g_strdup ( " " );
|
||||
|
||||
gtk_entry_set_text(GTK_ENTRY(data), filename);
|
||||
}
|
||||
|
||||
gtk_widget_destroy (filechooser);
|
||||
}
|
||||
|
||||
static GtkWidget *extcap_create_gtk_fileselect(extcap_arg *argument,
|
||||
GHashTable *prev_map _U_, gchar * file _U_) {
|
||||
GtkWidget * entry = NULL;
|
||||
GtkWidget * button = NULL;
|
||||
GtkWidget * ret_box = NULL;
|
||||
|
||||
button = gtk_button_new_with_label ("...");
|
||||
entry = gtk_entry_new();
|
||||
if (file != NULL)
|
||||
gtk_entry_set_text(GTK_ENTRY(entry), file);
|
||||
gtk_editable_set_editable (GTK_EDITABLE (entry), FALSE);
|
||||
g_object_set_data(G_OBJECT(entry), EXTCAP_GTK_DATA_KEY_ARGUMENT, argument);
|
||||
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
ret_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3);
|
||||
#else
|
||||
ret_box = ws_gtk_hbox_new(FALSE, 3);
|
||||
#endif
|
||||
|
||||
gtk_box_pack_start ( GTK_BOX(ret_box), entry, TRUE, TRUE, 5 );
|
||||
gtk_widget_show(entry);
|
||||
gtk_box_pack_end ( GTK_BOX(ret_box), button, FALSE, FALSE, 5 );
|
||||
gtk_widget_show(button);
|
||||
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (extcap_file_selectiondialog), (gpointer) entry);
|
||||
|
||||
g_object_set_data(G_OBJECT(ret_box), EXTCAP_GTK_DATA_KEY_FILENAME, entry);
|
||||
|
||||
return ret_box;
|
||||
}
|
||||
|
||||
GtkWidget *extcap_create_gtk_multicheckwidget(extcap_arg *argument,
|
||||
GHashTable *prev_map) {
|
||||
GtkCellRenderer *renderer, *togglerenderer;
|
||||
GtkTreeModel *model;
|
||||
GtkWidget *view, *retview;
|
||||
GtkTreeStore *store;
|
||||
GtkTreeIter iter;
|
||||
GtkTreeSelection *selection;
|
||||
extcap_value *v = NULL;
|
||||
GList * walker = NULL;
|
||||
gchar *prev_item = NULL;
|
||||
gchar **prev_list = NULL, **prev_iter = NULL;
|
||||
gboolean prev_value, prev_matched;
|
||||
extcap_gtk_multi_find_cb_data find_data;
|
||||
|
||||
if (g_list_length(argument->values) == 0)
|
||||
return NULL ;
|
||||
|
||||
view = gtk_tree_view_new();
|
||||
|
||||
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
|
||||
|
||||
store = gtk_tree_store_new(EXTCAP_GTK_MULTI_NUM_COLS, G_TYPE_BOOLEAN,
|
||||
G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN);
|
||||
|
||||
model = GTK_TREE_MODEL(store);
|
||||
gtk_tree_view_set_model(GTK_TREE_VIEW(view), model);
|
||||
gtk_tree_selection_set_mode(selection, GTK_SELECTION_NONE);
|
||||
|
||||
if (prev_map != NULL)
|
||||
prev_item = (gchar *) g_hash_table_lookup(prev_map, argument->call);
|
||||
|
||||
if (prev_item != NULL)
|
||||
prev_list = g_strsplit(prev_item, ",", 0);
|
||||
|
||||
for (walker = g_list_first(argument->values); walker != NULL ; walker =
|
||||
walker->next) {
|
||||
v = (extcap_value *) walker->data;
|
||||
if (v->display == NULL)
|
||||
break;
|
||||
|
||||
find_data.parent = v->parent;
|
||||
find_data.parent_iter = NULL;
|
||||
|
||||
if (find_data.parent != NULL)
|
||||
{
|
||||
gtk_tree_model_foreach(model, extcap_gtk_find_parent_in_multi_list,
|
||||
&find_data);
|
||||
if (find_data.parent_iter == NULL)
|
||||
{
|
||||
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG,
|
||||
"Extcap parent %s not found for value %s (%s)",
|
||||
v->parent, v->call, argument->call);
|
||||
}
|
||||
}
|
||||
|
||||
prev_value = FALSE;
|
||||
gtk_tree_store_append(store, &iter, find_data.parent_iter);
|
||||
|
||||
if (find_data.parent_iter != NULL)
|
||||
{
|
||||
gtk_tree_iter_free(find_data.parent_iter);
|
||||
find_data.parent_iter = NULL;
|
||||
}
|
||||
|
||||
if (prev_list != NULL) {
|
||||
prev_matched = FALSE;
|
||||
prev_iter = prev_list;
|
||||
|
||||
while (*prev_iter != NULL ) {
|
||||
if (g_strcmp0(*prev_iter, v->call) == 0) {
|
||||
prev_matched = TRUE;
|
||||
prev_value = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
prev_iter++;
|
||||
}
|
||||
|
||||
if (prev_matched == FALSE)
|
||||
prev_value = v->enabled;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Use default value if there is no information about previously selected items. */
|
||||
prev_value = v->is_default;
|
||||
}
|
||||
|
||||
|
||||
/* v->is_default is set when there was {default=true} for this value. */
|
||||
/* v->enabled is false for non-clickable tree items ({enabled=false}). */
|
||||
gtk_tree_store_set(store, &iter, EXTCAP_GTK_MULTI_COL_CHECK, prev_value,
|
||||
EXTCAP_GTK_MULTI_COL_DISPLAY, v->display,
|
||||
EXTCAP_GTK_MULTI_COL_VALUE, v,
|
||||
EXTCAP_GTK_MULTI_COL_ACTIVATABLE, v->enabled, -1);
|
||||
}
|
||||
|
||||
g_strfreev(prev_list);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
togglerenderer = gtk_cell_renderer_toggle_new();
|
||||
g_signal_connect(togglerenderer, "toggled",
|
||||
G_CALLBACK(extcap_gtk_multicheck_toggled), model);
|
||||
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), -1,
|
||||
"Enabled", togglerenderer, "active", EXTCAP_GTK_MULTI_COL_CHECK,
|
||||
"activatable", EXTCAP_GTK_MULTI_COL_ACTIVATABLE,
|
||||
"visible", EXTCAP_GTK_MULTI_COL_ACTIVATABLE,
|
||||
NULL);
|
||||
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), -1, "Name",
|
||||
renderer, "text", EXTCAP_GTK_MULTI_COL_DISPLAY,
|
||||
NULL);
|
||||
|
||||
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);
|
||||
|
||||
retview = extcap_gtk_wrap_scroll_treeview(view);
|
||||
|
||||
if (gtk_tree_model_iter_n_children(model, NULL) > 3)
|
||||
gtk_widget_set_size_request(retview, 0, 100);
|
||||
|
||||
/* Tree view has own reference */
|
||||
g_object_unref(model);
|
||||
|
||||
return retview;
|
||||
}
|
||||
|
||||
void extcap_gtk_free_args(GtkWidget *vbox) {
|
||||
GList *arguments = (GList *) g_object_get_data(G_OBJECT(vbox),
|
||||
EXTCAP_GTK_DATA_KEY_ARGPTR);
|
||||
extcap_free_arg_list(arguments);
|
||||
g_object_set_data(G_OBJECT(vbox), EXTCAP_GTK_DATA_KEY_ARGPTR, NULL);
|
||||
}
|
||||
|
||||
GSList *extcap_populate_gtk_vbox(GList *arguments, GtkWidget *vbox,
|
||||
GHashTable *prev_map) {
|
||||
GSList *widget_toplist = NULL;
|
||||
|
||||
extcap_arg *arg_iter = NULL;
|
||||
|
||||
extcap_complex *prev_complex = NULL;
|
||||
gchar *prev_call = NULL, *default_str;
|
||||
|
||||
GList * arg_list = g_list_first(arguments);
|
||||
if ( arg_list == NULL )
|
||||
return NULL;
|
||||
|
||||
g_object_set_data(G_OBJECT(vbox), EXTCAP_GTK_DATA_KEY_ARGPTR, arguments);
|
||||
|
||||
while (arg_list != NULL ) {
|
||||
GtkWidget *hbox = NULL, *label = NULL, *item = NULL;
|
||||
|
||||
arg_iter = (extcap_arg*) (arg_list->data);
|
||||
|
||||
/* A new storage box for label + element */
|
||||
|
||||
hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5, FALSE);
|
||||
|
||||
if (prev_map != NULL
|
||||
&& (prev_call = (gchar *) g_hash_table_lookup(prev_map,
|
||||
arg_iter->call)) != NULL) {
|
||||
prev_complex = extcap_parse_complex(arg_iter->arg_type, prev_call);
|
||||
} else {
|
||||
prev_complex = NULL;
|
||||
}
|
||||
|
||||
switch (arg_iter->arg_type) {
|
||||
case EXTCAP_ARG_INTEGER:
|
||||
case EXTCAP_ARG_UNSIGNED:
|
||||
case EXTCAP_ARG_LONG:
|
||||
case EXTCAP_ARG_DOUBLE:
|
||||
label = gtk_label_new(arg_iter->display);
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.1f);
|
||||
item = extcap_create_gtk_rangewidget(arg_iter, prev_map);
|
||||
if (item == NULL) {
|
||||
item = gtk_entry_new();
|
||||
|
||||
if (prev_complex != NULL) {
|
||||
default_str = extcap_get_complex_as_string(prev_complex);
|
||||
gtk_entry_set_text(GTK_ENTRY(item), default_str);
|
||||
g_free(default_str);
|
||||
} else if (arg_iter->default_complex != NULL) {
|
||||
default_str = extcap_get_complex_as_string(
|
||||
arg_iter->default_complex);
|
||||
gtk_entry_set_text(GTK_ENTRY(item), default_str);
|
||||
g_free(default_str);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EXTCAP_ARG_STRING:
|
||||
case EXTCAP_ARG_PASSWORD:
|
||||
label = gtk_label_new(arg_iter->display);
|
||||
|
||||
item = gtk_entry_new();
|
||||
default_str = NULL;
|
||||
|
||||
if (prev_complex != NULL)
|
||||
default_str = extcap_get_complex_as_string(prev_complex);
|
||||
else if (arg_iter->default_complex != NULL)
|
||||
default_str = extcap_get_complex_as_string(
|
||||
arg_iter->default_complex);
|
||||
|
||||
if (default_str != NULL) {
|
||||
gtk_entry_set_text(GTK_ENTRY(item), default_str);
|
||||
g_free(default_str);
|
||||
}
|
||||
|
||||
if ( arg_iter->arg_type == EXTCAP_ARG_PASSWORD)
|
||||
gtk_entry_set_visibility(GTK_ENTRY(item), FALSE);
|
||||
|
||||
break;
|
||||
case EXTCAP_ARG_FILESELECT:
|
||||
label = gtk_label_new(arg_iter->display);
|
||||
default_str = NULL;
|
||||
|
||||
if (prev_complex != NULL)
|
||||
default_str = extcap_get_complex_as_string(prev_complex);
|
||||
else if (arg_iter->default_complex != NULL)
|
||||
default_str = extcap_get_complex_as_string(
|
||||
arg_iter->default_complex);
|
||||
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.1f);
|
||||
item = extcap_create_gtk_fileselect(arg_iter, prev_map, default_str);
|
||||
g_free(default_str);
|
||||
break;
|
||||
case EXTCAP_ARG_TIMESTAMP:
|
||||
default_str = NULL;
|
||||
if (prev_complex != NULL)
|
||||
default_str = extcap_get_complex_as_string(prev_complex);
|
||||
else if (arg_iter->default_complex != NULL)
|
||||
default_str = extcap_get_complex_as_string(
|
||||
arg_iter->default_complex);
|
||||
label = gtk_label_new(arg_iter->display);
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.1f);
|
||||
if (default_str != NULL) {
|
||||
gtk_entry_set_text(GTK_ENTRY(item), default_str);
|
||||
g_free(default_str);
|
||||
}
|
||||
|
||||
item = gtk_calendar_new();
|
||||
break;
|
||||
case EXTCAP_ARG_BOOLEAN:
|
||||
case EXTCAP_ARG_BOOLFLAG:
|
||||
item = gtk_check_button_new_with_label(arg_iter->display);
|
||||
|
||||
if (prev_complex != NULL) {
|
||||
if (extcap_complex_get_bool(prev_complex))
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(item), TRUE);
|
||||
} else if (arg_iter->default_complex != NULL
|
||||
&& extcap_complex_get_bool(arg_iter->default_complex)) {
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(item), TRUE);
|
||||
}
|
||||
|
||||
break;
|
||||
case EXTCAP_ARG_RADIO:
|
||||
label = gtk_label_new(arg_iter->display);
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.1f);
|
||||
item = extcap_create_gtk_radiowidget(arg_iter, prev_map);
|
||||
break;
|
||||
case EXTCAP_ARG_SELECTOR:
|
||||
label = gtk_label_new(arg_iter->display);
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.1f);
|
||||
item = extcap_create_gtk_listwidget(arg_iter, prev_map);
|
||||
break;
|
||||
case EXTCAP_ARG_MULTICHECK:
|
||||
label = gtk_label_new(arg_iter->display);
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.1f);
|
||||
item = extcap_create_gtk_multicheckwidget(arg_iter, prev_map);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (prev_complex != NULL)
|
||||
extcap_free_complex(prev_complex);
|
||||
|
||||
if (label != NULL) {
|
||||
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
|
||||
gtk_widget_show(label);
|
||||
}
|
||||
|
||||
if (item != NULL) {
|
||||
gtk_box_pack_start(GTK_BOX(hbox), item, TRUE, TRUE, 0);
|
||||
gtk_widget_show(item);
|
||||
g_object_set_data(G_OBJECT(item), EXTCAP_GTK_DATA_KEY_ARGPTR,
|
||||
arg_iter);
|
||||
|
||||
if (arg_iter->tooltip != NULL) {
|
||||
gtk_widget_set_tooltip_text(item, arg_iter->tooltip);
|
||||
}
|
||||
|
||||
widget_toplist = g_slist_append(widget_toplist, item);
|
||||
}
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 1);
|
||||
|
||||
gtk_widget_show(hbox);
|
||||
|
||||
arg_list = arg_list->next;
|
||||
}
|
||||
|
||||
return widget_toplist;
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
||||
* :indentSize=4:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -1,125 +0,0 @@
|
|||
/* extcap_gtk.c
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __EXTCAP_GTK_H__
|
||||
#define __EXTCAP_GTK_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <extcap_parser.h>
|
||||
|
||||
/*
|
||||
* GObject data keys for linking argument records to the gtk
|
||||
* UI
|
||||
*/
|
||||
#define EXTCAP_GTK_DATA_KEY_ARGPTR "EXTCAP_ARGPTR"
|
||||
#define EXTCAP_GTK_DATA_KEY_VALPTR "EXTCAP_VALPTR"
|
||||
#define EXTCAP_GTK_DATA_KEY_FIRSTRADIO "EXTCAP_FIRSTRADIO"
|
||||
#define EXTCAP_GTK_DATA_KEY_WIDGETLIST "EXTCAP_WIDGETLIST"
|
||||
#define EXTCAP_GTK_DATA_KEY_TREEVIEW "EXTCAP_TREEVIEW"
|
||||
#define EXTCAP_GTK_DATA_KEY_FILENAME "EXTCAP_FILENAME"
|
||||
#define EXTCAP_GTK_DATA_KEY_TIMESTAMP "EXTCAP_TIMESTAMP"
|
||||
#define EXTCAP_GTK_DATA_KEY_ARGUMENT "EXTCAP_ARGUMENT"
|
||||
|
||||
/*
|
||||
* GTK UI / EXTCAP Linkage:
|
||||
*
|
||||
* Packed vbox of widgets
|
||||
* Contains EXTCAP_WIDGETLIST pointing to enclosed widget list
|
||||
*
|
||||
* GSList gtk_ui_widgets
|
||||
* Linked list of drawable widgets in the UI
|
||||
*
|
||||
* GtkWidget contained in GSList
|
||||
* Drawn GTK UI element. If UI element is directly linked
|
||||
* to argument, will contain EXTCAP_ARGPTR.
|
||||
*
|
||||
* Top-level GTK widgets will include text boxes, sliders
|
||||
* (if supported), and checkboxes.
|
||||
*
|
||||
* If the top level widget contains radio buttons, it will
|
||||
* contain an EXTCAP_ARGPTR *and* an EXTCAP_FIRSTRADIO
|
||||
*
|
||||
* Radio buttons
|
||||
* Each radio button will contain an EXTCAP_VALPTR reference
|
||||
* to the extcap_value * value being used.
|
||||
*
|
||||
* Selectors
|
||||
* Each selector row contains a pointer to the value, in the
|
||||
* column COL_VALUE
|
||||
*
|
||||
*/
|
||||
|
||||
enum extcap_gtk_col_types {
|
||||
EXTCAP_GTK_COL_DISPLAY = 0, EXTCAP_GTK_COL_VALUE = 1, EXTCAP_GTK_NUM_COLS
|
||||
};
|
||||
|
||||
enum extcap_gtk_multi_col_types {
|
||||
EXTCAP_GTK_MULTI_COL_CHECK = 0,
|
||||
EXTCAP_GTK_MULTI_COL_DISPLAY = 1,
|
||||
EXTCAP_GTK_MULTI_COL_VALUE = 2,
|
||||
EXTCAP_GTK_MULTI_COL_ACTIVATABLE = 3,
|
||||
EXTCAP_GTK_MULTI_NUM_COLS
|
||||
};
|
||||
|
||||
/* Get a hash map of calls and values from the top widget */
|
||||
GHashTable *extcap_gtk_get_state(GtkWidget *widget);
|
||||
|
||||
GtkWidget *extcap_create_gtk_rangewidget(extcap_arg *argument,
|
||||
GHashTable *prev_map);
|
||||
GtkWidget *extcap_create_gtk_listwidget(extcap_arg *argument,
|
||||
GHashTable *prev_map);
|
||||
GtkWidget *extcap_create_gtk_radiowidget(extcap_arg *argument,
|
||||
GHashTable *prev_map);
|
||||
GtkWidget *extcap_create_gtk_multicheckwidget(extcap_arg *argument,
|
||||
GHashTable *prev_map);
|
||||
|
||||
/*
|
||||
* Populate a (pre-created) container widget based on an arguments record.
|
||||
* For secondary repopulations, a saved state can be passed to populate
|
||||
* with known values. This should occur when setting interface options
|
||||
* repeatedly, for example
|
||||
*/
|
||||
GSList *extcap_populate_gtk_vbox(GList *arguments, GtkWidget *vbox,
|
||||
GHashTable *prev_map);
|
||||
|
||||
/* Free args associated with a GTK item */
|
||||
void extcap_gtk_free_args(GtkWidget *vbox);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
||||
* :indentSize=4:tabSize=8:noTabs=true:
|
||||
*/
|
||||
|
|
@ -1,474 +0,0 @@
|
|||
/* file_dlg.c
|
||||
* Utilities to use when constructing file selection dialogs
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Code to handle Windows shortcuts courtesy of:
|
||||
*
|
||||
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
|
||||
* Copyright (C) 1999-2012 Hiroyuki Yamamoto
|
||||
*
|
||||
* licensed under the GPL2 or later.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# define COBJMACROS
|
||||
# include <windows.h>
|
||||
# include <objbase.h>
|
||||
# include <objidl.h>
|
||||
# include <shlobj.h>
|
||||
#endif
|
||||
|
||||
#include <wsutil/file_util.h>
|
||||
|
||||
#include <wsutil/filesystem.h>
|
||||
|
||||
#include "ui/last_open_dir.h"
|
||||
#include "ui/util.h"
|
||||
|
||||
#include "ui/gtk/gtkglobals.h"
|
||||
#include "ui/gtk/gui_utils.h"
|
||||
#include "ui/gtk/file_dlg.h"
|
||||
#include "ui/gtk/keys.h"
|
||||
#include "ui/gtk/stock_icons.h"
|
||||
|
||||
|
||||
static gchar *last_open_dir = NULL;
|
||||
|
||||
static void file_selection_browse_destroy_cb(GtkWidget *win, GtkWidget* file_te);
|
||||
|
||||
/* Keys ... */
|
||||
#define E_FS_CALLER_PTR_KEY "fs_caller_ptr"
|
||||
|
||||
/* Create a file selection dialog box window that belongs to a top-level
|
||||
window. */
|
||||
GtkWidget *
|
||||
file_selection_new(const gchar *title, GtkWindow *parent,
|
||||
file_selection_action_t action)
|
||||
{
|
||||
GtkWidget *win;
|
||||
GtkFileChooserAction gtk_action;
|
||||
const gchar *ok_button_text;
|
||||
|
||||
switch (action) {
|
||||
|
||||
case FILE_SELECTION_OPEN:
|
||||
gtk_action = GTK_FILE_CHOOSER_ACTION_OPEN;
|
||||
ok_button_text = GTK_STOCK_OPEN;
|
||||
break;
|
||||
|
||||
case FILE_SELECTION_READ_BROWSE:
|
||||
gtk_action = GTK_FILE_CHOOSER_ACTION_OPEN;
|
||||
ok_button_text = GTK_STOCK_OK;
|
||||
break;
|
||||
|
||||
case FILE_SELECTION_SAVE:
|
||||
gtk_action = GTK_FILE_CHOOSER_ACTION_SAVE;
|
||||
ok_button_text = WIRESHARK_STOCK_SAVE;
|
||||
break;
|
||||
|
||||
case FILE_SELECTION_WRITE_BROWSE:
|
||||
gtk_action = GTK_FILE_CHOOSER_ACTION_SAVE;
|
||||
ok_button_text = GTK_STOCK_OK;
|
||||
break;
|
||||
|
||||
case FILE_SELECTION_CREATE_FOLDER:
|
||||
gtk_action = GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER;
|
||||
ok_button_text = GTK_STOCK_OK;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
gtk_action = (GtkFileChooserAction)-1;
|
||||
ok_button_text = NULL;
|
||||
break;
|
||||
}
|
||||
win = gtk_file_chooser_dialog_new(title, parent, gtk_action,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
ok_button_text, GTK_RESPONSE_ACCEPT,
|
||||
NULL);
|
||||
gtk_dialog_set_alternative_button_order(GTK_DIALOG(win),
|
||||
GTK_RESPONSE_ACCEPT,
|
||||
GTK_RESPONSE_CANCEL,
|
||||
-1);
|
||||
if (action == FILE_SELECTION_SAVE)
|
||||
gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(win), TRUE);
|
||||
|
||||
/* If we've opened a file before, start out by showing the files in the directory
|
||||
in which that file resided. */
|
||||
if (last_open_dir) {
|
||||
file_selection_set_current_folder(win, last_open_dir);
|
||||
}
|
||||
return win;
|
||||
}
|
||||
|
||||
/* Set the current folder for a file selection dialog. */
|
||||
gboolean
|
||||
file_selection_set_current_folder(GtkWidget *fs, const gchar *filename)
|
||||
{
|
||||
gboolean ret;
|
||||
size_t filename_len = strlen(filename);
|
||||
gchar *new_filename;
|
||||
|
||||
/* trim filename, so gtk_file_chooser_set_current_folder() likes it, see below */
|
||||
if (filename[filename_len -1] == G_DIR_SEPARATOR
|
||||
#ifdef _WIN32
|
||||
&& filename_len > 3) /* e.g. "D:\" */
|
||||
#else
|
||||
&& filename_len > 1) /* e.g. "/" */
|
||||
#endif
|
||||
{
|
||||
new_filename = g_strdup(filename);
|
||||
new_filename[filename_len-1] = '\0';
|
||||
} else {
|
||||
new_filename = g_strdup(filename);
|
||||
}
|
||||
|
||||
/* this function is very pedantic about its filename parameter */
|
||||
/* no trailing '\' allowed, unless a win32 root dir "D:\" */
|
||||
ret = gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(fs), new_filename);
|
||||
g_free(new_filename);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Set the "extra" widget for a file selection dialog, with user-supplied
|
||||
options. */
|
||||
void
|
||||
file_selection_set_extra_widget(GtkWidget *fs, GtkWidget *extra)
|
||||
{
|
||||
gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(fs), extra);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
static gchar *filesel_get_link(const gchar *link_file)
|
||||
{
|
||||
WIN32_FIND_DATAW wfd;
|
||||
IShellLinkW *psl;
|
||||
IPersistFile *ppf;
|
||||
wchar_t *wlink_file;
|
||||
wchar_t wtarget[MAX_PATH];
|
||||
gchar *target = NULL;
|
||||
|
||||
wtarget[0] = 0L;
|
||||
|
||||
CoInitialize(NULL);
|
||||
if (S_OK == CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
|
||||
&IID_IShellLinkW, (void **)&psl)) {
|
||||
if (S_OK == IShellLinkW_QueryInterface(psl, &IID_IPersistFile,
|
||||
(void **)&ppf)) {
|
||||
wlink_file = g_utf8_to_utf16(link_file, -1, NULL, NULL, NULL);
|
||||
if (S_OK == IPersistFile_Load(ppf, wlink_file, STGM_READ)) {
|
||||
if (S_OK == IShellLinkW_GetPath(psl, wtarget, MAX_PATH, &wfd,
|
||||
SLGP_UNCPRIORITY)) {
|
||||
target = g_utf16_to_utf8(wtarget, -1, NULL, NULL, NULL);
|
||||
}
|
||||
}
|
||||
IPersistFile_Release(ppf);
|
||||
g_free(wlink_file);
|
||||
}
|
||||
IShellLinkW_Release(psl);
|
||||
}
|
||||
CoUninitialize();
|
||||
|
||||
return target;
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/* Run the dialog, and handle some common operations, such as, if the
|
||||
user selects a directory, browsing that directory, and handling
|
||||
shortcuts on Windows.
|
||||
|
||||
Returns NULL if the user decided not to open/write to a file,
|
||||
returns the pathname of the selected file if they selected a
|
||||
file. */
|
||||
gchar *
|
||||
file_selection_run(GtkWidget *fs)
|
||||
{
|
||||
gchar *cf_name;
|
||||
#ifdef _WIN32
|
||||
gchar *target;
|
||||
const gchar *ext;
|
||||
#endif
|
||||
|
||||
for (;;) {
|
||||
if (gtk_dialog_run(GTK_DIALOG(fs)) != GTK_RESPONSE_ACCEPT) {
|
||||
/* They clicked "Cancel" or closed the dialog or...;
|
||||
destroy the dialog and tell our caller the user decided
|
||||
not to do anything with the file. */
|
||||
window_destroy(fs);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cf_name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fs));
|
||||
|
||||
/* Perhaps the user specified a directory instead of a file.
|
||||
Check whether they did. */
|
||||
if (test_for_directory(cf_name) == EISDIR) {
|
||||
/* It's a directory - set the file selection box to display that
|
||||
directory, and go back and re-run it; don't try to open the
|
||||
directory as a file (you'll get crap if you get anything) or
|
||||
write to it (which won't work anyway). */
|
||||
set_last_open_dir(cf_name);
|
||||
g_free(cf_name);
|
||||
file_selection_set_current_folder(fs, get_last_open_dir());
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
/* Perhaps the user specified a "shortcut" instead of a file.
|
||||
Check whether they did. */
|
||||
if ((ext = strrchr(cf_name, '.')) && g_ascii_strcasecmp(ext, ".lnk") == 0) {
|
||||
/* It ends with ".lnk", so it might be a shortcut. */
|
||||
target = filesel_get_link(cf_name);
|
||||
if (target != NULL) {
|
||||
/* We resolved it, so it must've been a shortcut. */
|
||||
g_free(cf_name);
|
||||
if (test_for_directory(target)) {
|
||||
/* It's a shortcut that points to a directory; treat it the same
|
||||
way we treat a directory. */
|
||||
set_last_open_dir(target);
|
||||
g_free(target);
|
||||
file_selection_set_current_folder(fs, get_last_open_dir());
|
||||
continue;
|
||||
}
|
||||
/* It's a shortcut that points to a file; act as if the target
|
||||
is what's selected. */
|
||||
cf_name = target;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
return cf_name;
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
/* If the specified file doesn't exist, return TRUE.
|
||||
If it exists and is neither user-immutable nor not writable, return
|
||||
TRUE.
|
||||
Otherwise, as the user whether they want to overwrite it anyway, and
|
||||
return TRUE if the file should be overwritten and FALSE otherwise. */
|
||||
gboolean
|
||||
file_target_unwritable_ui(GtkWidget *chooser_w, char *cf_name)
|
||||
{
|
||||
GtkWidget *msg_dialog;
|
||||
gchar *display_basename;
|
||||
gint response;
|
||||
ws_statb64 statbuf;
|
||||
|
||||
/* Check whether the file has all the write permission bits clear
|
||||
and, on systems that have the 4.4-Lite file flags, whether it
|
||||
has the "user immutable" flag set. Treat both of those as an
|
||||
indication that the user wants to protect the file from
|
||||
casual overwriting, and ask the user if they want to override
|
||||
that.
|
||||
|
||||
(Linux's "immutable" flag, as fetched and set by the appropriate
|
||||
ioctls (FS_IOC_GETFLAGS/FS_IOC_SETFLAGS in newer kernels,
|
||||
EXT2_IOC_GETFLAGS/EXT2_IOC_SETFLAGS in older kernels - non-ext2
|
||||
file systems that support those ioctls use the same values as ext2
|
||||
does), appears to be more like the *BSD/macOS "system immutable"
|
||||
flag, as it can be set only by the superuser or by processes with
|
||||
CAP_LINUX_IMMUTABLE, so it sounds as if it's not intended for
|
||||
arbitrary users to set or clear. */
|
||||
if (ws_stat64(cf_name, &statbuf) == -1) {
|
||||
/* Either the file doesn't exist or we can't get its attributes.
|
||||
In the former case, we have no reason to bother the user.
|
||||
In the latter case, we don't have enough information to
|
||||
know whether to bother the user, so we don't. */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* OK, we have the permission bits and, if HAVE_STRUCT_STAT_ST_FLAGS
|
||||
is defined, the flags. (If we don't, we don't worry about it.) */
|
||||
#ifdef HAVE_STRUCT_STAT_ST_FLAGS
|
||||
if (statbuf.st_flags & UF_IMMUTABLE) {
|
||||
display_basename = g_filename_display_basename(cf_name);
|
||||
msg_dialog = gtk_message_dialog_new(GTK_WINDOW(chooser_w),
|
||||
(GtkDialogFlags)(GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT),
|
||||
GTK_MESSAGE_QUESTION,
|
||||
GTK_BUTTONS_NONE,
|
||||
#ifdef __APPLE__
|
||||
/* Stuff in the macOS UI calls files with the "user immutable" bit
|
||||
"locked"; the classic Mac OS might have had that notion and
|
||||
called it "locked". */
|
||||
"The file \"%s\" is locked.",
|
||||
#else /* __APPLE__ */
|
||||
/* Just call it "immutable" in *BSD. */
|
||||
"The file \"%s\" is immutable.",
|
||||
#endif /* __APPLE__ */
|
||||
display_basename);
|
||||
g_free(display_basename);
|
||||
} else
|
||||
#endif /* HAVE_STRUCT_STAT_ST_FLAGS */
|
||||
if ((statbuf.st_mode & (S_IWUSR|S_IWGRP|S_IWOTH)) == 0) {
|
||||
display_basename = g_filename_display_basename(cf_name);
|
||||
msg_dialog = gtk_message_dialog_new(GTK_WINDOW(chooser_w),
|
||||
(GtkDialogFlags)(GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT),
|
||||
GTK_MESSAGE_QUESTION,
|
||||
GTK_BUTTONS_NONE,
|
||||
"The file \"%s\" is read-only.",
|
||||
display_basename);
|
||||
g_free(display_basename);
|
||||
} else {
|
||||
/* No problem, just drive on. */
|
||||
msg_dialog = NULL;
|
||||
}
|
||||
if (msg_dialog != NULL) {
|
||||
/* OK, ask the user if they want to overwrite the file. */
|
||||
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(msg_dialog),
|
||||
"Do you want to overwrite it anyway?");
|
||||
|
||||
gtk_dialog_add_buttons(GTK_DIALOG(msg_dialog),
|
||||
"Overwrite", GTK_RESPONSE_ACCEPT,
|
||||
"Don't overwrite", GTK_RESPONSE_REJECT,
|
||||
NULL);
|
||||
gtk_dialog_set_default_response(GTK_DIALOG(msg_dialog), GTK_RESPONSE_REJECT);
|
||||
|
||||
response = gtk_dialog_run(GTK_DIALOG(msg_dialog));
|
||||
gtk_widget_destroy(msg_dialog);
|
||||
|
||||
if (response != GTK_RESPONSE_ACCEPT) {
|
||||
/* The user doesn't want to overwrite this file. */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef HAVE_STRUCT_STAT_ST_FLAGS
|
||||
/* OK, they want to overwrite the file. If it has the "user
|
||||
immutable" flag, we have to turn that off first, so we
|
||||
can move on top of, or overwrite, the file. */
|
||||
if (statbuf.st_flags & UF_IMMUTABLE) {
|
||||
/* If this fails, the attempt to save will fail, so just
|
||||
let that happen and pop up a "you lose" dialog. */
|
||||
chflags(cf_name, statbuf.st_flags & ~UF_IMMUTABLE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* A generic select_file routine that is intended to be connected to
|
||||
* a Browse button on other dialog boxes. This allows the user to browse
|
||||
* for a file and select it. We fill in the text_entry that is given to us.
|
||||
*
|
||||
* We display the window label specified in our args.
|
||||
*/
|
||||
void
|
||||
file_selection_browse(GtkWidget *file_bt, GtkWidget *file_te, const char *label, file_selection_action_t action)
|
||||
{
|
||||
GtkWidget *caller = gtk_widget_get_toplevel(file_bt);
|
||||
GtkWidget *fs;
|
||||
gchar *f_name;
|
||||
|
||||
fs = file_selection_new(label, GTK_WINDOW(caller), action);
|
||||
|
||||
g_object_set_data(G_OBJECT(fs), PRINT_FILE_TE_KEY, file_te);
|
||||
|
||||
/* Set the E_FS_CALLER_PTR_KEY for the new dialog to point to our caller. */
|
||||
g_object_set_data(G_OBJECT(fs), E_FS_CALLER_PTR_KEY, caller);
|
||||
|
||||
/* Set the E_FILE_SEL_DIALOG_PTR_KEY for the caller to point to us */
|
||||
g_object_set_data(G_OBJECT(caller), E_FILE_SEL_DIALOG_PTR_KEY, fs);
|
||||
|
||||
/* Call a handler when the file selection box is destroyed, so we can inform
|
||||
our caller, if any, that it's been destroyed. */
|
||||
g_signal_connect(fs, "destroy", G_CALLBACK(file_selection_browse_destroy_cb),
|
||||
file_te);
|
||||
|
||||
if (gtk_dialog_run(GTK_DIALOG(fs)) == GTK_RESPONSE_ACCEPT)
|
||||
{
|
||||
f_name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fs));
|
||||
gtk_entry_set_text(GTK_ENTRY(file_te), f_name);
|
||||
g_free(f_name);
|
||||
}
|
||||
window_destroy(fs);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
file_selection_browse_destroy_cb(GtkWidget *win, GtkWidget* parent_te)
|
||||
{
|
||||
GtkWidget *caller;
|
||||
|
||||
/* Get the widget that requested that we be popped up.
|
||||
(It should arrange to destroy us if it's destroyed, so
|
||||
that we don't get a pointer to a non-existent window here.) */
|
||||
caller = (GtkWidget *)g_object_get_data(G_OBJECT(win), E_FS_CALLER_PTR_KEY);
|
||||
|
||||
/* Tell it we no longer exist. */
|
||||
g_object_set_data(G_OBJECT(caller), E_FILE_SEL_DIALOG_PTR_KEY, NULL);
|
||||
|
||||
/* Give the focus to the file text entry widget so the user can just press
|
||||
Return to print to the file. */
|
||||
gtk_widget_grab_focus(parent_te);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
set_last_open_dir(const char *dirname)
|
||||
{
|
||||
size_t len;
|
||||
gchar *new_last_open_dir;
|
||||
|
||||
if (dirname && dirname[0]) {
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
new_last_open_dir = NULL;
|
||||
}
|
||||
|
||||
g_free(last_open_dir);
|
||||
last_open_dir = new_last_open_dir;
|
||||
}
|
||||
|
||||
char *
|
||||
get_last_open_dir(void)
|
||||
{
|
||||
return last_open_dir;
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
||||
* :indentSize=4:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -1,133 +0,0 @@
|
|||
/* file_dlg.h
|
||||
* Declarations of utilities to use when constructing file selection dialogs
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/** @defgroup filesel_dialog_group File Selection Dialogs
|
||||
*
|
||||
* Dialogs are specially created windows and are related to their parent windows (usually the main window).
|
||||
* See: @ref howto_window_page for details.
|
||||
*
|
||||
* File selection dialogs are created using file_selection_new().
|
||||
*
|
||||
* - "Browse" file_selection_browse()
|
||||
* - "Open Capture File" file_open_cmd()
|
||||
* - "Save Capture File As" file_save_as_cmd()
|
||||
* - "Import Color Filters" file_color_import_cmd_cb()
|
||||
* - "Export Color Filters" file_color_export_cmd_cb()
|
||||
* - "Save TCP Follow Stream As" follow_save_as_cmd_cb()
|
||||
* - "Export Selected Packet Bytes" savehex_cb()
|
||||
* - "Save Data As CSV" save_csv_as_cb()
|
||||
* - "Save Payload As ..." on_save_bt_clicked()
|
||||
* - "Save selected stream in rtpdump" rtpstream_on_save()
|
||||
*
|
||||
*/
|
||||
|
||||
/** @file
|
||||
* Utilities for file selection dialog boxes. Depending on the window
|
||||
* functions in gui_utils.h, see: @ref howto_window_page for details.
|
||||
* @ingroup filesel_dialog_group
|
||||
*/
|
||||
|
||||
#ifndef __FILE_DLG_H__
|
||||
#define __FILE_DLG_H__
|
||||
|
||||
/** the action a file selection is designed for */
|
||||
typedef enum {
|
||||
FILE_SELECTION_OPEN, /**< open a file */
|
||||
FILE_SELECTION_READ_BROWSE, /**< browse for a file to read */
|
||||
FILE_SELECTION_SAVE, /**< save/export a file */
|
||||
FILE_SELECTION_WRITE_BROWSE, /**< browse for a file to write to */
|
||||
FILE_SELECTION_CREATE_FOLDER /**< browse for a dir. to save in */
|
||||
} file_selection_action_t;
|
||||
|
||||
/** Create a file selection dialog box window that belongs to a top-level
|
||||
* window. See window_new() for usage.
|
||||
*
|
||||
* @param title the title for the new file selection dialog
|
||||
* @param parent the top-level window
|
||||
* @param action the desired action
|
||||
* @return the newly created file selection dialog
|
||||
*/
|
||||
extern GtkWidget *file_selection_new(const gchar *title, GtkWindow *parent,
|
||||
file_selection_action_t action);
|
||||
|
||||
/** Set the current folder for a file selection dialog.
|
||||
*
|
||||
* @param fs the file selection dialog from file_selection_new()
|
||||
* @param filename the folder to set
|
||||
* @return TRUE if the folder could be changed successfully
|
||||
*/
|
||||
extern gboolean file_selection_set_current_folder(GtkWidget *fs, const gchar *filename);
|
||||
|
||||
/** Set the current file for a file selection dialog.
|
||||
*
|
||||
* @param chooser the file selection dialog from file_selection_new()
|
||||
* @param filename the folder to set
|
||||
* @return TRUE if the folder could be changed successfully
|
||||
*/
|
||||
#define file_selection_set_current_file(chooser, filename) \
|
||||
gtk_file_chooser_set_filename(chooser, filename)
|
||||
|
||||
/** Set the "extra" widget for a file selection dialog. This is needed to support
|
||||
* user-supplied options.
|
||||
*
|
||||
* @param fs the file selection dialog from file_selection_new()
|
||||
* @param extra the widget to set
|
||||
*/
|
||||
extern void file_selection_set_extra_widget(GtkWidget *fs, GtkWidget *extra);
|
||||
|
||||
/** Run the dialog, and handle some common operations, such as, if the
|
||||
* user selects a directory, browsing that directory, and handling
|
||||
* shortcuts on Windows.
|
||||
* @param fs the file selection dialog from file_selection_new()
|
||||
* @return the pathname of the selected file if the user selected a
|
||||
* file, NULL if they cancelled or closed the dialog.
|
||||
*/
|
||||
extern gchar *file_selection_run(GtkWidget *fs);
|
||||
|
||||
#ifndef _WIN32
|
||||
/** If the specified file doesn't exist, return TRUE.
|
||||
* If it exists and is neither user-immutable nor not writable, return
|
||||
* TRUE.
|
||||
* Otherwise, as the user whether they want to overwrite it anyway, and
|
||||
* return TRUE if the file should be overwritten and FALSE otherwise.
|
||||
*
|
||||
* @param chooser_w the GtkFileChooser used to select the file in question
|
||||
* @param cf_name the current name chosen
|
||||
*/
|
||||
extern gboolean file_target_unwritable_ui(GtkWidget *chooser_w, char *cf_name);
|
||||
#endif
|
||||
|
||||
/** The function file_selection_browse() will g_object_set_data() itself on its parent window.
|
||||
* When destroying the parent window, it can close the corresponding file selection. */
|
||||
#define E_FILE_SEL_DIALOG_PTR_KEY "file_sel_dialog_ptr"
|
||||
|
||||
/** Browse the files and fill in the associated text entry.
|
||||
*
|
||||
* @param file_bt the button that called us (to get the toplevel widget)
|
||||
* @param file_te the GtkEntry the dialog will have to fill in the filename
|
||||
* @param title the title for the file selection dialog
|
||||
* @param action the desired action
|
||||
*/
|
||||
extern void
|
||||
file_selection_browse(GtkWidget *file_bt, GtkWidget *file_te, const char *title, file_selection_action_t action);
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -1,30 +0,0 @@
|
|||
/* file_import_dlg.h
|
||||
* Definitions for file import dialog box
|
||||
* November 2010, Jaap Keuter <jaap.keuter@xs4all.nl>
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __FILE_IMPORT_DLG_H__
|
||||
#define __FILE_IMPORT_DLG_H__
|
||||
|
||||
void file_import_cmd_cb(GtkWidget *widget);
|
||||
void file_import_txt_buf_cb(GtkWidget *widget);
|
||||
|
||||
#endif /* file_import_dlg.h */
|
|
@ -1,414 +0,0 @@
|
|||
/* fileset_dlg.c
|
||||
* Routines for the file set dialog
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.org>
|
||||
* Copyright 1998 Gerald Combs
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <wsutil/filesystem.h>
|
||||
#include <wsutil/str_util.h>
|
||||
|
||||
#include "../../fileset.h"
|
||||
|
||||
#include "ui/gtk/gui_utils.h"
|
||||
#include "ui/gtk/dlg_utils.h"
|
||||
#include "ui/gtk/main.h"
|
||||
#include "ui/gtk/menus.h"
|
||||
#include "ui/gtk/help_dlg.h"
|
||||
#include "ui/gtk/fileset_dlg.h"
|
||||
#include "ui/gtk/old-gtk-compat.h"
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
/*
|
||||
* Keep a static pointer to the current "File Set" window, if
|
||||
* any, so that if somebody tries to do "File Set" while there's
|
||||
* already a "File Set" window up, we just pop up the existing
|
||||
* one, rather than creating a new one.
|
||||
*/
|
||||
static GtkWidget *fs_w;
|
||||
|
||||
|
||||
|
||||
/* various widget related global data */
|
||||
static int row;
|
||||
static GtkWidget *fs_grid;
|
||||
static GtkWidget *fs_sw;
|
||||
static GtkWidget *fs_dir_lb;
|
||||
static GtkWidget *fs_first_rb;
|
||||
static GtkWidget *fs_grid_vb;
|
||||
|
||||
|
||||
|
||||
/* open the file corresponding to the given fileset entry */
|
||||
static void
|
||||
fs_open_entry(fileset_entry *entry)
|
||||
{
|
||||
char *fname;
|
||||
int err;
|
||||
|
||||
|
||||
/* make a copy of the filename (cf_close will indirectly destroy it right now) */
|
||||
fname = g_strdup(entry->fullname);
|
||||
|
||||
/* close the old and open the new file */
|
||||
cf_close(&cfile);
|
||||
if (cf_open(&cfile, fname, WTAP_TYPE_AUTO, FALSE, &err) == CF_OK) {
|
||||
cf_read(&cfile, FALSE);
|
||||
}
|
||||
|
||||
g_free(fname);
|
||||
}
|
||||
|
||||
|
||||
/* radio button was pressed/released */
|
||||
static void
|
||||
fs_rb_cb(GtkWidget *open_bt, gpointer fs_data)
|
||||
{
|
||||
fileset_entry *entry = (fileset_entry *)fs_data;
|
||||
|
||||
/* button release should have no effect */
|
||||
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(open_bt) )) {
|
||||
return;
|
||||
}
|
||||
|
||||
fs_open_entry(entry);
|
||||
}
|
||||
|
||||
|
||||
/* the window was closed, cleanup things */
|
||||
static void
|
||||
fs_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
|
||||
{
|
||||
/* Note that we no longer have a "File Set" dialog box. */
|
||||
fs_w = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* get creation date (converted from filename) */
|
||||
/* */
|
||||
static char *
|
||||
fileset_dlg_name2date_dup(const char * name) {
|
||||
char *pfx;
|
||||
char *filename;
|
||||
size_t pos;
|
||||
|
||||
|
||||
/* just to be sure ... */
|
||||
if (!fileset_filename_match_pattern(name)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* find char position behind the last underscore */
|
||||
pfx = strrchr(name, '_');
|
||||
pfx++;
|
||||
pos = pfx - name;
|
||||
|
||||
/* Start conversion behind that underscore */
|
||||
/* http://en.wikipedia.org/wiki/ISO_8601 */
|
||||
filename = g_strdup_printf("%c%c%c%c-%c%c-%c%c %c%c:%c%c:%c%c",
|
||||
/* year */ name[pos] , name[pos+1], name[pos+2], name[pos+3],
|
||||
/* month */ name[pos+4], name[pos+5],
|
||||
/* day */ name[pos+6], name[pos+7],
|
||||
/* hour */ name[pos+8], name[pos+9],
|
||||
/* min */ name[pos+10], name[pos+11],
|
||||
/* second */ name[pos+12], name[pos+13]);
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
|
||||
/* this file is a part of the current file set, add it to the dialog */
|
||||
void
|
||||
fileset_dlg_add_file(fileset_entry *entry, void *window _U_) {
|
||||
char *created;
|
||||
char *modified;
|
||||
char *size;
|
||||
struct tm *local;
|
||||
GtkWidget *fs_lb;
|
||||
GtkWidget *fs_rb;
|
||||
gchar *title;
|
||||
|
||||
|
||||
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 if available */
|
||||
/*
|
||||
* macOS provides 0 if the file system doesn't support the
|
||||
* creation time; FreeBSD provides -1.
|
||||
*
|
||||
* If this OS doesn't provide the creation time with stat(),
|
||||
* it will be 0.
|
||||
*/
|
||||
if (entry->ctime > 0) {
|
||||
local = localtime(&entry->ctime);
|
||||
if (local != NULL) {
|
||||
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);
|
||||
} else {
|
||||
created = g_strdup("Time not representable");
|
||||
}
|
||||
} else
|
||||
created = g_strdup("Not available");
|
||||
}
|
||||
|
||||
local = localtime(&entry->mtime);
|
||||
if (local != NULL) {
|
||||
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);
|
||||
} else {
|
||||
modified = g_strdup("Time not representable");
|
||||
}
|
||||
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_widget_set_tooltip_text(fs_rb, "Open this capture file");
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(fs_grid), fs_rb, 0, row, 1, 1, (GtkAttachOptions)(GTK_EXPAND|GTK_FILL), (GtkAttachOptions)0, 0, 0);
|
||||
g_signal_connect(fs_rb, "toggled", G_CALLBACK(fs_rb_cb), entry);
|
||||
gtk_widget_show(fs_rb);
|
||||
|
||||
fs_lb = gtk_label_new(created);
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(fs_grid), fs_lb, 1, row, 1, 1, (GtkAttachOptions)(GTK_EXPAND|GTK_FILL), (GtkAttachOptions)0, 0, 0);
|
||||
gtk_widget_set_sensitive(fs_lb, entry->current);
|
||||
gtk_widget_show(fs_lb);
|
||||
|
||||
fs_lb = gtk_label_new(modified);
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(fs_grid), fs_lb, 2, row, 1, 1, (GtkAttachOptions)(GTK_EXPAND|GTK_FILL), (GtkAttachOptions)0, 0, 0);
|
||||
gtk_widget_set_sensitive(fs_lb, entry->current);
|
||||
gtk_widget_show(fs_lb);
|
||||
|
||||
fs_lb = gtk_label_new(size);
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(fs_grid), fs_lb, 3, row, 1, 1, (GtkAttachOptions)(GTK_EXPAND|GTK_FILL), (GtkAttachOptions)0, 0, 0);
|
||||
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_grid);
|
||||
|
||||
/* 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_get_preferred_size(fs_grid, &requisition, NULL);
|
||||
/* XXX use gtk_window_set_default_size()? */
|
||||
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);
|
||||
}
|
||||
|
||||
void fileset_dlg_begin_add_file(void *window _U_) { } // Qt only
|
||||
void fileset_dlg_end_add_file(void *window _U_) { } // Qt only
|
||||
|
||||
/* init the fileset table */
|
||||
static void
|
||||
fileset_init_table(GtkWidget *parent_vb)
|
||||
{
|
||||
GtkWidget *fs_lb;
|
||||
|
||||
fs_grid = ws_gtk_grid_new();
|
||||
ws_gtk_grid_set_row_spacing(GTK_GRID(fs_grid), 1);
|
||||
ws_gtk_grid_set_column_spacing(GTK_GRID(fs_grid), 12);
|
||||
gtk_box_pack_start(GTK_BOX(parent_vb), fs_grid, FALSE, FALSE, 0);
|
||||
|
||||
row = 0;
|
||||
fs_first_rb = NULL;
|
||||
|
||||
fs_lb = gtk_label_new("Filename");
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(fs_grid), fs_lb, 0, row, 1, 1, (GtkAttachOptions)(GTK_EXPAND|GTK_FILL), (GtkAttachOptions)0, 0, 0);
|
||||
|
||||
fs_lb = gtk_label_new("Created");
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(fs_grid), fs_lb, 1, row, 1, 1, (GtkAttachOptions)(GTK_EXPAND|GTK_FILL), (GtkAttachOptions)0, 0, 0);
|
||||
|
||||
fs_lb = gtk_label_new("Last Modified");
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(fs_grid), fs_lb, 2, row, 1, 1, (GtkAttachOptions)(GTK_EXPAND|GTK_FILL), (GtkAttachOptions)0, 0, 0);
|
||||
|
||||
fs_lb = gtk_label_new("Size");
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(fs_grid), fs_lb, 3, row, 1, 1, (GtkAttachOptions)(GTK_EXPAND|GTK_FILL), (GtkAttachOptions)0, 0, 0);
|
||||
|
||||
gtk_widget_hide(fs_grid);
|
||||
|
||||
gtk_window_set_title(GTK_WINDOW(fs_w), "Wireshark: 0 Files in Set");
|
||||
|
||||
gtk_label_set_text(GTK_LABEL(fs_dir_lb), "No capture file loaded.");
|
||||
|
||||
row++;
|
||||
}
|
||||
|
||||
|
||||
/* open the fileset dialog */
|
||||
void
|
||||
fileset_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||
{
|
||||
GtkWidget *main_vb, *bbox, *close_bt, *help_bt;
|
||||
|
||||
|
||||
if (fs_w != NULL) {
|
||||
/* There's already a "File Set" dialog box; reactivate it. */
|
||||
reactivate_window(fs_w);
|
||||
return;
|
||||
}
|
||||
|
||||
fs_w = dlg_window_new(""); /* transient_for top_level */
|
||||
gtk_window_set_destroy_with_parent (GTK_WINDOW(fs_w), TRUE);
|
||||
|
||||
main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 5, FALSE);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
|
||||
gtk_container_add(GTK_CONTAINER(fs_w), main_vb);
|
||||
|
||||
fs_sw = gtk_scrolled_window_new(NULL, NULL);
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(fs_sw), GTK_POLICY_NEVER, GTK_POLICY_NEVER);
|
||||
gtk_box_pack_start(GTK_BOX(main_vb), fs_sw, TRUE, TRUE, 0);
|
||||
|
||||
/* add a dummy container, so we can replace the table later */
|
||||
fs_grid_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
|
||||
#if ! GTK_CHECK_VERSION(3,8,0)
|
||||
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(fs_sw), fs_grid_vb);
|
||||
#else
|
||||
gtk_container_add(GTK_CONTAINER(fs_sw), fs_grid_vb);
|
||||
#endif
|
||||
|
||||
fs_dir_lb = gtk_label_new("");
|
||||
gtk_box_pack_start(GTK_BOX(main_vb), fs_dir_lb, FALSE, FALSE, 0);
|
||||
|
||||
fileset_init_table(fs_grid_vb);
|
||||
|
||||
/* Button row: close and help button */
|
||||
bbox = dlg_button_row_new(GTK_STOCK_CLOSE, GTK_STOCK_HELP, NULL);
|
||||
gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5);
|
||||
|
||||
close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
|
||||
window_set_cancel_button(fs_w, close_bt, window_cancel_button_cb);
|
||||
gtk_widget_set_tooltip_text(close_bt, "Close this window.");
|
||||
|
||||
help_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
|
||||
g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb), (gpointer)HELP_FILESET_DIALOG);
|
||||
|
||||
gtk_widget_grab_default(close_bt);
|
||||
|
||||
g_signal_connect(fs_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
||||
g_signal_connect(fs_w, "destroy", G_CALLBACK(fs_destroy_cb), NULL);
|
||||
|
||||
/* init the dialog content */
|
||||
fileset_update_dlg(NULL);
|
||||
|
||||
gtk_widget_show_all(fs_w);
|
||||
window_present(fs_w);
|
||||
}
|
||||
|
||||
|
||||
/* open the next file in the file set, or do nothing if already the last file */
|
||||
void
|
||||
fileset_next_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||
{
|
||||
fileset_entry *entry;
|
||||
|
||||
entry = fileset_get_next();
|
||||
|
||||
if (entry) {
|
||||
fs_open_entry(entry);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* open the previous file in the file set, or do nothing if already the first file */
|
||||
void
|
||||
fileset_previous_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||
{
|
||||
fileset_entry *entry;
|
||||
|
||||
entry = fileset_get_previous();
|
||||
|
||||
if (entry) {
|
||||
fs_open_entry(entry);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* a new capture file was opened, browse the dir and look for files matching the given file set */
|
||||
void
|
||||
fileset_file_opened(const capture_file *cf) {
|
||||
fileset_add_dir(cf->filename, NULL);
|
||||
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)
|
||||
{
|
||||
if (fs_w) {
|
||||
/* reinit the table, title and alike */
|
||||
g_object_ref(G_OBJECT(fs_grid_vb));
|
||||
gtk_widget_destroy(fs_grid);
|
||||
fileset_delete();
|
||||
fileset_init_table(fs_grid_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 );
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
||||
* :indentSize=4:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -1,63 +0,0 @@
|
|||
/* fileset_dlg.h
|
||||
* Definitions for the fileset dialog box
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __FILESET_DLG_H__
|
||||
#define __FILESET_DLG_H__
|
||||
|
||||
/** @file
|
||||
* "File Set" dialog box.
|
||||
* @ingroup dialog_group
|
||||
*/
|
||||
|
||||
/** Enable file set menu items and look for similar files
|
||||
*
|
||||
* @param cf Capture file struct
|
||||
*/
|
||||
extern void fileset_file_opened(const capture_file *cf);
|
||||
|
||||
/** Disable file set menu items
|
||||
*/
|
||||
extern void fileset_file_closed(void);
|
||||
|
||||
|
||||
/** Open the fileset dialog.
|
||||
*
|
||||
* @param w calling widget (unused)
|
||||
* @param d data from calling widget (unused)
|
||||
*/
|
||||
extern void fileset_cb(GtkWidget *w, gpointer d);
|
||||
|
||||
/** Open the next file in the file set, or do nothing if already the last file.
|
||||
*
|
||||
* @param w calling widget (unused)
|
||||
* @param d data from calling widget (unused)
|
||||
*/
|
||||
extern void fileset_next_cb(GtkWidget *w, gpointer d);
|
||||
|
||||
/** Open the previous file in the file set, or do nothing if already the first file.
|
||||
*
|
||||
* @param w calling widget (unused)
|
||||
* @param d data from calling widget (unused)
|
||||
*/
|
||||
extern void fileset_previous_cb(GtkWidget *w, gpointer d);
|
||||
|
||||
#endif /* fileset_dlg.h */
|
|
@ -1,899 +0,0 @@
|
|||
/* filter_autocomplete.h
|
||||
* Definitions for filter autocomplete
|
||||
*
|
||||
* Copyright 2008, Bahaa Naamneh <b.naamneh@gmail.com>
|
||||
*
|
||||
* With several usability improvements:
|
||||
* Copyright 2008, Stig Bjorlykke <stig@bjorlykke.org>
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
# include <gdk/gdkkeysyms-compat.h>
|
||||
#endif
|
||||
|
||||
#include <epan/proto.h>
|
||||
|
||||
#include "ui/gtk/gui_utils.h"
|
||||
#include "ui/gtk/filter_autocomplete.h"
|
||||
|
||||
#include "ui/gtk/old-gtk-compat.h"
|
||||
|
||||
#define E_FILT_AUTOCOMP_TREE_KEY "filter_autocomplete_tree"
|
||||
|
||||
|
||||
static GtkWidget *filter_autocomplete_new(GtkWidget *filter_te, const gchar *protocol_name,
|
||||
gboolean protocols_only, gboolean *stop_propagation);
|
||||
static void autocomplete_protocol_string(GtkWidget *filter_te, gchar* selected_str);
|
||||
static void autoc_filter_row_activated_cb(GtkTreeView *treeview, GtkTreePath *path,
|
||||
GtkTreeViewColumn *column, gpointer data);
|
||||
static gboolean filter_te_focus_out_cb(GtkWidget *filter_te, GdkEvent *event, gpointer data);
|
||||
static void init_autocompletion_list(GtkWidget *list);
|
||||
static void add_to_autocompletion_list(GtkWidget *list, const gchar *str);
|
||||
static gboolean autocompletion_list_lookup(GtkWidget *filter_te, GtkWidget *popup_win, GtkWidget *list,
|
||||
const gchar *str, gboolean *stop_propagation);
|
||||
static void filter_autocomplete_handle_backspace(GtkWidget *filter_te, GtkWidget *list, GtkWidget *popup_win,
|
||||
gchar *prefix, GtkWidget *main_win);
|
||||
static void filter_autocomplete_win_destroy_cb(GtkWidget *win, gpointer data);
|
||||
static gboolean is_protocol_name_being_typed(GtkWidget *filter_te, int str_len);
|
||||
|
||||
|
||||
/*
|
||||
* Check if the string at the cursor position is a beginning of a protocol name.
|
||||
* Possible false positives:
|
||||
* "NOT" at the beginning of the display filter editable text.
|
||||
* "NOT" adjacent to another logical operation. (e.g: exp1 AND NOT exp2).
|
||||
**/
|
||||
static gboolean
|
||||
is_protocol_name_being_typed(GtkWidget *filter_te, int str_len)
|
||||
{
|
||||
unsigned int i;
|
||||
int op_len, cursor_pos;
|
||||
gchar *start;
|
||||
gchar *pos;
|
||||
static const gchar *logic_ops[] =
|
||||
{ "!", "not",
|
||||
"||", "or",
|
||||
"&&", "and",
|
||||
"^^", "xor" };
|
||||
|
||||
/* If the cursor is located at the beginning of the filter editable text,
|
||||
* then it's _probably_ a protocol name.
|
||||
**/
|
||||
if(!(cursor_pos = gtk_editable_get_position(GTK_EDITABLE(filter_te))))
|
||||
return TRUE;
|
||||
|
||||
start = gtk_editable_get_chars(GTK_EDITABLE(filter_te), 0, (gint) cursor_pos);
|
||||
|
||||
/* Point to one char before the current string in the filter editable text */
|
||||
pos = start + (cursor_pos - str_len);
|
||||
|
||||
/* Walk back through string to find last char which isn't ' ' or '(' */
|
||||
while(pos > start) {
|
||||
if(*pos != ' ' && *pos != '(') {
|
||||
/* Check if we have one of the logical operations */
|
||||
for(i = 0; i < (sizeof(logic_ops)/sizeof(logic_ops[0])); i++) {
|
||||
op_len = (int) strlen(logic_ops[i]);
|
||||
|
||||
if(pos-start+1 < op_len)
|
||||
continue;
|
||||
|
||||
/* If one of the logical operations is found, then the current string is _probably_ a protocol name */
|
||||
if(!strncmp(pos-op_len+1, logic_ops[i], op_len)) {
|
||||
g_free (start);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* If none of the logical operations was found, then the current string is not a protocol */
|
||||
g_free (start);
|
||||
return FALSE;
|
||||
}
|
||||
pos--;
|
||||
}
|
||||
|
||||
/* The "str" preceded only by ' ' or '(' chars,
|
||||
* which means that the str is _probably_ a protocol name.
|
||||
**/
|
||||
g_free (start);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
autocomplete_protocol_string(GtkWidget *filter_te, gchar *selected_str)
|
||||
{
|
||||
int pos;
|
||||
gchar *filter_str;
|
||||
gchar *pch;
|
||||
|
||||
/* Get the current filter string */
|
||||
pos = gtk_editable_get_position(GTK_EDITABLE(filter_te));
|
||||
filter_str = gtk_editable_get_chars(GTK_EDITABLE(filter_te), 0, pos);
|
||||
|
||||
/* Start from the end */
|
||||
pch = filter_str + strlen(filter_str);
|
||||
|
||||
/* Walk back through string to find last non-punctuation */
|
||||
while(pch != filter_str) {
|
||||
pch--;
|
||||
if(!g_ascii_isalnum(*pch) && (*pch) != '.' && (*pch) != '_' && (*pch) != '-') {
|
||||
pch++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(strncmp(pch, selected_str, pos-(pch-filter_str))) {
|
||||
gtk_editable_delete_text(GTK_EDITABLE(filter_te), (gint) (pch-filter_str), pos);
|
||||
pos = (int) (pch-filter_str);
|
||||
pch = selected_str;
|
||||
} else {
|
||||
pch = (selected_str + strlen(pch));
|
||||
}
|
||||
|
||||
gtk_editable_insert_text(GTK_EDITABLE(filter_te), pch, (gint) strlen(pch), &pos);
|
||||
gtk_editable_set_position(GTK_EDITABLE(filter_te), pos);
|
||||
g_free (filter_str);
|
||||
}
|
||||
|
||||
/* On row activated signal, complete the protocol string automatically */
|
||||
static void
|
||||
autoc_filter_row_activated_cb(GtkTreeView *treeview,
|
||||
GtkTreePath *path,
|
||||
GtkTreeViewColumn *column _U_,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *w_main;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
GtkWidget *win;
|
||||
gchar *proto;
|
||||
|
||||
model = gtk_tree_view_get_model(treeview);
|
||||
|
||||
if (gtk_tree_model_get_iter(model, &iter, path)) {
|
||||
|
||||
gtk_tree_model_get(model, &iter, 0, &proto, -1);
|
||||
autocomplete_protocol_string(GTK_WIDGET(data), proto);
|
||||
|
||||
g_free (proto);
|
||||
}
|
||||
|
||||
w_main = gtk_widget_get_toplevel(GTK_WIDGET(data));
|
||||
win = (GtkWidget *)g_object_get_data(G_OBJECT(w_main), E_FILT_AUTOCOMP_PTR_KEY);
|
||||
if(win != NULL) {
|
||||
gtk_widget_destroy(win);
|
||||
g_object_set_data(G_OBJECT(w_main), E_FILT_AUTOCOMP_PTR_KEY, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
filter_te_focus_out_cb(GtkWidget *filter_te _U_,
|
||||
GdkEvent *event _U_,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *win;
|
||||
|
||||
win = (GtkWidget *)g_object_get_data(G_OBJECT(data), E_FILT_AUTOCOMP_PTR_KEY);
|
||||
if(win != NULL) {
|
||||
gtk_widget_destroy(win);
|
||||
g_object_set_data(G_OBJECT(data), E_FILT_AUTOCOMP_PTR_KEY, NULL);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
check_select_region (GtkWidget *filter_te, GtkWidget *popup_win,
|
||||
const gchar *string, unsigned int str_len)
|
||||
{
|
||||
gint pos1 = gtk_editable_get_position(GTK_EDITABLE(filter_te));
|
||||
gint pos2 = pos1 + (gint) strlen(string) - str_len;
|
||||
gint pos3 = pos1;
|
||||
|
||||
if (pos2 > pos1) {
|
||||
gtk_editable_insert_text(GTK_EDITABLE(filter_te), &string[str_len-1],
|
||||
pos2-pos1+1, &pos3);
|
||||
gtk_editable_set_position(GTK_EDITABLE(filter_te), pos1+1);
|
||||
gtk_editable_select_region(GTK_EDITABLE(filter_te), pos1+1, pos2+1);
|
||||
gtk_widget_hide (popup_win);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
init_autocompletion_list(GtkWidget *list)
|
||||
{
|
||||
GtkCellRenderer *renderer;
|
||||
GtkTreeViewColumn *column;
|
||||
GtkListStore *store;
|
||||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
column = gtk_tree_view_column_new_with_attributes(NULL, renderer, "text", 0, NULL);
|
||||
|
||||
gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);
|
||||
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE);
|
||||
|
||||
store = gtk_list_store_new(1, G_TYPE_STRING);
|
||||
|
||||
gtk_tree_view_set_model(GTK_TREE_VIEW(list), GTK_TREE_MODEL(store));
|
||||
|
||||
g_object_unref(store);
|
||||
}
|
||||
|
||||
static void
|
||||
add_to_autocompletion_list(GtkWidget *list, const gchar *str)
|
||||
{
|
||||
GtkListStore *store;
|
||||
GtkTreeIter iter;
|
||||
|
||||
store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(list)));
|
||||
|
||||
gtk_list_store_append(store, &iter);
|
||||
gtk_list_store_set(store, &iter, 0, str, -1);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
autocompletion_list_lookup(GtkWidget *filter_te, GtkWidget *popup_win, GtkWidget *list,
|
||||
const gchar *str, gboolean *stop_propagation)
|
||||
{
|
||||
GtkRequisition requisition;
|
||||
GtkListStore *store;
|
||||
GtkTreeIter iter;
|
||||
GtkAllocation popup_win_alloc;
|
||||
gchar *curr_str;
|
||||
unsigned int str_len = (unsigned int) strlen(str);
|
||||
gchar *first = NULL;
|
||||
gint count = 0;
|
||||
gboolean loop = TRUE;
|
||||
gboolean exact_match = FALSE;
|
||||
|
||||
store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(list)));
|
||||
|
||||
if( gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter) ) {
|
||||
|
||||
do {
|
||||
|
||||
gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, 0, &curr_str, -1);
|
||||
|
||||
if( !g_ascii_strncasecmp(str, curr_str, str_len) ) {
|
||||
loop = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter);
|
||||
if (strlen(curr_str) == str_len) {
|
||||
exact_match = TRUE;
|
||||
}
|
||||
count++;
|
||||
if (count == 1)
|
||||
first = g_strdup (curr_str);
|
||||
} else {
|
||||
loop = gtk_list_store_remove(store, &iter);
|
||||
}
|
||||
|
||||
g_free(curr_str);
|
||||
|
||||
} while( loop );
|
||||
|
||||
if (count == 1 && !exact_match && strncmp(str, first, str_len) == 0) {
|
||||
/* Only one match (not exact) with correct case */
|
||||
*stop_propagation = check_select_region(filter_te, popup_win, first, str_len);
|
||||
}
|
||||
|
||||
/* Don't show an autocompletion-list with only one entry with exact match */
|
||||
if ((count == 1 && exact_match && strncmp(str, first, str_len) == 0) ||
|
||||
!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter))
|
||||
{
|
||||
g_free (first);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_free (first);
|
||||
|
||||
gtk_tree_view_columns_autosize(GTK_TREE_VIEW(list));
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
gtk_widget_get_preferred_size(list, &requisition, NULL);
|
||||
#else
|
||||
gtk_widget_size_request(list, &requisition);
|
||||
#endif
|
||||
gtk_widget_get_allocation(popup_win, &popup_win_alloc);
|
||||
|
||||
gtk_widget_set_size_request(popup_win, popup_win_alloc.width,
|
||||
(requisition.height<200? requisition.height+8:200));
|
||||
gtk_window_resize(GTK_WINDOW(popup_win), popup_win_alloc.width,
|
||||
(requisition.height<200? requisition.height+8:200));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
filter_string_te_key_pressed_cb(GtkWidget *filter_te, GdkEventKey *event, gpointer user_data _U_)
|
||||
{
|
||||
GtkWidget *popup_win;
|
||||
GtkWidget *w_toplevel;
|
||||
GtkWidget *treeview;
|
||||
GtkTreeModel *model;
|
||||
GtkTreePath *path;
|
||||
GtkTreeSelection *selection;
|
||||
GtkTreeIter iter;
|
||||
gchar* prefix;
|
||||
gchar* prefix_start = NULL;
|
||||
gboolean stop_propagation = FALSE;
|
||||
guint k;
|
||||
guint32 ckey = '\0';
|
||||
gint string_buf_len;
|
||||
gchar string_buf[6]; /* g_unichar_to_utf8 needs 6 bytes to convert a single
|
||||
char to a code point. (ISO/IEC 10646 defines this
|
||||
maximum byte length, RFC 3629 changed this to 4) */
|
||||
gchar *key_string = NULL;
|
||||
gint pos;
|
||||
|
||||
w_toplevel = gtk_widget_get_toplevel(filter_te);
|
||||
|
||||
popup_win = (GtkWidget *)g_object_get_data(G_OBJECT(w_toplevel), E_FILT_AUTOCOMP_PTR_KEY);
|
||||
|
||||
k = event->keyval;
|
||||
if (k != GDK_VoidSymbol) {
|
||||
ckey = gdk_keyval_to_unicode(k);
|
||||
string_buf_len = g_unichar_to_utf8(ckey, string_buf);
|
||||
key_string =
|
||||
g_locale_from_utf8(string_buf, string_buf_len, NULL, NULL, NULL);
|
||||
}
|
||||
if (!key_string)
|
||||
key_string = g_strdup("");
|
||||
|
||||
/* Ignore Ctrl combinations (Ctrl-C, Ctrl-V, Ctrl-Right, ...). */
|
||||
if (event->state & GDK_CONTROL_MASK)
|
||||
goto exit;
|
||||
/* Pressing modifiers such as Shift or Ctrl should not hide the list. */
|
||||
switch (k) {
|
||||
case GDK_Shift_L:
|
||||
case GDK_Shift_R:
|
||||
case GDK_Control_L:
|
||||
case GDK_Control_R:
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (popup_win)
|
||||
gtk_widget_show(popup_win);
|
||||
|
||||
pos = gtk_editable_get_position(GTK_EDITABLE(filter_te));
|
||||
if (g_ascii_isalnum(ckey) ||
|
||||
k == GDK_KP_Decimal || k == GDK_period ||
|
||||
k == GDK_underscore || k == GDK_minus)
|
||||
{
|
||||
/* Ensure we delete the selected text */
|
||||
gtk_editable_delete_selection(GTK_EDITABLE(filter_te));
|
||||
} else if (k == GDK_Return || k == GDK_KP_Enter) {
|
||||
/* Remove selection */
|
||||
gtk_editable_select_region(GTK_EDITABLE(filter_te), pos, pos);
|
||||
}
|
||||
/* get the string from filter_te, start from 0 till cursor's position */
|
||||
prefix_start = gtk_editable_get_chars(GTK_EDITABLE(filter_te), 0, pos);
|
||||
|
||||
/* If the pressed key is non-alphanumeric or one of the keys specified
|
||||
* in the condition (decimal, period...) then destroy popup window.
|
||||
**/
|
||||
if( !g_ascii_isalnum(ckey) &&
|
||||
k != GDK_KP_Decimal && k != GDK_period &&
|
||||
k != GDK_underscore && k != GDK_minus &&
|
||||
k != GDK_space && k != GDK_Return && k != GDK_KP_Enter &&
|
||||
k != GDK_Page_Down && k != GDK_Down && k != GDK_Page_Up && k != GDK_Up &&
|
||||
k != GDK_BackSpace)
|
||||
{
|
||||
if (popup_win) {
|
||||
gtk_widget_destroy(popup_win);
|
||||
g_object_set_data(G_OBJECT(w_toplevel), E_FILT_AUTOCOMP_PTR_KEY, NULL);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Let prefix points to the first char that is not aphanumeric,'.', '_' or '-',
|
||||
* start from the end of filter_te_str.
|
||||
**/
|
||||
prefix = prefix_start + strlen(prefix_start);
|
||||
while(prefix != prefix_start) {
|
||||
prefix--;
|
||||
if(!g_ascii_isalnum((*prefix)) && (*prefix) != '.' && (*prefix) != '_' && (*prefix) != '-') {
|
||||
prefix++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Now, if the pressed key is decimal or period, and there is no period or
|
||||
* decimal before it in prefix then construct the popup window.
|
||||
*
|
||||
* If the pressed key is backspace, and there is no existing popup window
|
||||
* then construct the popup window again.
|
||||
**/
|
||||
if(k==GDK_period || k==GDK_KP_Decimal) {
|
||||
if( !strchr(prefix, '.') || !popup_win) {
|
||||
|
||||
gchar* name_with_period;
|
||||
|
||||
if (popup_win) {
|
||||
gtk_widget_destroy (popup_win);
|
||||
}
|
||||
|
||||
name_with_period = g_strconcat(prefix, key_string, NULL);
|
||||
popup_win = filter_autocomplete_new(filter_te, name_with_period, FALSE, &stop_propagation);
|
||||
g_object_set_data(G_OBJECT(w_toplevel), E_FILT_AUTOCOMP_PTR_KEY, popup_win);
|
||||
|
||||
g_free(name_with_period);
|
||||
|
||||
goto exit;
|
||||
}
|
||||
} else if(k==GDK_BackSpace && !popup_win) {
|
||||
|
||||
if(strlen(prefix) > 1) {
|
||||
/* Delete the last character in the prefix string */
|
||||
prefix[strlen(prefix)-1] = '\0';
|
||||
if(strchr(prefix, '.')) {
|
||||
popup_win = filter_autocomplete_new(filter_te, prefix, FALSE, NULL);
|
||||
g_object_set_data(G_OBJECT(w_toplevel), E_FILT_AUTOCOMP_PTR_KEY, popup_win);
|
||||
} else if(strlen(prefix) && is_protocol_name_being_typed(filter_te, (int) strlen(prefix)+2)) {
|
||||
popup_win = filter_autocomplete_new(filter_te, prefix, TRUE, NULL);
|
||||
g_object_set_data(G_OBJECT(w_toplevel), E_FILT_AUTOCOMP_PTR_KEY, popup_win);
|
||||
}
|
||||
}
|
||||
|
||||
goto exit;
|
||||
} else if(g_ascii_isalnum(ckey) && !popup_win) {
|
||||
gchar *name = g_strconcat(prefix, key_string, NULL);
|
||||
|
||||
if( !strchr(name, '.') && is_protocol_name_being_typed(filter_te, (int) strlen(name)) ) {
|
||||
popup_win = filter_autocomplete_new(filter_te, name, TRUE, &stop_propagation);
|
||||
g_object_set_data(G_OBJECT(w_toplevel), E_FILT_AUTOCOMP_PTR_KEY, popup_win);
|
||||
}
|
||||
|
||||
g_free(name);
|
||||
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* If the popup window hasn't been constructed yet then we have nothing to do */
|
||||
if( !popup_win ) {
|
||||
stop_propagation = FALSE;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
||||
treeview = (GtkWidget *)g_object_get_data(G_OBJECT(popup_win), E_FILT_AUTOCOMP_TREE_KEY);
|
||||
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
|
||||
model = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
|
||||
|
||||
switch(k)
|
||||
{
|
||||
/* a better implementation for UP/DOWN keys would be moving the control to the popup'ed window, and letting
|
||||
* the treeview handle the up, down actions directly and return the control to the filter text once
|
||||
* the user press Enter or any key except for UP, DOWN arrows. * I wasn't able to find a way to do that. *
|
||||
**/
|
||||
case GDK_Page_Down:
|
||||
case GDK_Down:
|
||||
if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
|
||||
if (gtk_tree_model_iter_next(model, &iter)) {
|
||||
if (k == GDK_Page_Down) {
|
||||
/* Skip up to 8 entries */
|
||||
GtkTreeIter last_iter;
|
||||
gint count = 0;
|
||||
do {
|
||||
last_iter = iter;
|
||||
} while (++count < 8 && gtk_tree_model_iter_next(model, &iter));
|
||||
iter = last_iter;
|
||||
}
|
||||
gtk_tree_selection_select_iter(GTK_TREE_SELECTION(selection), &iter);
|
||||
path = gtk_tree_model_get_path(model, &iter);
|
||||
gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(treeview), path,
|
||||
NULL, FALSE, 0, 0);
|
||||
gtk_tree_path_free(path);
|
||||
} else {
|
||||
gtk_tree_selection_unselect_all(selection);
|
||||
}
|
||||
} else if (gtk_tree_model_get_iter_first(model, &iter)) {
|
||||
gtk_tree_selection_select_iter(GTK_TREE_SELECTION(selection), &iter);
|
||||
path = gtk_tree_model_get_path(model, &iter);
|
||||
gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(treeview), path,
|
||||
NULL, FALSE, 0, 0);
|
||||
gtk_tree_path_free(path);
|
||||
}
|
||||
|
||||
/* stop event propagation */
|
||||
stop_propagation = TRUE;
|
||||
goto exit;
|
||||
|
||||
case GDK_Page_Up:
|
||||
case GDK_Up:
|
||||
{
|
||||
GtkTreeIter last_iter;
|
||||
|
||||
if (gtk_tree_selection_get_selected(selection, &model, &iter) ) {
|
||||
path = gtk_tree_model_get_path(model, &iter);
|
||||
|
||||
if (gtk_tree_path_prev(path)) {
|
||||
if (k == GDK_Page_Up) {
|
||||
/* Skip up to 8 entries */
|
||||
GtkTreePath *last_path;
|
||||
gint count = 0;
|
||||
do {
|
||||
last_path = path;
|
||||
} while (++count < 8 && gtk_tree_path_prev(path));
|
||||
path = last_path;
|
||||
}
|
||||
gtk_tree_selection_select_path(GTK_TREE_SELECTION(selection), path);
|
||||
gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(treeview), path, NULL, FALSE, 0, 0);
|
||||
} else {
|
||||
gtk_tree_selection_unselect_iter(selection, &iter);
|
||||
}
|
||||
gtk_tree_path_free(path);
|
||||
} else if (gtk_tree_model_get_iter_first(model, &iter)) {
|
||||
do {
|
||||
last_iter = iter;
|
||||
} while (gtk_tree_model_iter_next(model, &iter));
|
||||
gtk_tree_selection_select_iter(GTK_TREE_SELECTION(selection), &last_iter);
|
||||
path = gtk_tree_model_get_path(model, &last_iter);
|
||||
gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(treeview), path,
|
||||
NULL, FALSE, 0, 0);
|
||||
gtk_tree_path_free(path);
|
||||
}
|
||||
|
||||
/* stop event propagation */
|
||||
stop_propagation = TRUE;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
||||
/* if pressed key is Space or Enter then autocomplete protocol string */
|
||||
case GDK_space:
|
||||
case GDK_Return:
|
||||
case GDK_KP_Enter:
|
||||
|
||||
if(gtk_tree_selection_get_selected(selection, &model, &iter) ) {
|
||||
gchar *value;
|
||||
|
||||
/* Do not autocomplete protocols with space yet, because we can be in
|
||||
* a operator or a value field.
|
||||
**/
|
||||
if(k != GDK_space || strchr(prefix, '.')) {
|
||||
/* Use chosen string */
|
||||
gtk_tree_model_get(model, &iter, 0, &value, -1);
|
||||
autocomplete_protocol_string(filter_te, value);
|
||||
g_free(value);
|
||||
}
|
||||
if(k != GDK_space) {
|
||||
stop_propagation = TRUE; /* stop event propagation */
|
||||
}
|
||||
}
|
||||
|
||||
/* Lose popup */
|
||||
gtk_widget_destroy(popup_win);
|
||||
g_object_set_data(G_OBJECT(w_toplevel), E_FILT_AUTOCOMP_PTR_KEY, NULL);
|
||||
break;
|
||||
|
||||
case GDK_BackSpace:
|
||||
filter_autocomplete_handle_backspace(filter_te, treeview, popup_win, prefix, w_toplevel);
|
||||
break;
|
||||
|
||||
default: {
|
||||
gchar* updated_str;
|
||||
|
||||
updated_str = g_strconcat(prefix, key_string, NULL);
|
||||
if( !autocompletion_list_lookup(filter_te, popup_win, treeview, updated_str, &stop_propagation) ) {
|
||||
/* function returned false, ie the list is empty -> close popup */
|
||||
gtk_widget_destroy(popup_win);
|
||||
g_object_set_data(G_OBJECT(w_toplevel), E_FILT_AUTOCOMP_PTR_KEY, NULL);
|
||||
}
|
||||
|
||||
g_free(updated_str);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exit:
|
||||
g_free(prefix_start);
|
||||
g_free(key_string);
|
||||
|
||||
return stop_propagation;
|
||||
}
|
||||
|
||||
/*
|
||||
* In my implementation, I'm looking for fields that match the protocol name in the whole fields list
|
||||
* and not only restrict the process by returning all the fields of the protocol that match the prefix using
|
||||
* 'proto_get_id_by_filter_name(protocol_name)'; because I have noticed that some of the fields
|
||||
* have a prefix different than its parent protocol; for example SIP protocol had this field raw_sip.line despite
|
||||
* that there is a protocol called RAW_SIP which it should be associated with it.
|
||||
* so the unorganized fields and nonexistent of a standardized protocols and fields naming rules prevent me from
|
||||
* implementing the autocomplete in an optimized way.
|
||||
**/
|
||||
static gboolean
|
||||
build_autocompletion_list(GtkWidget *filter_te, GtkWidget *treeview, GtkWidget *popup_win,
|
||||
const gchar *protocol_name, gboolean protocols_only, gboolean *stop_propagation)
|
||||
{
|
||||
void *cookie, *cookie2;
|
||||
protocol_t *protocol;
|
||||
unsigned int protocol_name_len;
|
||||
header_field_info *hfinfo;
|
||||
gint count = 0;
|
||||
gboolean exact_match = FALSE;
|
||||
const gchar *first = NULL;
|
||||
int i;
|
||||
|
||||
protocol_name_len = (unsigned int) strlen(protocol_name);
|
||||
|
||||
/* Force load protocol fields, if not already done */
|
||||
if(protocol_name[protocol_name_len-1] == '.')
|
||||
proto_registrar_get_byname(protocol_name);
|
||||
|
||||
/* Walk protocols list */
|
||||
for (i = proto_get_first_protocol(&cookie); i != -1; i = proto_get_next_protocol(&cookie)) {
|
||||
|
||||
protocol = find_protocol_by_id(i);
|
||||
|
||||
if (!proto_is_protocol_enabled(protocol))
|
||||
continue;
|
||||
|
||||
if (protocols_only) {
|
||||
const gchar *name = proto_get_protocol_filter_name (i);
|
||||
|
||||
if (!g_ascii_strncasecmp(protocol_name, name, protocol_name_len)) {
|
||||
add_to_autocompletion_list(treeview, name);
|
||||
if (strlen(name) == protocol_name_len) {
|
||||
exact_match = TRUE;
|
||||
}
|
||||
count++;
|
||||
if (count == 1)
|
||||
first = name;
|
||||
}
|
||||
} else {
|
||||
|
||||
for (hfinfo = proto_get_first_protocol_field(i, &cookie2);
|
||||
hfinfo != NULL;
|
||||
hfinfo = proto_get_next_protocol_field(i, &cookie2))
|
||||
{
|
||||
if (hfinfo->same_name_prev_id != -1) /* ignore duplicate names */
|
||||
continue;
|
||||
|
||||
if(!g_ascii_strncasecmp(protocol_name, hfinfo->abbrev, protocol_name_len)) {
|
||||
add_to_autocompletion_list(treeview, hfinfo->abbrev);
|
||||
if (strlen(hfinfo->abbrev) == protocol_name_len) {
|
||||
exact_match = TRUE;
|
||||
}
|
||||
count++;
|
||||
if (count == 1)
|
||||
first = hfinfo->abbrev;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count == 1 && !exact_match && stop_propagation &&
|
||||
strncmp(protocol_name, first, protocol_name_len) == 0)
|
||||
{
|
||||
/* Only one match (not exact) with correct case */
|
||||
*stop_propagation = check_select_region(filter_te, popup_win, first, protocol_name_len);
|
||||
}
|
||||
|
||||
/* Don't show an empty autocompletion-list or
|
||||
* an autocompletion-list with only one entry with exact match
|
||||
**/
|
||||
if (count == 0 || (count == 1 && exact_match &&
|
||||
strncmp(protocol_name, first, protocol_name_len) == 0))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
filter_autocomplete_disable_sorting(GtkTreeModel *model)
|
||||
{
|
||||
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model),
|
||||
GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, GTK_SORT_ASCENDING);
|
||||
}
|
||||
|
||||
static void
|
||||
filter_autocomplete_enable_sorting(GtkTreeModel *model)
|
||||
{
|
||||
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), 0, GTK_SORT_ASCENDING);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
filter_autocomplete_new(GtkWidget *filter_te, const gchar *protocol_name,
|
||||
gboolean protocols_only, gboolean *stop_propagation)
|
||||
{
|
||||
GtkWidget *popup_win;
|
||||
GtkWidget *treeview;
|
||||
GtkWidget *filter_sc;
|
||||
gint x_pos, y_pos;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeSelection *selection;
|
||||
GtkRequisition requisition;
|
||||
GtkWidget *w_toplevel;
|
||||
GtkAllocation filter_te_alloc;
|
||||
|
||||
w_toplevel = gtk_widget_get_toplevel(filter_te);
|
||||
|
||||
/* Create popup window */
|
||||
popup_win = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
|
||||
/* Create scrolled window */
|
||||
filter_sc = scrolled_window_new(NULL, NULL);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (filter_sc), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(filter_sc), GTK_SHADOW_IN);
|
||||
gtk_container_add(GTK_CONTAINER(popup_win), filter_sc);
|
||||
|
||||
/* Create tree view */
|
||||
treeview = gtk_tree_view_new();
|
||||
gtk_tree_view_set_hover_selection(GTK_TREE_VIEW(treeview), TRUE);
|
||||
init_autocompletion_list(treeview);
|
||||
g_object_set_data(G_OBJECT(popup_win), E_FILT_AUTOCOMP_TREE_KEY, treeview);
|
||||
|
||||
/* Build list */
|
||||
if (!build_autocompletion_list(filter_te, treeview, popup_win, protocol_name, protocols_only, stop_propagation)) {
|
||||
gtk_widget_destroy(popup_win);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Sort treeview */
|
||||
model = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
|
||||
if(model)
|
||||
filter_autocomplete_enable_sorting(model);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (filter_sc), treeview);
|
||||
|
||||
g_signal_connect(treeview, "row-activated", G_CALLBACK(autoc_filter_row_activated_cb), filter_te);
|
||||
g_signal_connect(filter_te, "focus-out-event", G_CALLBACK(filter_te_focus_out_cb), w_toplevel);
|
||||
g_signal_connect(popup_win, "destroy", G_CALLBACK(filter_autocomplete_win_destroy_cb), NULL);
|
||||
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
gtk_widget_get_preferred_size(treeview, &requisition, NULL);
|
||||
#else
|
||||
gtk_widget_size_request(treeview, &requisition);
|
||||
#endif
|
||||
gtk_widget_get_allocation(filter_te, &filter_te_alloc);
|
||||
|
||||
gtk_widget_set_size_request(popup_win, filter_te_alloc.width,
|
||||
(requisition.height<200? requisition.height+8:200));
|
||||
gtk_window_resize(GTK_WINDOW(popup_win), filter_te_alloc.width,
|
||||
(requisition.height<200? requisition.height+8:200));
|
||||
|
||||
gdk_window_get_origin(gtk_widget_get_window(filter_te), &x_pos, &y_pos);
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
x_pos += filter_te_alloc.x;
|
||||
y_pos += (filter_te_alloc.y + filter_te_alloc.height);
|
||||
#else
|
||||
y_pos += filter_te_alloc.height;
|
||||
#endif
|
||||
gtk_window_move(GTK_WINDOW(popup_win), x_pos, y_pos);
|
||||
|
||||
gtk_widget_show_all (popup_win);
|
||||
|
||||
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
|
||||
gtk_tree_selection_unselect_all(selection);
|
||||
|
||||
return popup_win;
|
||||
}
|
||||
|
||||
static void
|
||||
filter_autocomplete_handle_backspace(GtkWidget *filter_te, GtkWidget *list, GtkWidget *popup_win,
|
||||
gchar *prefix, GtkWidget *main_win)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
GtkListStore *store;
|
||||
GtkRequisition requisition;
|
||||
size_t prefix_len;
|
||||
gboolean protocols_only = FALSE;
|
||||
GtkAllocation popup_win_alloc;
|
||||
|
||||
prefix_len = strlen(prefix);
|
||||
|
||||
if (prefix_len <= 1) {
|
||||
/* Remove the popup window for protocols */
|
||||
gtk_widget_destroy(popup_win);
|
||||
g_object_set_data(G_OBJECT(main_win), E_FILT_AUTOCOMP_PTR_KEY, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Delete the last character in the prefix string */
|
||||
prefix_len--;
|
||||
prefix[prefix_len] = '\0';
|
||||
|
||||
if(strchr(prefix, '.') == NULL) {
|
||||
protocols_only = TRUE;
|
||||
}
|
||||
|
||||
/* Empty list */
|
||||
model = gtk_tree_view_get_model(GTK_TREE_VIEW(list));
|
||||
store = GTK_LIST_STORE(model);
|
||||
gtk_list_store_clear(store);
|
||||
|
||||
/* Disable sorting */
|
||||
filter_autocomplete_disable_sorting(model);
|
||||
|
||||
/* Build new list */
|
||||
if (!build_autocompletion_list(filter_te, list, popup_win, prefix, protocols_only, NULL)) {
|
||||
gtk_widget_destroy(popup_win);
|
||||
g_object_set_data(G_OBJECT(main_win), E_FILT_AUTOCOMP_PTR_KEY, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Enable sorting */
|
||||
filter_autocomplete_enable_sorting(model);
|
||||
|
||||
gtk_tree_view_columns_autosize(GTK_TREE_VIEW(list));
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
gtk_widget_get_preferred_size(list, &requisition, NULL);
|
||||
#else
|
||||
gtk_widget_size_request(list, &requisition);
|
||||
#endif
|
||||
|
||||
gtk_widget_get_allocation(popup_win, &popup_win_alloc);
|
||||
|
||||
/* XXX use gtk_window_set_default_size()? */
|
||||
gtk_widget_set_size_request(popup_win, popup_win_alloc.width,
|
||||
(requisition.height<200? requisition.height+8:200));
|
||||
gtk_window_resize(GTK_WINDOW(popup_win), popup_win_alloc.width,
|
||||
(requisition.height<200? requisition.height+8:200));
|
||||
}
|
||||
|
||||
static void
|
||||
filter_autocomplete_win_destroy_cb(GtkWidget *win, gpointer data _U_)
|
||||
{
|
||||
/* tell that the autocomplete window doesn't exist anymore */
|
||||
g_object_set_data(G_OBJECT(win), E_FILT_AUTOCOMP_PTR_KEY, NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
filter_parent_dlg_key_pressed_cb(GtkWidget *win, GdkEventKey *event, gpointer user_data _U_)
|
||||
{
|
||||
GtkWidget *popup_win;
|
||||
|
||||
popup_win = (GtkWidget *)g_object_get_data(G_OBJECT(win), E_FILT_AUTOCOMP_PTR_KEY);
|
||||
|
||||
if(popup_win && event->keyval == GDK_Escape) {
|
||||
gtk_widget_destroy(popup_win);
|
||||
g_object_set_data(G_OBJECT(win), E_FILT_AUTOCOMP_PTR_KEY, NULL);
|
||||
|
||||
/* stop event propagation */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local Variables:
|
||||
* c-basic-offset: 2
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=2 tabstop=8 expandtab:
|
||||
* :indentSize=2:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -1,53 +0,0 @@
|
|||
/* filter_autocomplete.h
|
||||
* Definitions for filter autocomplete
|
||||
*
|
||||
* Copyright 2008, Bahaa Naamneh <b.naamneh@gmail.com>
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef _FILTER_AUTO_COMPLETE_H_
|
||||
#define _FILTER_AUTO_COMPLETE_H_
|
||||
|
||||
|
||||
#define E_FILT_AUTOCOMP_PTR_KEY "filter_autocomplete_window"
|
||||
|
||||
/** @file
|
||||
* "Filter Auto Complete" dialog box.
|
||||
* @ingroup dialog_group
|
||||
*/
|
||||
|
||||
/** Callback function that is called when a "key-press-event" signal occur.
|
||||
*
|
||||
* @param filter_te text-editing filter widget
|
||||
* @param event a GdkEventButton *event
|
||||
* @param user_data pointer to user_data (unused)
|
||||
*/
|
||||
extern gboolean filter_string_te_key_pressed_cb(GtkWidget *filter_te, GdkEventKey *event, gpointer user_data _U_);
|
||||
|
||||
/** Callback function that is called when a "key-press-event" signal occur.
|
||||
*
|
||||
* @param win parent window of the text-editing filter widget
|
||||
* @param event a GdkEventButton *event
|
||||
* @param user_data pointer to user_data (unused)
|
||||
*/
|
||||
extern gboolean filter_parent_dlg_key_pressed_cb(GtkWidget *win, GdkEventKey *event, gpointer user_data _U_);
|
||||
|
||||
|
||||
#endif
|
1399
ui/gtk/filter_dlg.c
1399
ui/gtk/filter_dlg.c
File diff suppressed because it is too large
Load Diff
|
@ -1,132 +0,0 @@
|
|||
/* filter_dlg.h
|
||||
* Definitions for dialog boxes for filter editing
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __FILTER_DLG_H__
|
||||
#define __FILTER_DLG_H__
|
||||
|
||||
/** @file
|
||||
* "Capture Filter" / "Display Filter" / "Add expression" dialog boxes.
|
||||
* (This used to be a notebook page under "Preferences", hence the
|
||||
* "prefs" in the file name.)
|
||||
* @ingroup dialog_group
|
||||
*/
|
||||
|
||||
/**
|
||||
* Structure giving properties of the filter editing dialog box to be
|
||||
* created.
|
||||
*/
|
||||
typedef struct {
|
||||
const gchar *title; /**< title of dialog box */
|
||||
gboolean wants_apply_button; /**< dialog should have an Apply button */
|
||||
gboolean activate_on_ok; /**< if parent text widget should be
|
||||
activated on "Ok" or "Apply" */
|
||||
gboolean modal_and_transient; /**< dialog is modal and transient to the
|
||||
parent window (e.g. to gtk_file_chooser) */
|
||||
} construct_args_t;
|
||||
|
||||
/** Create a "Capture Filter" dialog box caused by a button click.
|
||||
*
|
||||
* @param widget parent widget
|
||||
* @param user_data unused
|
||||
*/
|
||||
void capture_filter_construct_cb(GtkWidget *widget, gpointer user_data);
|
||||
|
||||
/** Create a "Display Filter" dialog box caused by a button click.
|
||||
*
|
||||
* @param widget parent widget
|
||||
* @param construct_args_ptr parameters to construct the dialog (construct_args_t)
|
||||
*/
|
||||
void display_filter_construct_cb(GtkWidget *widget, gpointer construct_args_ptr);
|
||||
|
||||
/** Should be called when the widget (usually a button) that creates filters
|
||||
* is destroyed. It destroys any filter dialog created by that widget.
|
||||
*
|
||||
* @param widget parent widget
|
||||
* @param user_data unused
|
||||
*/
|
||||
void filter_button_destroy_cb(GtkWidget *widget, gpointer user_data);
|
||||
|
||||
/** User requested the "Capture Filter" dialog box by menu or toolbar.
|
||||
*
|
||||
* @param widget parent widget
|
||||
*/
|
||||
void cfilter_dialog_cb(GtkWidget *widget);
|
||||
|
||||
/** User requested the "Display Filter" dialog box by menu or toolbar.
|
||||
*
|
||||
* @param widget parent widget
|
||||
*/
|
||||
void dfilter_dialog_cb(GtkWidget *widget);
|
||||
|
||||
/** Create an "Add expression" dialog box caused by a button click.
|
||||
*
|
||||
* @param widget unused
|
||||
* @param main_w_arg parent widget
|
||||
*/
|
||||
void filter_add_expr_bt_cb(GtkWidget *widget, gpointer main_w_arg);
|
||||
|
||||
/** Colorize a text entry as empty.
|
||||
*
|
||||
* @param widget the text entry to colorize
|
||||
*/
|
||||
void colorize_filter_te_as_empty(GtkWidget *widget);
|
||||
|
||||
/** Colorize a text entry as a invalid.
|
||||
*
|
||||
* @param widget the text entry to colorize
|
||||
*/
|
||||
void colorize_filter_te_as_invalid(GtkWidget *widget);
|
||||
|
||||
/** Colorize a text entry as a valid.
|
||||
*
|
||||
* @param widget the text entry to colorize
|
||||
*/
|
||||
void colorize_filter_te_as_valid(GtkWidget *widget);
|
||||
|
||||
/** Colorize a filter text entry depending on "validity".
|
||||
*
|
||||
* @param widget the text entry to colorize
|
||||
* @param user_data Callback User Data pointer (unused)
|
||||
*/
|
||||
void filter_te_syntax_check_cb(GtkWidget *widget, gpointer user_data _U_);
|
||||
|
||||
/** The filter button of the top_level window. */
|
||||
#define E_FILT_BT_PTR_KEY "filter_bt_ptr"
|
||||
|
||||
/** The filter text entry. */
|
||||
#define E_FILT_TE_PTR_KEY "filter_te_ptr"
|
||||
|
||||
/** The filter text entry.
|
||||
* @todo Check the usage of all the text entry keys.
|
||||
*/
|
||||
#define E_FILT_FILTER_TE_KEY "filter_filter_te"
|
||||
|
||||
/** Only validate a single field entry. */
|
||||
#define E_FILT_FIELD_NAME_ONLY_KEY "filter_field_name_only"
|
||||
|
||||
/** Only validate a multi field entry. */
|
||||
#define E_FILT_MULTI_FIELD_NAME_ONLY_KEY "filter_multi_field_name_only"
|
||||
|
||||
/** Update statusbar when changing the filter entry. */
|
||||
#define E_FILT_FIELD_USE_STATUSBAR_KEY "filter_field_use_statusbar"
|
||||
|
||||
#endif /* filter_dlg.h */
|
|
@ -1,354 +0,0 @@
|
|||
/* filter_expression_save_dlg.c
|
||||
* Routines for "Filter Save" window
|
||||
* Submitted by Edwin Groothuis <wireshark@mavetju.org>
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <epan/prefs.h>
|
||||
#include <epan/uat-int.h>
|
||||
|
||||
|
||||
#include "ui/preference_utils.h"
|
||||
|
||||
#include "ui/gtk/gui_utils.h"
|
||||
#include "ui/gtk/filter_expression_save_dlg.h"
|
||||
#include "ui/gtk/dlg_utils.h"
|
||||
#include "ui/gtk/filter_dlg.h"
|
||||
#include "ui/gtk/filter_autocomplete.h"
|
||||
#include "ui/gtk/help_dlg.h"
|
||||
|
||||
#include "globals.h"
|
||||
#include "main.h"
|
||||
|
||||
|
||||
/* Capture callback data keys */
|
||||
#define E_FILTER_SAVE_EXPR_KEY "filter_save_offset_expression"
|
||||
#define E_FILTER_SAVE_LABEL_KEY "filter_save_offset_label"
|
||||
|
||||
static void filter_save_ok_cb(GtkWidget *ok_bt, GtkWindow *parent_w);
|
||||
static void filter_save_close_cb(GtkWidget *close_bt, gpointer parent_w);
|
||||
static void filter_save_frame_destroy_cb(GtkWidget *win, gpointer user_data);
|
||||
static void filter_button_cb(GtkWidget *close_bt, gpointer parent_w);
|
||||
static int filter_button_add(const char *label, const char *expr, struct filter_expression *newbutton);
|
||||
|
||||
/*
|
||||
* Keep a static pointer to the current "Filter Save" window, if any, so
|
||||
* that if somebody tries to do "Filter Save" while there's already a
|
||||
* "Filter Save" window up, we just pop up the existing one, rather than
|
||||
* creating a new one.
|
||||
*/
|
||||
static GtkWidget *filter_save_frame_w;
|
||||
|
||||
GtkWidget *_filter_tb = NULL;
|
||||
GtkWidget *_filter_te = NULL;
|
||||
|
||||
static GList * filter_buttons = NULL;
|
||||
|
||||
static gboolean
|
||||
add_filter_expression_button(const void *key _U_, void *value, void *user_data _U_)
|
||||
{
|
||||
filter_expression_t* fe = (filter_expression_t*)value;
|
||||
|
||||
filter_button_add(NULL, NULL, fe);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* This does do two things:
|
||||
* - Keep track of the various elements of the Filter Toolbar which will
|
||||
* be needed later when a new button has to be added.
|
||||
* - Since it is called after the preferences are read from the configfile,
|
||||
* this is the one also which creates the initial buttons when the
|
||||
* Filter Toolbar has been created.
|
||||
*/
|
||||
void
|
||||
filter_expression_save_dlg_init(gpointer filter_tb, gpointer filter_te)
|
||||
{
|
||||
_filter_tb = (GtkWidget *)filter_tb;
|
||||
_filter_te = (GtkWidget *)filter_te;
|
||||
|
||||
filter_expression_iterate_expressions(add_filter_expression_button, NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
add_filter_buttons(const void *key _U_, void *value, void *user_data _U_)
|
||||
{
|
||||
filter_expression_t* fe = (filter_expression_t*)value;
|
||||
|
||||
filter_button_add(NULL, NULL, fe);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
filter_expression_reinit(int what)
|
||||
{
|
||||
GList *button_list;
|
||||
if ((what & FILTER_EXPRESSION_REINIT_DESTROY) != 0) {
|
||||
for(button_list = filter_buttons; button_list != NULL; button_list = g_list_next(button_list)) {
|
||||
gtk_widget_destroy((GtkWidget *)button_list->data);
|
||||
}
|
||||
g_list_free(filter_buttons);
|
||||
filter_buttons = NULL;
|
||||
}
|
||||
|
||||
if (what == FILTER_EXPRESSION_REINIT_DESTROY) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((what & FILTER_EXPRESSION_REINIT_CREATE) != 0) {
|
||||
/* XXX - Updating of the filter index was removed
|
||||
when filter expressions were converted to a UAT.
|
||||
This will probably cause some "reordering" bugs,
|
||||
but they should be ignored since GTK GUI is deprecated */
|
||||
filter_expression_iterate_expressions(add_filter_buttons, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
filter_button_add(const char *label, const char *expr, struct filter_expression *newfe)
|
||||
{
|
||||
struct filter_expression *fe;
|
||||
GtkWidget *button;
|
||||
gchar* tooltip;
|
||||
|
||||
/* No duplicate buttons when adding a new one */
|
||||
if (newfe == NULL)
|
||||
fe = filter_expression_new(label, expr, "", TRUE);
|
||||
else
|
||||
fe = newfe;
|
||||
|
||||
if (fe->enabled == FALSE)
|
||||
return(0);
|
||||
|
||||
/* Create the "Label" button */
|
||||
button = (GtkWidget*)gtk_tool_button_new(NULL, fe->label);
|
||||
g_signal_connect(button, "clicked", G_CALLBACK(filter_button_cb),
|
||||
NULL);
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
|
||||
gtk_widget_show(GTK_WIDGET(button));
|
||||
|
||||
gtk_toolbar_insert(GTK_TOOLBAR(_filter_tb), (GtkToolItem *)button, -1);
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(button), TRUE);
|
||||
if (strlen(fe->comment) > 0)
|
||||
{
|
||||
tooltip = g_strdup_printf("%s\n%s", fe->comment, fe->expression);
|
||||
gtk_widget_set_tooltip_text(GTK_WIDGET(button), tooltip);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_set_tooltip_text(GTK_WIDGET(button), fe->expression);
|
||||
}
|
||||
|
||||
fe->button = button;
|
||||
filter_buttons = g_list_append (filter_buttons, button);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
find_match_filter_button(const void *key _U_, void *value, void *user_data)
|
||||
{
|
||||
filter_expression_t* fe = (filter_expression_t*)value;
|
||||
GtkWidget *this_button = (GtkWidget *)user_data;
|
||||
|
||||
if ((void *)fe->button == (void *)this_button) {
|
||||
gtk_entry_set_text(GTK_ENTRY(_filter_te),
|
||||
fe->expression);
|
||||
main_filter_packets(&cfile, fe->expression, FALSE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
filter_button_cb(GtkWidget *this_button, gpointer parent_w _U_)
|
||||
{
|
||||
filter_expression_iterate_expressions(find_match_filter_button, this_button);
|
||||
}
|
||||
|
||||
void
|
||||
filter_expression_save_dlg(gpointer data)
|
||||
{
|
||||
GtkWidget *main_vb, *main_filter_save_hb, *filter_save_frame,
|
||||
*filter_save_type_vb, *filter_save_type_hb, *entry_hb,
|
||||
*bbox, *ok_bt, *cancel_bt, *help_bt, *filter_text_box,
|
||||
*label_text_box;
|
||||
|
||||
const char *expr;
|
||||
|
||||
/* The filter requested */
|
||||
expr = gtk_entry_get_text(GTK_ENTRY(data));
|
||||
|
||||
if (filter_save_frame_w != NULL) {
|
||||
/* There's already a "Filter Save" dialog box; reactivate it. */
|
||||
reactivate_window(filter_save_frame_w);
|
||||
return;
|
||||
}
|
||||
|
||||
filter_save_frame_w = dlg_window_new("Wireshark: Save Filter");
|
||||
|
||||
/* Container for each row of widgets */
|
||||
main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
|
||||
gtk_container_add(GTK_CONTAINER(filter_save_frame_w), main_vb);
|
||||
gtk_widget_show(main_vb);
|
||||
|
||||
|
||||
/* */
|
||||
main_filter_save_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
|
||||
gtk_box_pack_start(GTK_BOX (main_vb), main_filter_save_hb, TRUE, TRUE, 0);
|
||||
gtk_widget_show(main_filter_save_hb);
|
||||
|
||||
/* Filter Save frame */
|
||||
filter_save_frame = gtk_frame_new("Save Filter as...");
|
||||
gtk_box_pack_start(GTK_BOX(main_filter_save_hb), filter_save_frame,
|
||||
TRUE, TRUE, 0);
|
||||
gtk_widget_show(filter_save_frame);
|
||||
|
||||
filter_save_type_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(filter_save_type_vb), 3);
|
||||
gtk_container_add(GTK_CONTAINER(filter_save_frame),
|
||||
filter_save_type_vb);
|
||||
gtk_widget_show(filter_save_type_vb);
|
||||
|
||||
/* filter_save type row */
|
||||
filter_save_type_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
|
||||
gtk_box_pack_start(GTK_BOX (filter_save_type_vb), filter_save_type_hb, TRUE, TRUE, 0);
|
||||
|
||||
gtk_widget_show(filter_save_type_hb);
|
||||
|
||||
/* filter_save row */
|
||||
entry_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
|
||||
gtk_box_pack_start(GTK_BOX(filter_save_type_vb), entry_hb, FALSE,
|
||||
FALSE, 0);
|
||||
gtk_widget_show(entry_hb);
|
||||
|
||||
filter_text_box = gtk_entry_new();
|
||||
gtk_box_pack_start(GTK_BOX(entry_hb), filter_text_box, TRUE, TRUE, 0);
|
||||
g_signal_connect(filter_text_box, "changed", G_CALLBACK(filter_te_syntax_check_cb), NULL);
|
||||
g_signal_connect(filter_text_box, "key-press-event", G_CALLBACK (filter_string_te_key_pressed_cb), NULL);
|
||||
g_signal_connect(filter_save_frame_w, "key-press-event", G_CALLBACK (filter_parent_dlg_key_pressed_cb), NULL);
|
||||
|
||||
gtk_entry_set_text(GTK_ENTRY(filter_text_box), expr);
|
||||
gtk_widget_show(filter_text_box);
|
||||
|
||||
label_text_box = gtk_entry_new();
|
||||
gtk_box_pack_start(GTK_BOX(entry_hb), label_text_box, TRUE, TRUE, 0);
|
||||
gtk_entry_set_text(GTK_ENTRY(label_text_box), "Filter");
|
||||
gtk_widget_show(label_text_box);
|
||||
|
||||
/* Button row */
|
||||
bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL,
|
||||
GTK_STOCK_HELP, NULL);
|
||||
gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show(bbox);
|
||||
|
||||
ok_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
|
||||
g_signal_connect(ok_bt, "clicked", G_CALLBACK(filter_save_ok_cb),
|
||||
filter_save_frame_w);
|
||||
|
||||
cancel_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
|
||||
g_signal_connect(cancel_bt, "clicked", G_CALLBACK(filter_save_close_cb),
|
||||
filter_save_frame_w);
|
||||
|
||||
help_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
|
||||
g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb),
|
||||
(gpointer)HELP_FILTER_SAVE_DIALOG);
|
||||
|
||||
g_object_set_data(G_OBJECT(filter_save_frame_w),
|
||||
E_FILTER_SAVE_EXPR_KEY, filter_text_box);
|
||||
g_object_set_data(G_OBJECT(filter_save_frame_w),
|
||||
E_FILTER_SAVE_LABEL_KEY, label_text_box);
|
||||
|
||||
dlg_set_activate(label_text_box, ok_bt);
|
||||
|
||||
/* Give the initial focus to the "offset" entry box. */
|
||||
gtk_widget_grab_focus(label_text_box);
|
||||
|
||||
g_signal_connect(filter_save_frame_w, "delete_event",
|
||||
G_CALLBACK(window_delete_event_cb), NULL);
|
||||
g_signal_connect(filter_save_frame_w, "destroy",
|
||||
G_CALLBACK(filter_save_frame_destroy_cb), NULL);
|
||||
|
||||
gtk_widget_show(filter_save_frame_w);
|
||||
window_present(filter_save_frame_w);
|
||||
}
|
||||
|
||||
static void
|
||||
filter_save_ok_cb(GtkWidget *ok_bt _U_, GtkWindow *parent_w)
|
||||
{
|
||||
GtkWidget *expr_te, *label_te;
|
||||
const char *expr, *label;
|
||||
|
||||
/* The filter requested */
|
||||
expr_te = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w),
|
||||
E_FILTER_SAVE_EXPR_KEY);
|
||||
label_te = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w),
|
||||
E_FILTER_SAVE_LABEL_KEY);
|
||||
expr = gtk_entry_get_text(GTK_ENTRY(expr_te));
|
||||
label = gtk_entry_get_text(GTK_ENTRY(label_te));
|
||||
|
||||
if (filter_button_add(label, expr, NULL) == 0) {
|
||||
gchar *err = NULL;
|
||||
|
||||
//Filter buttons are just a UAT, so only need to save that
|
||||
uat_save(uat_get_table_by_name("Display expressions"), &err);
|
||||
//ignore any errors
|
||||
g_free(err);
|
||||
filter_save_close_cb(NULL, parent_w);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
filter_save_close_cb(GtkWidget *close_bt _U_, gpointer parent_w)
|
||||
{
|
||||
gtk_grab_remove(GTK_WIDGET(parent_w));
|
||||
window_destroy(GTK_WIDGET(parent_w));
|
||||
}
|
||||
|
||||
static void
|
||||
filter_save_frame_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
|
||||
{
|
||||
/* Note that we no longer have a "Filter Save" dialog box. */
|
||||
filter_save_frame_w = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
||||
* :indentSize=8:tabSize=8:noTabs=false:
|
||||
*/
|
|
@ -1,37 +0,0 @@
|
|||
/* filter_expression_save_dlg.h
|
||||
* Submitted by Edwin Groothuis <wireshark@mavetju.org>
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __FILTER_EXPRESSIONS_SAVE_DLG_H__
|
||||
#define __FILTER_EXPRESSIONS_SAVE_DLG_H__
|
||||
|
||||
#include "epan/filter_expressions.h"
|
||||
|
||||
enum {
|
||||
FILTER_EXPRESSION_REINIT_DESTROY = 1,
|
||||
FILTER_EXPRESSION_REINIT_CREATE = 2
|
||||
};
|
||||
|
||||
extern void filter_expression_save_dlg(gpointer data);
|
||||
void filter_expression_save_dlg_init(gpointer filter_tb, gpointer filter_te);
|
||||
void filter_expression_reinit(int what);
|
||||
|
||||
#endif /* __FILTER_EXPRESSIONS_SAVE_DLG_H__ */
|
|
@ -1,118 +0,0 @@
|
|||
/* filter_utils.c
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ui/gtk/main.h"
|
||||
#include "ui/gtk/gtkglobals.h"
|
||||
#include "ui/gtk/find_dlg.h"
|
||||
#include "ui/gtk/color_dlg.h"
|
||||
#include "ui/gtk/filter_utils.h"
|
||||
|
||||
#include "ui/gtk/old-gtk-compat.h"
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
void
|
||||
apply_selected_filter (guint callback_action, const char *filter)
|
||||
{
|
||||
int action, type;
|
||||
char *str = NULL;
|
||||
const char *current_filter;
|
||||
|
||||
action = FILTER_ACTION(callback_action);
|
||||
type = FILTER_ACTYPE(callback_action);
|
||||
|
||||
current_filter = gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
|
||||
|
||||
switch(type){
|
||||
case ACTYPE_SELECTED:
|
||||
str = g_strdup(filter);
|
||||
break;
|
||||
case ACTYPE_NOT_SELECTED:
|
||||
str = g_strdup_printf("!(%s)", filter);
|
||||
break;
|
||||
case ACTYPE_AND_SELECTED:
|
||||
if ((!current_filter) || (0 == strlen(current_filter)))
|
||||
str = g_strdup(filter);
|
||||
else
|
||||
str = g_strdup_printf("(%s) && (%s)", current_filter, filter);
|
||||
break;
|
||||
case ACTYPE_OR_SELECTED:
|
||||
if ((!current_filter) || (0 == strlen(current_filter)))
|
||||
str = g_strdup(filter);
|
||||
else
|
||||
str = g_strdup_printf("(%s) || (%s)", current_filter, filter);
|
||||
break;
|
||||
case ACTYPE_AND_NOT_SELECTED:
|
||||
if ((!current_filter) || (0 == strlen(current_filter)))
|
||||
str = g_strdup_printf("!(%s)", filter);
|
||||
else
|
||||
str = g_strdup_printf("(%s) && !(%s)", current_filter, filter);
|
||||
break;
|
||||
case ACTYPE_OR_NOT_SELECTED:
|
||||
if ((!current_filter) || (0 == strlen(current_filter)))
|
||||
str = g_strdup_printf("!(%s)", filter);
|
||||
else
|
||||
str = g_strdup_printf("(%s) || !(%s)", current_filter, filter);
|
||||
break;
|
||||
}
|
||||
|
||||
switch(action){
|
||||
case ACTION_MATCH:
|
||||
gtk_entry_set_text(GTK_ENTRY(main_display_filter_widget), str);
|
||||
main_filter_packets(&cfile, str, FALSE);
|
||||
gdk_window_raise(gtk_widget_get_window(top_level));
|
||||
break;
|
||||
case ACTION_PREPARE:
|
||||
gtk_entry_set_text(GTK_ENTRY(main_display_filter_widget), str);
|
||||
break;
|
||||
case ACTION_FIND_FRAME:
|
||||
find_frame_with_filter(str);
|
||||
break;
|
||||
case ACTION_FIND_NEXT:
|
||||
cf_find_packet_dfilter_string(&cfile, str, SD_FORWARD);
|
||||
break;
|
||||
case ACTION_FIND_PREVIOUS:
|
||||
cf_find_packet_dfilter_string(&cfile, str, SD_BACKWARD);
|
||||
break;
|
||||
case ACTION_COLORIZE:
|
||||
color_display_with_filter(str);
|
||||
break;
|
||||
}
|
||||
g_free (str);
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
||||
* :indentSize=8:tabSize=8:noTabs=false:
|
||||
*/
|
|
@ -1,65 +0,0 @@
|
|||
/* filter_utils.h
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __FILTER_UTILS_H__
|
||||
#define __FILTER_UTILS_H__
|
||||
|
||||
#define GTK_MENU_FUNC(a) ((GtkItemFactoryCallback)(a))
|
||||
|
||||
/* Filter actions */
|
||||
#define ACTION_MATCH 0
|
||||
#define ACTION_PREPARE 1
|
||||
#define ACTION_FIND_FRAME 2
|
||||
#define ACTION_FIND_NEXT 3
|
||||
#define ACTION_FIND_PREVIOUS 4
|
||||
#define ACTION_COLORIZE 5
|
||||
#define ACTION_WEB_LOOKUP 6
|
||||
#define ACTION_COPY 7
|
||||
|
||||
|
||||
/* Action type - says what to do with the filter */
|
||||
#define ACTYPE_SELECTED 0
|
||||
#define ACTYPE_NOT_SELECTED 1
|
||||
#define ACTYPE_AND_SELECTED 2
|
||||
#define ACTYPE_OR_SELECTED 3
|
||||
#define ACTYPE_AND_NOT_SELECTED 4
|
||||
#define ACTYPE_OR_NOT_SELECTED 5
|
||||
|
||||
/* Encoded callback arguments */
|
||||
#define CALLBACK_MATCH(type, extra) ((ACTION_MATCH<<16) | ((type)<<8) | (extra))
|
||||
#define CALLBACK_PREPARE(type, extra) ((ACTION_PREPARE<<16) | ((type)<<8) | (extra))
|
||||
#define CALLBACK_FIND_FRAME(type, extra) ((ACTION_FIND_FRAME<<16) | ((type)<<8) | (extra))
|
||||
#define CALLBACK_FIND_NEXT(type, extra) ((ACTION_FIND_NEXT<<16) | ((type)<<8) | (extra))
|
||||
#define CALLBACK_FIND_PREVIOUS(type, extra) ((ACTION_FIND_PREVIOUS<<16) | ((type)<<8) | (extra))
|
||||
#define CALLBACK_COLORIZE(type, extra) ((ACTION_COLORIZE<<16) | ((type)<<8) | (extra))
|
||||
#define CALLBACK_WEB_LOOKUP (ACTION_WEB_LOOKUP<<16)
|
||||
#define CALLBACK_COPY (ACTION_COPY<<16)
|
||||
|
||||
|
||||
/* Extract components of callback argument */
|
||||
#define FILTER_ACTION(cb_arg) (((cb_arg)>>16) & 0xff)
|
||||
#define FILTER_ACTYPE(cb_arg) (((cb_arg)>>8) & 0xff)
|
||||
#define FILTER_EXTRA(cb_arg) ((cb_arg) & 0xff)
|
||||
|
||||
|
||||
extern void apply_selected_filter (guint callback_action, const char *filter);
|
||||
|
||||
#endif /* __FILTER_UTILS_H__ */
|
|
@ -1,803 +0,0 @@
|
|||
/* find_dlg.c
|
||||
* Routines for "find frame" window
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <epan/strutil.h>
|
||||
#include <epan/prefs.h>
|
||||
|
||||
#include "../../globals.h"
|
||||
#include "ui/main_statusbar.h"
|
||||
|
||||
#include "ui/gtk/old-gtk-compat.h"
|
||||
#include "ui/gtk/gui_utils.h"
|
||||
#include "ui/gtk/find_dlg.h"
|
||||
#include "ui/gtk/filter_dlg.h"
|
||||
#include "ui/gtk/dlg_utils.h"
|
||||
#include "ui/gtk/stock_icons.h"
|
||||
#include "ui/gtk/help_dlg.h"
|
||||
#include "ui/gtk/filter_autocomplete.h"
|
||||
|
||||
/* Capture callback data keys */
|
||||
#define E_FIND_FILT_KEY "find_filter_te"
|
||||
#define E_FIND_BACKWARD_KEY "find_backward"
|
||||
#define E_FIND_HEXDATA_KEY "find_hex"
|
||||
#define E_FIND_STRINGDATA_KEY "find_string"
|
||||
#define E_FIND_FILTERDATA_KEY "find_filter"
|
||||
#define E_FIND_STRINGTYPE_KEY "find_string_type"
|
||||
#define E_FIND_STRINGTYPE_LABEL_KEY "find_string_type_label"
|
||||
#define E_CASE_SEARCH_KEY "case_insensitive_search"
|
||||
#define E_SOURCE_DATA_KEY "packet_data_source"
|
||||
#define E_SOURCE_DECODE_KEY "decode_data_source"
|
||||
#define E_SOURCE_SUMMARY_KEY "summary_data_source"
|
||||
#define E_FILT_TE_BUTTON_KEY "find_filter_button"
|
||||
|
||||
static gboolean case_type = TRUE;
|
||||
static gboolean summary_data = FALSE;
|
||||
static gboolean decode_data = FALSE;
|
||||
static gboolean packet_data = FALSE;
|
||||
|
||||
static void
|
||||
find_filter_te_syntax_check_cb(GtkWidget *w, gpointer parent_w);
|
||||
|
||||
static void
|
||||
find_frame_ok_cb(GtkWidget *ok_bt, gpointer parent_w);
|
||||
|
||||
static void
|
||||
find_frame_close_cb(GtkWidget *close_bt, gpointer parent_w);
|
||||
|
||||
static void
|
||||
find_frame_destroy_cb(GtkWidget *win, gpointer user_data);
|
||||
|
||||
static void
|
||||
hex_selected_cb(GtkWidget *button_rb _U_, gpointer parent_w);
|
||||
|
||||
static void
|
||||
string_selected_cb(GtkWidget *button_rb _U_, gpointer parent_w);
|
||||
|
||||
static void
|
||||
filter_selected_cb(GtkWidget *button_rb _U_, gpointer parent_w);
|
||||
|
||||
/*
|
||||
* Keep a static pointer to the current "Find Packet" window, if any, so
|
||||
* that if somebody tries to do "Find Packet" while there's already a
|
||||
* "Find Packet" window up, we just pop up the existing one, rather than
|
||||
* creating a new one.
|
||||
*/
|
||||
static GtkWidget *find_frame_w;
|
||||
static GtkWidget *filter_text_box;
|
||||
|
||||
/*
|
||||
* Save the presskey handlers to be able to dissable the auto-completion
|
||||
* feature for hex and string searches.
|
||||
*/
|
||||
static gulong te_presskey_handler_id;
|
||||
static gulong win_presskey_handler_id;
|
||||
|
||||
void
|
||||
find_frame_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||
{
|
||||
GtkWidget *main_vb, *main_find_hb, *main_options_hb,
|
||||
|
||||
*find_type_frame, *find_type_vb,
|
||||
*find_type_hb, *find_type_lb, *hex_rb, *string_rb, *filter_rb,
|
||||
*filter_hb, *filter_bt,
|
||||
|
||||
*direction_frame, *direction_vb,
|
||||
*up_rb, *down_rb,
|
||||
|
||||
*data_frame, *data_vb,
|
||||
*packet_data_rb, *decode_data_rb, *summary_data_rb,
|
||||
|
||||
*string_opt_frame, *string_opt_vb,
|
||||
*case_cb, *combo_lb, *combo_cb,
|
||||
|
||||
*bbox, *ok_bt, *cancel_bt, *help_bt;
|
||||
|
||||
|
||||
/* No Apply button, but "OK" not only sets our text widget, it
|
||||
activates it (i.e., it causes us to do the search). */
|
||||
static construct_args_t args = {
|
||||
"Wireshark: Search Filter",
|
||||
FALSE,
|
||||
TRUE,
|
||||
FALSE
|
||||
};
|
||||
|
||||
if (find_frame_w != NULL) {
|
||||
/* There's already a "Find Packet" dialog box; reactivate it. */
|
||||
reactivate_window(find_frame_w);
|
||||
return;
|
||||
}
|
||||
|
||||
find_frame_w = dlg_window_new("Wireshark: Find Packet");
|
||||
|
||||
/* Container for each row of widgets */
|
||||
main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
|
||||
gtk_container_add(GTK_CONTAINER(find_frame_w), main_vb);
|
||||
gtk_widget_show(main_vb);
|
||||
|
||||
|
||||
/* */
|
||||
main_find_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
|
||||
gtk_box_pack_start(GTK_BOX (main_vb), main_find_hb, TRUE, TRUE, 0);
|
||||
gtk_widget_show(main_find_hb);
|
||||
|
||||
|
||||
/* find frame */
|
||||
find_type_frame = gtk_frame_new("Find");
|
||||
gtk_box_pack_start(GTK_BOX(main_find_hb), find_type_frame, TRUE, TRUE, 0);
|
||||
gtk_widget_show(find_type_frame);
|
||||
|
||||
find_type_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(find_type_vb), 3);
|
||||
gtk_container_add(GTK_CONTAINER(find_type_frame), find_type_vb);
|
||||
gtk_widget_show(find_type_vb);
|
||||
|
||||
/* find type row */
|
||||
find_type_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
|
||||
gtk_box_pack_start(GTK_BOX (find_type_vb), find_type_hb, TRUE, TRUE, 0);
|
||||
gtk_widget_show(find_type_hb);
|
||||
|
||||
find_type_lb = gtk_label_new("By:");
|
||||
gtk_box_pack_start(GTK_BOX(find_type_hb), find_type_lb, FALSE, FALSE, 0);
|
||||
gtk_widget_show(find_type_lb);
|
||||
|
||||
/* Filter */
|
||||
filter_rb = gtk_radio_button_new_with_mnemonic_from_widget(NULL, "_Display filter");
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filter_rb), !cfile.hex && !cfile.string);
|
||||
gtk_box_pack_start(GTK_BOX(find_type_hb), filter_rb, FALSE, FALSE, 0);
|
||||
gtk_widget_set_tooltip_text(filter_rb, "Search for data by display filter syntax.\ne.g. ip.addr==10.1.1.1");
|
||||
gtk_widget_show(filter_rb);
|
||||
|
||||
/* Hex */
|
||||
hex_rb = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(filter_rb), "_Hex value");
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hex_rb), cfile.hex);
|
||||
gtk_box_pack_start(GTK_BOX(find_type_hb), hex_rb, FALSE, FALSE, 0);
|
||||
gtk_widget_set_tooltip_text(hex_rb, "Search for data by hex string.\ne.g. fffffda5");
|
||||
gtk_widget_show(hex_rb);
|
||||
|
||||
/* ASCII Search */
|
||||
string_rb = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(filter_rb), "_String");
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(string_rb), cfile.string);
|
||||
gtk_box_pack_start(GTK_BOX(find_type_hb), string_rb, FALSE, FALSE, 0);
|
||||
gtk_widget_set_tooltip_text(string_rb, "Search for data by string value.\ne.g. My String");
|
||||
gtk_widget_show(string_rb);
|
||||
|
||||
/* Filter row */
|
||||
filter_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
|
||||
gtk_box_pack_start(GTK_BOX(find_type_vb), filter_hb, FALSE, FALSE, 0);
|
||||
gtk_widget_show(filter_hb);
|
||||
|
||||
filter_bt = ws_gtk_button_new_from_stock(WIRESHARK_STOCK_DISPLAY_FILTER_ENTRY);
|
||||
g_signal_connect(filter_bt, "clicked", G_CALLBACK(display_filter_construct_cb), &args);
|
||||
g_signal_connect(filter_bt, "destroy", G_CALLBACK(filter_button_destroy_cb), NULL);
|
||||
g_object_set_data(G_OBJECT(filter_bt), E_FILT_TE_BUTTON_KEY, filter_bt);
|
||||
gtk_box_pack_start(GTK_BOX(filter_hb), filter_bt, FALSE, TRUE, 0);
|
||||
gtk_widget_set_tooltip_text(filter_bt, "Click on the filter button to select a display filter,\nor enter your search criteria into the text box");
|
||||
gtk_widget_show(filter_bt);
|
||||
|
||||
filter_text_box = gtk_entry_new();
|
||||
if (cfile.sfilter) gtk_entry_set_text(GTK_ENTRY(filter_text_box), cfile.sfilter);
|
||||
g_object_set_data(G_OBJECT(filter_bt), E_FILT_TE_PTR_KEY, filter_text_box);
|
||||
g_object_set_data(G_OBJECT(find_frame_w), E_FILT_TE_PTR_KEY, filter_text_box);
|
||||
gtk_box_pack_start(GTK_BOX(filter_hb), filter_text_box, TRUE, TRUE, 0);
|
||||
g_signal_connect(filter_text_box, "changed", G_CALLBACK(find_filter_te_syntax_check_cb), find_frame_w);
|
||||
g_object_set_data(G_OBJECT(find_frame_w), E_FILT_AUTOCOMP_PTR_KEY, NULL);
|
||||
te_presskey_handler_id = g_signal_connect(filter_text_box, "key-press-event", G_CALLBACK (filter_string_te_key_pressed_cb), NULL);
|
||||
win_presskey_handler_id = g_signal_connect(find_frame_w, "key-press-event", G_CALLBACK (filter_parent_dlg_key_pressed_cb), NULL);
|
||||
gtk_widget_show(filter_text_box);
|
||||
|
||||
|
||||
/* */
|
||||
main_options_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
|
||||
gtk_box_pack_start(GTK_BOX (main_vb), main_options_hb, TRUE, TRUE, 0);
|
||||
gtk_widget_show(main_options_hb);
|
||||
|
||||
|
||||
/* search in frame */
|
||||
data_frame = gtk_frame_new("Search In");
|
||||
gtk_box_pack_start(GTK_BOX(main_options_hb), data_frame, TRUE, TRUE, 0);
|
||||
gtk_widget_show(data_frame);
|
||||
|
||||
/* search in row */
|
||||
data_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(data_vb), 3);
|
||||
gtk_container_add(GTK_CONTAINER(data_frame), data_vb);
|
||||
gtk_widget_show(data_vb);
|
||||
|
||||
/* Packet list */
|
||||
summary_data_rb = gtk_radio_button_new_with_mnemonic_from_widget(NULL, "Packet list");
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(summary_data_rb), summary_data);
|
||||
gtk_box_pack_start(GTK_BOX(data_vb), summary_data_rb, TRUE, TRUE, 0);
|
||||
gtk_widget_set_tooltip_text(summary_data_rb, "Search for string in the Info column of the packet summary (summary pane)");
|
||||
gtk_widget_show(summary_data_rb);
|
||||
|
||||
/* Packet details */
|
||||
decode_data_rb = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(summary_data_rb), "Packet details");
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(decode_data_rb), decode_data);
|
||||
gtk_box_pack_start(GTK_BOX(data_vb), decode_data_rb, TRUE, TRUE, 0);
|
||||
gtk_widget_set_tooltip_text(decode_data_rb, "Search for string among the decoded packet display labels (tree view pane)");
|
||||
gtk_widget_show(decode_data_rb);
|
||||
|
||||
/* Packet bytes */
|
||||
packet_data_rb = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(summary_data_rb), "Packet bytes");
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(packet_data_rb), packet_data);
|
||||
gtk_box_pack_start(GTK_BOX(data_vb), packet_data_rb, TRUE, TRUE, 0);
|
||||
gtk_widget_set_tooltip_text(packet_data_rb, "Search for string in the ASCII-converted packet data (hex view pane)");
|
||||
gtk_widget_show(packet_data_rb);
|
||||
|
||||
/* string options frame */
|
||||
string_opt_frame = gtk_frame_new("String Options");
|
||||
gtk_box_pack_start(GTK_BOX(main_options_hb), string_opt_frame, TRUE, TRUE, 0);
|
||||
gtk_widget_show(string_opt_frame);
|
||||
|
||||
string_opt_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
|
||||
gtk_container_add(GTK_CONTAINER(string_opt_frame), string_opt_vb);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(string_opt_vb), 3);
|
||||
gtk_widget_show(string_opt_vb);
|
||||
|
||||
case_cb = gtk_check_button_new_with_mnemonic("Case sensitive");
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(case_cb), !case_type);
|
||||
gtk_box_pack_start(GTK_BOX (string_opt_vb), case_cb, TRUE, TRUE, 0);
|
||||
gtk_widget_set_tooltip_text(case_cb, "Search by mixed upper/lower case?");
|
||||
gtk_widget_show(case_cb);
|
||||
|
||||
combo_lb = gtk_label_new("Character width:");
|
||||
gtk_box_pack_start(GTK_BOX (string_opt_vb), combo_lb, TRUE, TRUE, 0);
|
||||
gtk_misc_set_alignment(GTK_MISC(combo_lb), 0.0f, 0.5f);
|
||||
gtk_widget_show(combo_lb);
|
||||
|
||||
/* Character Type Selection Dropdown Box
|
||||
These only apply to the string find option */
|
||||
/* Create Combo Box */
|
||||
|
||||
combo_cb = gtk_combo_box_text_new();
|
||||
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(combo_cb), "Narrow & wide");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(combo_cb), "Narrow (UTF-8 / ASCII)");
|
||||
/* UCS-2 might be more accurate but then we'd have to explain why we don't support UTF-16 */
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(combo_cb), "Wide (UTF-16)");
|
||||
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_cb),0);
|
||||
gtk_box_pack_start(GTK_BOX (string_opt_vb), combo_cb, TRUE, TRUE, 0);
|
||||
|
||||
gtk_widget_show(combo_cb);
|
||||
|
||||
|
||||
/* direction frame */
|
||||
direction_frame = gtk_frame_new("Direction");
|
||||
gtk_box_pack_start(GTK_BOX(main_options_hb), direction_frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show(direction_frame);
|
||||
|
||||
/* Direction row: Forward and reverse radio buttons */
|
||||
direction_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(direction_vb), 3);
|
||||
gtk_container_add(GTK_CONTAINER(direction_frame), direction_vb);
|
||||
gtk_widget_show(direction_vb);
|
||||
|
||||
up_rb = gtk_radio_button_new_with_mnemonic_from_widget(NULL, "_Up");
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(up_rb), cfile.dir == SD_BACKWARD);
|
||||
gtk_box_pack_start(GTK_BOX(direction_vb), up_rb, FALSE, FALSE, 0);
|
||||
gtk_widget_show(up_rb);
|
||||
|
||||
down_rb = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(up_rb), "_Down");
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(down_rb), cfile.dir == SD_FORWARD);
|
||||
gtk_box_pack_start(GTK_BOX(direction_vb), down_rb, FALSE, FALSE, 0);
|
||||
gtk_widget_show(down_rb);
|
||||
|
||||
|
||||
/* Button row */
|
||||
bbox = dlg_button_row_new(GTK_STOCK_FIND, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
|
||||
gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show(bbox);
|
||||
|
||||
ok_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_FIND);
|
||||
g_signal_connect(ok_bt, "clicked", G_CALLBACK(find_frame_ok_cb), find_frame_w);
|
||||
|
||||
cancel_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
|
||||
g_signal_connect(cancel_bt, "clicked", G_CALLBACK(find_frame_close_cb), find_frame_w);
|
||||
|
||||
help_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
|
||||
g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb), (gpointer)HELP_FIND_DIALOG);
|
||||
|
||||
/* Attach pointers to needed widgets to the capture prefs window/object */
|
||||
g_object_set_data(G_OBJECT(find_frame_w), E_FIND_FILT_KEY, filter_text_box);
|
||||
g_object_set_data(G_OBJECT(find_frame_w), E_FIND_BACKWARD_KEY, up_rb);
|
||||
g_object_set_data(G_OBJECT(find_frame_w), E_FIND_FILTERDATA_KEY, filter_rb);
|
||||
g_object_set_data(G_OBJECT(find_frame_w), E_FIND_HEXDATA_KEY, hex_rb);
|
||||
g_object_set_data(G_OBJECT(find_frame_w), E_FIND_STRINGDATA_KEY, string_rb);
|
||||
g_object_set_data(G_OBJECT(find_frame_w), E_FIND_STRINGTYPE_LABEL_KEY, combo_lb);
|
||||
g_object_set_data(G_OBJECT(find_frame_w), E_FIND_STRINGTYPE_KEY, combo_cb);
|
||||
g_object_set_data(G_OBJECT(find_frame_w), E_CASE_SEARCH_KEY, case_cb);
|
||||
g_object_set_data(G_OBJECT(find_frame_w), E_SOURCE_DATA_KEY, packet_data_rb);
|
||||
g_object_set_data(G_OBJECT(find_frame_w), E_SOURCE_DECODE_KEY, decode_data_rb);
|
||||
g_object_set_data(G_OBJECT(find_frame_w), E_SOURCE_SUMMARY_KEY, summary_data_rb);
|
||||
g_object_set_data(G_OBJECT(find_frame_w), E_FILT_TE_BUTTON_KEY, filter_bt);
|
||||
|
||||
/*
|
||||
* Now that we've attached the pointers, connect the signals - if
|
||||
* we do so before we've attached the pointers, the signals may
|
||||
* be delivered before the pointers are attached; the signal
|
||||
* handlers expect the pointers to be attached, and won't be happy.
|
||||
*/
|
||||
g_signal_connect(hex_rb, "clicked", G_CALLBACK(hex_selected_cb), find_frame_w);
|
||||
g_signal_connect(string_rb, "clicked", G_CALLBACK(string_selected_cb), find_frame_w);
|
||||
g_signal_connect(filter_rb, "clicked", G_CALLBACK(filter_selected_cb), find_frame_w);
|
||||
|
||||
string_selected_cb(NULL, find_frame_w);
|
||||
filter_selected_cb(NULL, find_frame_w);
|
||||
|
||||
window_set_cancel_button(find_frame_w, cancel_bt, window_cancel_button_cb);
|
||||
|
||||
gtk_widget_grab_default(ok_bt);
|
||||
|
||||
/* Catch the "activate" signal on the filter text entry, so that
|
||||
if the user types Return there, we act as if the "OK" button
|
||||
had been selected, as happens if Return is typed if some widget
|
||||
that *doesn't* handle the Return key has the input focus. */
|
||||
dlg_set_activate(filter_text_box, ok_bt);
|
||||
|
||||
/* Give the initial focus to the "Filter" entry box. */
|
||||
gtk_widget_grab_focus(filter_text_box);
|
||||
|
||||
g_signal_connect(find_frame_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
||||
g_signal_connect(find_frame_w, "destroy", G_CALLBACK(find_frame_destroy_cb), NULL);
|
||||
|
||||
gtk_widget_show(find_frame_w);
|
||||
window_present(find_frame_w);
|
||||
}
|
||||
|
||||
/* this function opens the find frame dialogue and sets the filter string */
|
||||
void
|
||||
find_frame_with_filter(char *filter)
|
||||
{
|
||||
find_frame_cb(NULL, NULL);
|
||||
gtk_entry_set_text(GTK_ENTRY(filter_text_box), filter);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check the filter syntax based on the type of search we're doing.
|
||||
*/
|
||||
static void
|
||||
find_filter_te_syntax_check_cb(GtkWidget *w, gpointer parent_w)
|
||||
{
|
||||
const gchar *strval;
|
||||
GtkWidget *hex_rb, *string_rb;
|
||||
guint8 *bytes = NULL;
|
||||
size_t nbytes;
|
||||
|
||||
hex_rb = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_FIND_HEXDATA_KEY);
|
||||
string_rb = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_FIND_STRINGDATA_KEY);
|
||||
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (hex_rb))) {
|
||||
/*
|
||||
* Hex search - scan the search string to make sure it's valid hex.
|
||||
*/
|
||||
strval = gtk_entry_get_text(GTK_ENTRY(w));
|
||||
if (strval == NULL) {
|
||||
/* XXX - can this happen? */
|
||||
colorize_filter_te_as_invalid(w);
|
||||
} else {
|
||||
bytes = convert_string_to_hex(strval, &nbytes);
|
||||
if (bytes == NULL)
|
||||
colorize_filter_te_as_invalid(w);
|
||||
else {
|
||||
g_free(bytes);
|
||||
colorize_filter_te_as_valid(w);
|
||||
}
|
||||
}
|
||||
} else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (string_rb))) {
|
||||
/*
|
||||
* String search. Make sure the string isn't empty.
|
||||
*/
|
||||
strval = gtk_entry_get_text(GTK_ENTRY(w));
|
||||
if (strval == NULL) {
|
||||
/* XXX - can this happen? */
|
||||
colorize_filter_te_as_invalid(w);
|
||||
} else {
|
||||
if (strcmp(strval, "") == 0)
|
||||
colorize_filter_te_as_invalid(w);
|
||||
else
|
||||
colorize_filter_te_as_valid(w);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Display filter search; check it with "filter_te_syntax_check_cb()".
|
||||
*/
|
||||
filter_te_syntax_check_cb(w, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This function will re-check the search text syntax.
|
||||
*/
|
||||
static void
|
||||
hex_selected_cb(GtkWidget *button_rb _U_, gpointer parent_w)
|
||||
{
|
||||
GtkWidget *filter_tb, *hex_rb, *filter_entry;
|
||||
|
||||
filter_tb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_FILT_TE_PTR_KEY);
|
||||
hex_rb = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_FIND_HEXDATA_KEY);
|
||||
|
||||
filter_entry = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w),E_FIND_FILT_KEY);
|
||||
gtk_widget_grab_focus(filter_entry);
|
||||
|
||||
/* Disable AutoCompletion feature */
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hex_rb)) && g_signal_handler_is_connected(filter_tb, te_presskey_handler_id)) {
|
||||
g_signal_handler_disconnect(filter_tb, te_presskey_handler_id);
|
||||
g_signal_handler_disconnect(parent_w, win_presskey_handler_id);
|
||||
}
|
||||
|
||||
/* Re-check the display filter. */
|
||||
find_filter_te_syntax_check_cb(filter_tb, parent_w);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function will disable the string options until
|
||||
* the string search is selected.
|
||||
*/
|
||||
static void
|
||||
string_selected_cb(GtkWidget *button_rb _U_, gpointer parent_w)
|
||||
{
|
||||
GtkWidget *string_rb, *packet_data_rb, *decode_data_rb, *summary_data_rb,
|
||||
*data_combo_lb, *data_combo_cb, *data_case_cb, *filter_tb, *filter_entry;
|
||||
|
||||
string_rb = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_FIND_STRINGDATA_KEY);
|
||||
packet_data_rb = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_SOURCE_DATA_KEY);
|
||||
decode_data_rb = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_SOURCE_DECODE_KEY);
|
||||
summary_data_rb = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_SOURCE_SUMMARY_KEY);
|
||||
|
||||
data_combo_lb = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_FIND_STRINGTYPE_LABEL_KEY);
|
||||
data_combo_cb = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_FIND_STRINGTYPE_KEY);
|
||||
data_case_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CASE_SEARCH_KEY);
|
||||
filter_tb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_FILT_TE_PTR_KEY);
|
||||
|
||||
filter_entry = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w),E_FIND_FILT_KEY);
|
||||
gtk_widget_grab_focus(filter_entry);
|
||||
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(string_rb))) {
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(packet_data_rb), TRUE);
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(decode_data_rb), TRUE);
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(summary_data_rb), TRUE);
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(data_combo_lb), TRUE);
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(data_combo_cb), TRUE);
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(data_case_cb), TRUE);
|
||||
|
||||
/* Disable AutoCompletion feature */
|
||||
if(g_signal_handler_is_connected(filter_tb, te_presskey_handler_id)) {
|
||||
g_signal_handler_disconnect(filter_tb, te_presskey_handler_id);
|
||||
g_signal_handler_disconnect(parent_w, win_presskey_handler_id);
|
||||
}
|
||||
|
||||
} else {
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(packet_data_rb), FALSE);
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(decode_data_rb), FALSE);
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(summary_data_rb), FALSE);
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(data_combo_lb), FALSE);
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(data_combo_cb), FALSE);
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(data_case_cb), FALSE);
|
||||
}
|
||||
/* Re-check the display filter. */
|
||||
find_filter_te_syntax_check_cb(filter_tb, parent_w);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function will disable the filter button until
|
||||
* the filter search is selected.
|
||||
*/
|
||||
static void
|
||||
filter_selected_cb(GtkWidget *button_rb _U_, gpointer parent_w)
|
||||
{
|
||||
GtkWidget *filter_bt, *filter_rb, *filter_te, *filter_entry;
|
||||
|
||||
filter_bt = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_FILT_TE_BUTTON_KEY);
|
||||
filter_rb = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_FIND_FILTERDATA_KEY);
|
||||
filter_te = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_FILT_TE_PTR_KEY);
|
||||
|
||||
filter_entry = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w),E_FIND_FILT_KEY);
|
||||
gtk_widget_grab_focus(filter_entry);
|
||||
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filter_rb)))
|
||||
{
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(filter_bt), TRUE);
|
||||
/* Enable AutoCompletion feature */
|
||||
if(!g_signal_handler_is_connected(filter_te, te_presskey_handler_id)) {
|
||||
te_presskey_handler_id = g_signal_connect(filter_te, "key-press-event", G_CALLBACK (filter_string_te_key_pressed_cb), NULL);
|
||||
win_presskey_handler_id = g_signal_connect(parent_w, "key-press-event", G_CALLBACK (filter_parent_dlg_key_pressed_cb), NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(filter_bt), FALSE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
find_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
|
||||
{
|
||||
GtkWidget *filter_te, *up_rb, *hex_rb, *string_rb, *combo_cb,
|
||||
*case_cb, *packet_data_rb, *decode_data_rb, *summary_data_rb;
|
||||
const gchar *filter_text;
|
||||
search_charset_t scs_type = SCS_NARROW_AND_WIDE;
|
||||
guint8 *bytes = NULL;
|
||||
size_t nbytes = 0;
|
||||
char *string = NULL;
|
||||
dfilter_t *sfcode = NULL;
|
||||
gboolean found_packet=FALSE;
|
||||
gboolean hex_search;
|
||||
gboolean string_search;
|
||||
int string_type;
|
||||
|
||||
filter_te = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_FIND_FILT_KEY);
|
||||
up_rb = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_FIND_BACKWARD_KEY);
|
||||
hex_rb = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_FIND_HEXDATA_KEY);
|
||||
string_rb = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_FIND_STRINGDATA_KEY);
|
||||
combo_cb = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_FIND_STRINGTYPE_KEY);
|
||||
case_cb = (GtkWidget *) g_object_get_data(G_OBJECT(parent_w), E_CASE_SEARCH_KEY);
|
||||
packet_data_rb = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_SOURCE_DATA_KEY);
|
||||
decode_data_rb = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_SOURCE_DECODE_KEY);
|
||||
summary_data_rb = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_SOURCE_SUMMARY_KEY);
|
||||
|
||||
filter_text = gtk_entry_get_text(GTK_ENTRY(filter_te));
|
||||
|
||||
/* Corresponds to the enum in file.c
|
||||
* Character set for text search.
|
||||
* typedef enum {
|
||||
* SCS_NARROW_AND_WIDE,
|
||||
* SCS_NARROW,
|
||||
* SCS_WIDE
|
||||
* / * add EBCDIC when it's implemented * /
|
||||
* } search_charset_t;
|
||||
*/
|
||||
string_type = gtk_combo_box_get_active (GTK_COMBO_BOX(combo_cb));
|
||||
|
||||
case_type = !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(case_cb));
|
||||
packet_data = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(packet_data_rb));
|
||||
decode_data = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(decode_data_rb));
|
||||
summary_data = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(summary_data_rb));
|
||||
hex_search = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (hex_rb));
|
||||
string_search = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (string_rb));
|
||||
/*
|
||||
* Process the search criterion.
|
||||
*/
|
||||
if (hex_search) {
|
||||
/*
|
||||
* Hex search - scan the search string to make sure it's valid hex
|
||||
* and to find out how many bytes there are.
|
||||
*/
|
||||
bytes = convert_string_to_hex(filter_text, &nbytes);
|
||||
if (bytes == NULL) {
|
||||
statusbar_push_temporary_msg("That's not a valid hex string.");
|
||||
return;
|
||||
}
|
||||
} else if (string_search) {
|
||||
/*
|
||||
* String search.
|
||||
* Make sure we're searching for something, first.
|
||||
*/
|
||||
if (strcmp(filter_text, "") == 0) {
|
||||
statusbar_push_temporary_msg("You didn't specify any text for which to search.");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* We are - get the character set type.
|
||||
*/
|
||||
if (string_type == SCS_NARROW_AND_WIDE)
|
||||
scs_type = SCS_NARROW_AND_WIDE;
|
||||
else if (string_type == SCS_NARROW)
|
||||
scs_type = SCS_NARROW;
|
||||
else if (string_type == SCS_WIDE)
|
||||
scs_type = SCS_WIDE;
|
||||
else {
|
||||
statusbar_push_temporary_msg("You didn't choose a valid character set.");
|
||||
return;
|
||||
}
|
||||
string = convert_string_case(filter_text, case_type);
|
||||
} else {
|
||||
/*
|
||||
* Display filter search - try to compile the filter.
|
||||
*/
|
||||
gchar *err_msg;
|
||||
|
||||
if (!dfilter_compile(filter_text, &sfcode, &err_msg)) {
|
||||
/* The attempt failed; report an error. */
|
||||
bad_dfilter_alert_box(GTK_WIDGET(parent_w), filter_text, err_msg);
|
||||
g_free(err_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Was it empty? */
|
||||
if (sfcode == NULL) {
|
||||
/* Yes - complain. */
|
||||
statusbar_push_temporary_msg("That filter doesn't test anything.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Remember the search parameters.
|
||||
*/
|
||||
g_free(cfile.sfilter);
|
||||
cfile.sfilter = g_strdup(filter_text);
|
||||
cfile.dir = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (up_rb)) ? SD_BACKWARD : SD_FORWARD;
|
||||
cfile.hex = hex_search;
|
||||
cfile.string = string_search;
|
||||
cfile.scs_type = scs_type;
|
||||
cfile.case_type = case_type;
|
||||
cfile.regex = NULL;
|
||||
cfile.packet_data = packet_data;
|
||||
cfile.decode_data = decode_data;
|
||||
cfile.summary_data = summary_data;
|
||||
|
||||
if (cfile.hex) {
|
||||
/* Hex value in packet data */
|
||||
found_packet = cf_find_packet_data(&cfile, bytes, nbytes, cfile.dir);
|
||||
g_free(bytes);
|
||||
if (!found_packet) {
|
||||
/* We didn't find a packet */
|
||||
statusbar_push_temporary_msg("No packet contained those bytes.");
|
||||
return;
|
||||
}
|
||||
} else if (cfile.string) {
|
||||
if (cfile.summary_data) {
|
||||
/* String in the Info column of the summary line */
|
||||
found_packet = cf_find_packet_summary_line(&cfile, string, cfile.dir);
|
||||
g_free(string);
|
||||
if (!found_packet) {
|
||||
statusbar_push_temporary_msg("No packet contained that string in its Info column.");
|
||||
return;
|
||||
}
|
||||
} else if (cfile.decode_data) {
|
||||
/* String in the protocol tree headings */
|
||||
found_packet = cf_find_packet_protocol_tree(&cfile, string, cfile.dir);
|
||||
g_free(string);
|
||||
if (!found_packet) {
|
||||
statusbar_push_temporary_msg("No packet contained that string in its dissected display.");
|
||||
return;
|
||||
}
|
||||
} else if (cfile.packet_data && string) {
|
||||
/* String in the ASCII-converted packet data */
|
||||
found_packet = cf_find_packet_data(&cfile, string, strlen(string), cfile.dir);
|
||||
g_free(string);
|
||||
if (!found_packet) {
|
||||
statusbar_push_temporary_msg("No packet contained that string in its ASCII-converted data.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Search via display filter */
|
||||
found_packet = cf_find_packet_dfilter(&cfile, sfcode, cfile.dir);
|
||||
dfilter_free(sfcode);
|
||||
if (!found_packet) {
|
||||
statusbar_push_temporary_msg("No packet matched that filter.");
|
||||
g_free(bytes);
|
||||
return;
|
||||
}
|
||||
}
|
||||
window_destroy(GTK_WIDGET(parent_w));
|
||||
}
|
||||
|
||||
static void
|
||||
find_frame_close_cb(GtkWidget *close_bt _U_, gpointer parent_w)
|
||||
{
|
||||
gtk_grab_remove(GTK_WIDGET(parent_w));
|
||||
window_destroy(GTK_WIDGET(parent_w));
|
||||
}
|
||||
|
||||
static void
|
||||
find_frame_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
|
||||
{
|
||||
/* Note that we no longer have a "Find Packet" dialog box. */
|
||||
find_frame_w = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
find_previous_next(GtkWidget *w, gpointer d, search_direction dir)
|
||||
{
|
||||
guint8 *bytes;
|
||||
size_t nbytes;
|
||||
char *string;
|
||||
dfilter_t *sfcode;
|
||||
|
||||
if (cfile.sfilter) {
|
||||
cfile.dir = dir;
|
||||
if (cfile.hex) {
|
||||
bytes = convert_string_to_hex(cfile.sfilter, &nbytes);
|
||||
if (bytes == NULL) {
|
||||
/*
|
||||
* XXX - this shouldn't happen, as we've already successfully
|
||||
* translated the string once.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
cf_find_packet_data(&cfile, bytes, nbytes, dir);
|
||||
g_free(bytes);
|
||||
} else if (cfile.string) {
|
||||
string = convert_string_case(cfile.sfilter, cfile.case_type);
|
||||
/* OK, what are we searching? */
|
||||
if (cfile.decode_data) {
|
||||
/* The text in the protocol tree */
|
||||
cf_find_packet_protocol_tree(&cfile, string, dir);
|
||||
} else if (cfile.summary_data) {
|
||||
/* The text in the summary line */
|
||||
cf_find_packet_summary_line(&cfile, string, dir);
|
||||
} else {
|
||||
/* The raw packet data */
|
||||
cf_find_packet_data(&cfile, string, strlen(string), dir);
|
||||
}
|
||||
g_free(string);
|
||||
} else {
|
||||
if (!dfilter_compile(cfile.sfilter, &sfcode, NULL)) {
|
||||
/*
|
||||
* XXX - this shouldn't happen, as we've already successfully
|
||||
* translated the string once.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
if (sfcode == NULL) {
|
||||
/*
|
||||
* XXX - this shouldn't happen, as we've already found that the
|
||||
* string wasn't null.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
cf_find_packet_dfilter(&cfile, sfcode, dir);
|
||||
dfilter_free(sfcode);
|
||||
}
|
||||
} else
|
||||
find_frame_cb(w, d);
|
||||
}
|
||||
|
||||
void
|
||||
find_next_cb(GtkWidget *w , gpointer d)
|
||||
{
|
||||
find_previous_next(w, d, SD_FORWARD);
|
||||
}
|
||||
|
||||
void
|
||||
find_previous_cb(GtkWidget *w , gpointer d)
|
||||
{
|
||||
find_previous_next(w, d, SD_BACKWARD);
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local Variables:
|
||||
* c-basic-offset: 2
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=2 tabstop=8 expandtab:
|
||||
* :indentSize=2:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -1,59 +0,0 @@
|
|||
/* find_dlg.h
|
||||
* Definitions for "find frame" window
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __FIND_DLG_H__
|
||||
#define __FIND_DLG_H__
|
||||
|
||||
/** @file
|
||||
* "Find" dialog box and related functions.
|
||||
* @ingroup dialog_group
|
||||
*/
|
||||
|
||||
/** User requested the "Find" dialog box by menu or toolbar.
|
||||
*
|
||||
* @param widget parent widget (unused)
|
||||
* @param data unused
|
||||
*/
|
||||
extern void find_frame_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
/** User requested the "Find Next" function.
|
||||
*
|
||||
* @param widget parent widget (unused)
|
||||
* @param data unused
|
||||
*/
|
||||
extern void find_next_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
/** User requested the "Find Previous" function.
|
||||
*
|
||||
* @param widget parent widget (unused)
|
||||
* @param data unused
|
||||
*/
|
||||
extern void find_previous_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
/** Find frame by filter.
|
||||
*
|
||||
* @param filter the filter string
|
||||
*/
|
||||
extern void find_frame_with_filter(char *filter);
|
||||
|
||||
#endif /* find_dlg.h */
|
|
@ -1,549 +0,0 @@
|
|||
/* firewall_rules_dlg.c
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Generate firewall ACL rules based on packet addresses and ports.
|
||||
* For directional rules, an outside interface is assumed.
|
||||
*
|
||||
* There may be better ways to present the information, e.g. all rules
|
||||
* in one huge text window, or some sort of tree view.
|
||||
*/
|
||||
|
||||
/* Copied from ssl-dlg.c */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <epan/packet.h>
|
||||
#include <epan/addr_resolv.h>
|
||||
#include <epan/epan_dissect.h>
|
||||
#include <wsutil/filesystem.h>
|
||||
|
||||
#include <ui/alert_box.h>
|
||||
#include <ui/firewall_rules.h>
|
||||
#include <ui/last_open_dir.h>
|
||||
|
||||
#include <wsutil/file_util.h>
|
||||
|
||||
#include "ui/gtk/main.h"
|
||||
#include "ui/gtk/dlg_utils.h"
|
||||
#include "ui/gtk/file_dlg.h"
|
||||
#include "ui/gtk/help_dlg.h"
|
||||
#include "ui/gtk/gui_utils.h"
|
||||
#include "ui/gtk/old-gtk-compat.h"
|
||||
#include "ui/gtk/firewall_dlg.h"
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
#define MAX_RULE_LEN 200
|
||||
|
||||
/* Copied from packet_info struct */
|
||||
typedef struct _rule_info_t {
|
||||
size_t product;
|
||||
address dl_src;
|
||||
address dl_dst;
|
||||
address net_src;
|
||||
address net_dst;
|
||||
port_type ptype;
|
||||
guint32 srcport;
|
||||
guint32 destport;
|
||||
GtkWidget *text;
|
||||
GtkWidget *filter_combo_box;
|
||||
GtkWidget *deny_cb;
|
||||
GtkWidget *inbound_cb;
|
||||
gboolean inbound;
|
||||
gboolean deny;
|
||||
rule_type_e rule_type;
|
||||
} rule_info_t;
|
||||
|
||||
static void sf_dummy(GString *rtxt, gchar *addr, guint32 port, port_type ptype, gboolean inbound, gboolean deny);
|
||||
|
||||
static void select_product(GtkWidget * win, gpointer data);
|
||||
static void select_filter(GtkWidget * win, gpointer data);
|
||||
static void toggle_inbound(GtkToggleButton *t, gpointer data);
|
||||
static void toggle_deny(GtkToggleButton *t, gpointer data);
|
||||
static void set_rule_text(rule_info_t *rule_info);
|
||||
static void firewall_destroy_cb(GtkWidget * win, gpointer data);
|
||||
static void firewall_copy_cmd_cb(GtkWidget * w, gpointer data);
|
||||
static void firewall_save_as_cmd_cb(GtkWidget * w, gpointer data);
|
||||
|
||||
#define WS_RULE_INFO_KEY "rule_info_key"
|
||||
|
||||
#if 0
|
||||
/* List of "rule_info_t" structures for all rule windows. */
|
||||
static GList *rule_infos;
|
||||
|
||||
/* Remove a "rule_info_t" structure from the list. */
|
||||
static void
|
||||
forget_rule_info(rule_info_t *rule_info)
|
||||
{
|
||||
rule_infos = g_list_remove(rule_infos, rule_info);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
firewall_rule_cb(GtkWidget *w _U_, gpointer data _U_)
|
||||
{
|
||||
GtkWidget *rule_w, *vbox, *txt_scrollw, *text;
|
||||
GtkWidget *label, *product_combo_box;
|
||||
GtkWidget *hbox, *button_hbox, *button;
|
||||
rule_info_t *rule_info;
|
||||
packet_info *pinfo = &cfile.edt->pi;
|
||||
size_t i;
|
||||
|
||||
rule_info = g_new0(rule_info_t, 1);
|
||||
copy_address(&(rule_info->dl_src), &(pinfo->dl_src));
|
||||
copy_address(&(rule_info->dl_dst), &(pinfo->dl_dst));
|
||||
copy_address(&(rule_info->net_src), &(pinfo->net_src));
|
||||
copy_address(&(rule_info->net_dst), &(pinfo->net_dst));
|
||||
rule_info->ptype = pinfo->ptype;
|
||||
rule_info->srcport = pinfo->srcport;
|
||||
rule_info->destport = pinfo->destport;
|
||||
rule_info->inbound = TRUE;
|
||||
rule_info->deny = TRUE;
|
||||
rule_info->product = 0;
|
||||
|
||||
rule_w = dlg_window_new("Firewall ACL Rules");
|
||||
|
||||
gtk_widget_set_name(rule_w, "Firewall ACL rule window");
|
||||
gtk_container_set_border_width(GTK_CONTAINER(rule_w), 6);
|
||||
|
||||
/* setup the container */
|
||||
vbox = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE);
|
||||
gtk_container_add(GTK_CONTAINER(rule_w), vbox);
|
||||
|
||||
/* rule type selectors hbox */
|
||||
hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1, FALSE);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
|
||||
|
||||
/* product selector */
|
||||
label = gtk_label_new("Product");
|
||||
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
|
||||
|
||||
product_combo_box = gtk_combo_box_text_new();
|
||||
for (i = 0; i < firewall_product_count(); i++) {
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(product_combo_box), firewall_product_name(i));
|
||||
}
|
||||
g_object_set_data(G_OBJECT(product_combo_box), WS_RULE_INFO_KEY, rule_info);
|
||||
g_signal_connect(product_combo_box, "changed", G_CALLBACK(select_product), NULL);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), product_combo_box, FALSE, FALSE, 5);
|
||||
|
||||
/* type selector */
|
||||
label = gtk_label_new("Filter");
|
||||
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 10);
|
||||
|
||||
rule_info->filter_combo_box = ws_combo_box_new_text_and_pointer();
|
||||
g_object_set_data(G_OBJECT(rule_info->filter_combo_box), WS_RULE_INFO_KEY, rule_info); \
|
||||
g_signal_connect(rule_info->filter_combo_box, "changed", G_CALLBACK(select_filter), NULL);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), rule_info->filter_combo_box, FALSE, FALSE, 5);
|
||||
|
||||
/* inbound selector */
|
||||
rule_info->inbound_cb = gtk_check_button_new_with_label("Inbound");
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rule_info->inbound_cb),
|
||||
rule_info->inbound);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), rule_info->inbound_cb, FALSE, FALSE, 10);
|
||||
g_signal_connect(rule_info->inbound_cb, "toggled", G_CALLBACK(toggle_inbound), rule_info);
|
||||
|
||||
/* deny selector */
|
||||
rule_info->deny_cb = gtk_check_button_new_with_label("Deny");
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rule_info->deny_cb),
|
||||
rule_info->deny);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), rule_info->deny_cb, FALSE, FALSE, 10);
|
||||
g_signal_connect(rule_info->deny_cb, "toggled", G_CALLBACK(toggle_deny), rule_info);
|
||||
|
||||
/* create a scrolled window for the text */
|
||||
txt_scrollw = scrolled_window_new(NULL, NULL);
|
||||
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(txt_scrollw),
|
||||
GTK_SHADOW_IN);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), txt_scrollw, TRUE, TRUE, 0);
|
||||
|
||||
/* create a text box */
|
||||
text = gtk_text_view_new();
|
||||
gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
|
||||
gtk_container_add(GTK_CONTAINER(txt_scrollw), text);
|
||||
rule_info->text = text;
|
||||
|
||||
/* Button row */
|
||||
button_hbox = dlg_button_row_new(GTK_STOCK_HELP, GTK_STOCK_COPY, GTK_STOCK_SAVE, GTK_STOCK_CANCEL, NULL);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), button_hbox, FALSE, FALSE, 0);
|
||||
|
||||
/* Create Copy Button */
|
||||
button = (GtkWidget *)g_object_get_data(G_OBJECT(button_hbox), GTK_STOCK_COPY);
|
||||
g_signal_connect(button, "clicked", G_CALLBACK(firewall_copy_cmd_cb), rule_info);
|
||||
gtk_widget_set_tooltip_text(button, "Copy rule to clipboard");
|
||||
|
||||
/* Create Save Button */
|
||||
button = (GtkWidget *)g_object_get_data(G_OBJECT(button_hbox), GTK_STOCK_SAVE);
|
||||
g_signal_connect(button, "clicked", G_CALLBACK(firewall_save_as_cmd_cb), rule_info);
|
||||
gtk_widget_set_tooltip_text(button, "Save the rule as currently displayed");
|
||||
|
||||
button = (GtkWidget *)g_object_get_data(G_OBJECT(button_hbox), GTK_STOCK_CANCEL);
|
||||
gtk_widget_set_tooltip_text(button, "Cancel the dialog");
|
||||
window_set_cancel_button(rule_w, button, window_cancel_button_cb);
|
||||
|
||||
button = (GtkWidget *)g_object_get_data(G_OBJECT(button_hbox), GTK_STOCK_HELP);
|
||||
g_signal_connect(button, "clicked", G_CALLBACK(topic_cb), (gpointer)HELP_FIREWALL_DIALOG);
|
||||
|
||||
/* Tuck away the rule_info object into the window */
|
||||
g_object_set_data(G_OBJECT(rule_w), WS_RULE_INFO_KEY, rule_info);
|
||||
|
||||
g_signal_connect(rule_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
||||
g_signal_connect(rule_w, "destroy", G_CALLBACK(firewall_destroy_cb), NULL);
|
||||
|
||||
/* Make sure this widget gets destroyed if we quit the main loop,
|
||||
so that if we exit, we clean up any temporary files we have
|
||||
for "Follow SSL Stream" windows.
|
||||
gtk_quit_add_destroy is deprecated and should not be used in newly-written code. This function is going to be removed in GTK+ 3.0
|
||||
|
||||
gtk_quit_add_destroy(gtk_main_level(), GTK_OBJECT(rule_w));
|
||||
|
||||
*/
|
||||
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(product_combo_box), 0); /* invokes select_product callback */
|
||||
gtk_widget_show_all(rule_w);
|
||||
window_present(rule_w);
|
||||
}
|
||||
|
||||
/* Set the current product. */
|
||||
#define ADD_TO_FILTER_MENU(rt) \
|
||||
ws_combo_box_append_text_and_pointer(GTK_COMBO_BOX(rule_info->filter_combo_box), name, GUINT_TO_POINTER(rt)); \
|
||||
if (rule_type == RT_NONE) { \
|
||||
rule_type = rt; \
|
||||
}
|
||||
|
||||
#define NAME_TCP_UDP (rule_info->ptype == PT_TCP ? "TCP" : "UDP")
|
||||
|
||||
static void
|
||||
select_product(GtkWidget *w, gpointer data _U_)
|
||||
{
|
||||
guint prod = gtk_combo_box_get_active(GTK_COMBO_BOX(w));
|
||||
rule_info_t *rule_info;
|
||||
gchar name[MAX_RULE_LEN], addr_str[MAX_RULE_LEN];
|
||||
address *addr;
|
||||
rule_type_e rule_type = RT_NONE;
|
||||
gboolean sensitive = FALSE;
|
||||
|
||||
rule_info =(rule_info_t *)g_object_get_data(G_OBJECT(w), WS_RULE_INFO_KEY);
|
||||
|
||||
if (prod >= firewall_product_count() || !rule_info)
|
||||
return;
|
||||
|
||||
rule_info->product = prod;
|
||||
|
||||
/* Clear the list store (ie: the como_box list items) */
|
||||
ws_combo_box_clear_text_and_pointer(GTK_COMBO_BOX(rule_info->filter_combo_box));
|
||||
|
||||
/* Fill in valid combo_box list items (in the list store). */
|
||||
if (firewall_product_mac_func(prod) && rule_info->dl_src.type == AT_ETHER) {
|
||||
addr = &(rule_info->dl_src);
|
||||
address_to_str_buf(addr, name, MAX_RULE_LEN);
|
||||
ADD_TO_FILTER_MENU(RT_MAC_SRC);
|
||||
|
||||
addr = &(rule_info->dl_dst);
|
||||
address_to_str_buf(addr, name, MAX_RULE_LEN);
|
||||
ADD_TO_FILTER_MENU(RT_MAC_DST);
|
||||
}
|
||||
|
||||
if (firewall_product_ipv4_func(prod) && rule_info->net_src.type == AT_IPv4) {
|
||||
addr = &(rule_info->net_src);
|
||||
address_to_str_buf(addr, name, MAX_RULE_LEN);
|
||||
ADD_TO_FILTER_MENU(RT_IPv4_SRC);
|
||||
|
||||
addr = &(rule_info->net_dst);
|
||||
address_to_str_buf(addr, name, MAX_RULE_LEN);
|
||||
ADD_TO_FILTER_MENU(RT_IPv4_DST);
|
||||
}
|
||||
|
||||
if (firewall_product_port_func(prod) && (rule_info->ptype == PT_TCP || rule_info->ptype == PT_UDP)) {
|
||||
g_snprintf(name, MAX_RULE_LEN, "%s port %u", NAME_TCP_UDP,
|
||||
rule_info->srcport);
|
||||
ADD_TO_FILTER_MENU(RT_PORT_SRC);
|
||||
if (rule_info->srcport != rule_info->destport) {
|
||||
g_snprintf(name, MAX_RULE_LEN, "%s port %u", NAME_TCP_UDP,
|
||||
rule_info->destport);
|
||||
ADD_TO_FILTER_MENU(RT_PORT_DST);
|
||||
}
|
||||
}
|
||||
|
||||
if (firewall_product_ipv4_port_func(prod) && rule_info->net_src.type == AT_IPv4 &&
|
||||
(rule_info->ptype == PT_TCP || rule_info->ptype == PT_UDP)) {
|
||||
addr = &(rule_info->net_src);
|
||||
address_to_str_buf(addr, addr_str, MAX_RULE_LEN);
|
||||
g_snprintf(name, MAX_RULE_LEN, "%s + %s port %u", addr_str,
|
||||
NAME_TCP_UDP, rule_info->srcport);
|
||||
ADD_TO_FILTER_MENU(RT_IPv4_PORT_SRC);
|
||||
|
||||
addr = &(rule_info->net_dst);
|
||||
address_to_str_buf(addr, addr_str, MAX_RULE_LEN);
|
||||
g_snprintf(name, MAX_RULE_LEN, "%s + %s port %u", addr_str,
|
||||
NAME_TCP_UDP, rule_info->destport);
|
||||
ADD_TO_FILTER_MENU(RT_IPv4_PORT_DST);
|
||||
}
|
||||
|
||||
if (rule_type != RT_NONE) {
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(rule_info->filter_combo_box), 0); /* invokes select_filter callback */
|
||||
sensitive = TRUE;
|
||||
} else {
|
||||
select_filter(rule_info->filter_combo_box, NULL); /* Call if RT_NONE [with nothing selected] */
|
||||
}
|
||||
|
||||
gtk_widget_set_sensitive(rule_info->filter_combo_box, sensitive);
|
||||
gtk_widget_set_sensitive(rule_info->inbound_cb, firewall_product_does_inbound(prod) && sensitive);
|
||||
gtk_widget_set_sensitive(rule_info->deny_cb, sensitive);
|
||||
}
|
||||
|
||||
/* Set the rule text based upon the current product and current filter. */
|
||||
static void
|
||||
select_filter(GtkWidget *w, gpointer data _U_)
|
||||
{
|
||||
rule_type_e cur_type;
|
||||
rule_info_t *rule_info;
|
||||
gpointer ptr;
|
||||
|
||||
rule_info = (rule_info_t *)g_object_get_data(G_OBJECT(w), WS_RULE_INFO_KEY);
|
||||
if (!rule_info)
|
||||
return;
|
||||
|
||||
|
||||
if (ws_combo_box_get_active_pointer(GTK_COMBO_BOX(w), &ptr))
|
||||
cur_type = (rule_type_e)GPOINTER_TO_UINT(ptr);
|
||||
else
|
||||
cur_type = RT_NONE; /* If nothing selected (eg: nothing in filter list) */
|
||||
|
||||
if (cur_type >= NUM_RULE_TYPES)
|
||||
return;
|
||||
|
||||
rule_info->rule_type = cur_type;
|
||||
|
||||
set_rule_text(rule_info);
|
||||
}
|
||||
|
||||
/* Set inbound/outbound */
|
||||
static void
|
||||
toggle_inbound(GtkToggleButton *t, gpointer data)
|
||||
{
|
||||
rule_info_t *rule_info = (rule_info_t *) data;
|
||||
|
||||
rule_info->inbound = gtk_toggle_button_get_active(t);
|
||||
|
||||
set_rule_text(rule_info);
|
||||
}
|
||||
|
||||
/* Set deny/allow. */
|
||||
static void
|
||||
toggle_deny(GtkToggleButton *t, gpointer data)
|
||||
{
|
||||
rule_info_t *rule_info = (rule_info_t *) data;
|
||||
|
||||
rule_info->deny = gtk_toggle_button_get_active(t);
|
||||
|
||||
set_rule_text(rule_info);
|
||||
}
|
||||
|
||||
/* Set the rule text */
|
||||
#define DL_ADDR (rt == RT_MAC_SRC ? &(rule_info->dl_src) : &(rule_info->dl_dst))
|
||||
#define NET_ADDR (rt == RT_IPv4_SRC ? &(rule_info->net_src) : &(rule_info->net_dst))
|
||||
#define NET_PORT (rt == RT_PORT_SRC ? rule_info->srcport : rule_info->destport)
|
||||
static void
|
||||
set_rule_text(rule_info_t *rule_info) {
|
||||
GString *rtxt = g_string_new("");
|
||||
gchar addr_str[MAX_RULE_LEN];
|
||||
rule_type_e rt = rule_info->rule_type;
|
||||
size_t prod = rule_info->product;
|
||||
address *addr = NULL;
|
||||
guint32 port = 0;
|
||||
syntax_func rt_func = NULL;
|
||||
|
||||
GtkTextBuffer *buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(rule_info->text));
|
||||
|
||||
if (prod < firewall_product_count()) {
|
||||
const char *hint = firewall_product_rule_hint(prod);
|
||||
g_string_printf(rtxt, "%s %s\n", firewall_product_comment_prefix(prod), firewall_product_name(prod));
|
||||
if (strlen(hint) > 0) {
|
||||
g_string_append_printf(rtxt, " %s", hint);
|
||||
}
|
||||
switch(rt) {
|
||||
case RT_NONE:
|
||||
g_string_append_printf(rtxt, "%s Not supported", firewall_product_comment_prefix(prod));
|
||||
rt_func = sf_dummy;
|
||||
break;
|
||||
case RT_MAC_SRC:
|
||||
case RT_MAC_DST:
|
||||
addr = DL_ADDR;
|
||||
address_to_str_buf(addr, addr_str, MAX_RULE_LEN);
|
||||
rt_func = firewall_product_mac_func(prod);
|
||||
break;
|
||||
case RT_IPv4_SRC:
|
||||
case RT_IPv4_DST:
|
||||
addr = NET_ADDR;
|
||||
address_to_str_buf(addr, addr_str, MAX_RULE_LEN);
|
||||
rt_func = firewall_product_ipv4_func(prod);
|
||||
break;
|
||||
case RT_PORT_SRC:
|
||||
case RT_PORT_DST:
|
||||
port = NET_PORT;
|
||||
rt_func = firewall_product_port_func(prod);
|
||||
break;
|
||||
case RT_IPv4_PORT_SRC:
|
||||
case RT_IPv4_PORT_DST:
|
||||
addr = NET_ADDR;
|
||||
address_to_str_buf(addr, addr_str, MAX_RULE_LEN);
|
||||
port = NET_PORT;
|
||||
rt_func = firewall_product_ipv4_port_func(prod);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (rt_func) {
|
||||
rt_func(rtxt, addr_str, port, rule_info->ptype, rule_info->inbound, rule_info->deny);
|
||||
} else {
|
||||
g_string_append_printf(rtxt, "ERROR: Unable to create rule");
|
||||
}
|
||||
|
||||
gtk_text_buffer_set_text(buf, rtxt->str, (gint) rtxt->len);
|
||||
|
||||
g_string_free(rtxt, TRUE);
|
||||
}
|
||||
|
||||
|
||||
/* Rule text functions */
|
||||
/* Dummy */
|
||||
static void sf_dummy(GString *rtxt _U_, gchar *addr _U_, guint32 port _U_, port_type ptype _U_, gboolean inbound _U_, gboolean deny _U_) {
|
||||
}
|
||||
|
||||
/* The destroy call back has the responsibility of
|
||||
* unlinking the temporary file
|
||||
* and freeing the filter_out_filter */
|
||||
static void
|
||||
firewall_destroy_cb(GtkWidget *w, gpointer data _U_)
|
||||
{
|
||||
rule_info_t *rule_info;
|
||||
|
||||
rule_info = (rule_info_t *)g_object_get_data(G_OBJECT(w), WS_RULE_INFO_KEY);
|
||||
#if 0
|
||||
forget_rule_info(rule_info);
|
||||
#endif
|
||||
g_free(rule_info);
|
||||
gtk_widget_destroy(w);
|
||||
}
|
||||
|
||||
static void
|
||||
firewall_copy_cmd_cb(GtkWidget *w _U_, gpointer data)
|
||||
{
|
||||
rule_info_t *rule_info = (rule_info_t *)data;
|
||||
|
||||
GtkTextIter start, end;
|
||||
GtkTextBuffer *buf;
|
||||
|
||||
buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(rule_info->text));
|
||||
gtk_text_buffer_get_start_iter(buf, &start);
|
||||
gtk_text_buffer_get_end_iter(buf, &end);
|
||||
gtk_text_buffer_select_range(buf, &start, &end);
|
||||
gtk_text_buffer_copy_clipboard(buf, gtk_clipboard_get(GDK_SELECTION_CLIPBOARD));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
firewall_save_as_ok_cb(const char *to_name, rule_info_t *rule_info)
|
||||
{
|
||||
FILE *fh;
|
||||
gchar *rule;
|
||||
|
||||
GtkTextIter start, end;
|
||||
GtkTextBuffer *buf;
|
||||
|
||||
fh = ws_fopen(to_name, "w");
|
||||
if (fh == NULL) {
|
||||
open_failure_alert_box(to_name, errno, TRUE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(rule_info->text));
|
||||
gtk_text_buffer_get_start_iter(buf, &start);
|
||||
gtk_text_buffer_get_end_iter(buf, &end);
|
||||
rule = gtk_text_buffer_get_text(buf, &start, &end, FALSE);
|
||||
|
||||
fputs(rule, fh);
|
||||
fclose(fh);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static char *
|
||||
gtk_firewall_save_as_file(GtkWidget *caller)
|
||||
{
|
||||
GtkWidget *new_win;
|
||||
char *pathname;
|
||||
|
||||
new_win = file_selection_new("Wireshark: Save Firewall ACL Rule",
|
||||
GTK_WINDOW(caller),
|
||||
FILE_SELECTION_SAVE);
|
||||
|
||||
pathname = file_selection_run(new_win);
|
||||
if (pathname == NULL) {
|
||||
/* User cancelled or closed the dialog. */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* We've crosed the Rubicon; get rid of the dialog box. */
|
||||
window_destroy(new_win);
|
||||
|
||||
return pathname;
|
||||
}
|
||||
|
||||
static void
|
||||
firewall_save_as_cmd_cb(GtkWidget *w, gpointer data)
|
||||
{
|
||||
GtkWidget *caller = gtk_widget_get_toplevel(w);
|
||||
rule_info_t *rule_info = (rule_info_t *)data;
|
||||
char *pathname;
|
||||
|
||||
/*
|
||||
* Loop until the user either selects a file or gives up.
|
||||
*/
|
||||
for (;;) {
|
||||
pathname = gtk_firewall_save_as_file(caller);
|
||||
if (pathname == NULL) {
|
||||
/* User gave up. */
|
||||
break;
|
||||
}
|
||||
if (firewall_save_as_ok_cb(pathname, rule_info)) {
|
||||
/* We succeeded. */
|
||||
g_free(pathname);
|
||||
break;
|
||||
}
|
||||
/* Dump failed; let the user select another file or give up. */
|
||||
g_free(pathname);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
||||
* :indentSize=4:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -1,30 +0,0 @@
|
|||
/* firewall_dlg.h
|
||||
* Produce ACL rules for various products from a packet.
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.org>
|
||||
* Copyright 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __FIREWALL_DLG_H__
|
||||
#define __FIREWALL_DLG_H__
|
||||
|
||||
/* Generate ACL / firewall rules from different fields in the
|
||||
selected packet. */
|
||||
void firewall_rule_cb(GtkWidget * w, gpointer data _U_);
|
||||
|
||||
#endif /* __FIREWALL_DLG_H__ */
|
|
@ -1,431 +0,0 @@
|
|||
/* flow_graph.c
|
||||
* Allows to display a flow graph of the currently displayed packets
|
||||
*
|
||||
* Copyright 2004, Ericsson , Spain
|
||||
* By Francisco Alcoba <francisco.alcoba@ericsson.com>
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <string.h>
|
||||
|
||||
#include <epan/packet.h>
|
||||
#include <epan/stat_tap_ui.h>
|
||||
#include <wsutil/report_message.h>
|
||||
|
||||
#include "ui/gtk/graph_analysis.h"
|
||||
#include "ui/gtk/dlg_utils.h"
|
||||
#include "ui/gtk/gui_utils.h"
|
||||
#include "ui/gtk/stock_icons.h"
|
||||
#include "ui/gtk/main.h"
|
||||
#include "ui/gtk/gui_stat_menu.h"
|
||||
#include "ui/gtk/old-gtk-compat.h"
|
||||
#include "ui/gtk/gtkglobals.h"
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
void register_tap_listener_flow_graph(void);
|
||||
|
||||
static seq_analysis_info_t *graph_analysis = NULL;
|
||||
static graph_analysis_data_t *graph_analysis_data = NULL;
|
||||
static const char* display_filter = NULL;
|
||||
|
||||
static GtkWidget *flow_graph_dlg = NULL;
|
||||
|
||||
static GtkWidget *select_all_rb;
|
||||
static GtkWidget *select_displayed_rb;
|
||||
static GtkWidget *src_dst_rb;
|
||||
static GtkWidget *net_src_dst_rb;
|
||||
static GtkWidget *select_analysis_combo;
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
static void
|
||||
flow_graph_data_init(void) {
|
||||
graph_analysis = sequence_analysis_info_new();
|
||||
graph_analysis->name = "any";
|
||||
display_filter = NULL;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/* CALLBACKS */
|
||||
/****************************************************************************/
|
||||
static void
|
||||
flow_graph_on_destroy(GObject *object _U_, gpointer user_data _U_)
|
||||
{
|
||||
g_assert(graph_analysis != NULL);
|
||||
g_assert(graph_analysis_data != NULL);
|
||||
|
||||
/* Clean up memory used by tap */
|
||||
sequence_analysis_info_free(graph_analysis);
|
||||
graph_analysis = NULL;
|
||||
|
||||
g_free(graph_analysis_data);
|
||||
graph_analysis_data = NULL;
|
||||
|
||||
/* Note that we no longer have a "Flow Graph" dialog box. */
|
||||
flow_graph_dlg = NULL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
find_seq_name(const void *key, void *value, void *userdata)
|
||||
{
|
||||
const char* name = (const char*)key;
|
||||
register_analysis_t* analysis = (register_analysis_t*)value;
|
||||
const char* ui_name = (const char*)userdata;
|
||||
|
||||
if (strcmp(ui_name, sequence_analysis_get_ui_name(analysis)) == 0)
|
||||
{
|
||||
graph_analysis->name = name;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
sequence_combo_box_changed_cb(GtkComboBox *combo_box, gpointer user_data _U_)
|
||||
{
|
||||
gchar* ui_name = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(combo_box));
|
||||
|
||||
sequence_analysis_table_iterate_tables(find_seq_name, ui_name);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
static void
|
||||
toggle_select_all(GtkWidget *widget _U_, gpointer user_data _U_)
|
||||
{
|
||||
/* is the button now active? */
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(select_all_rb))) {
|
||||
display_filter = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
static void
|
||||
toggle_select_displayed(GtkWidget *widget _U_, gpointer user_data _U_)
|
||||
{
|
||||
/* is the button now active? */
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(select_displayed_rb))) {
|
||||
display_filter = gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
static void
|
||||
toggle_select_srcdst(GtkWidget *widget _U_, gpointer user_data _U_)
|
||||
{
|
||||
/* is the button now active? */
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(src_dst_rb))) {
|
||||
graph_analysis->any_addr = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
static void
|
||||
toggle_select_netsrcdst(GtkWidget *widget _U_, gpointer user_data _U_)
|
||||
{
|
||||
/* is the button now active? */
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(net_src_dst_rb))) {
|
||||
graph_analysis->any_addr = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
static void
|
||||
flow_graph_on_ok(GtkButton *button _U_, gpointer user_data)
|
||||
{
|
||||
register_analysis_t* analysis = sequence_analysis_find_by_name(graph_analysis->name);
|
||||
|
||||
/* Scan for displayed packets (retap all packets) */
|
||||
sequence_analysis_list_free(graph_analysis);
|
||||
|
||||
if (analysis != NULL)
|
||||
{
|
||||
GString *error_string;
|
||||
|
||||
error_string = register_tap_listener(sequence_analysis_get_tap_listener_name(analysis), graph_analysis, display_filter, sequence_analysis_get_tap_flags(analysis),
|
||||
NULL, sequence_analysis_get_packet_func(analysis), NULL);
|
||||
if (error_string) {
|
||||
report_failure("Flow graph - tap registration failed: %s", error_string->str);
|
||||
g_string_free(error_string, TRUE);
|
||||
return;
|
||||
}
|
||||
|
||||
cf_retap_packets(&cfile);
|
||||
remove_tap_listener(graph_analysis);
|
||||
}
|
||||
|
||||
if (graph_analysis_data->dlg.window != NULL){ /* if we still have a window */
|
||||
graph_analysis_update(graph_analysis_data); /* refresh it xxx */
|
||||
}
|
||||
else{
|
||||
graph_analysis_data->dlg.parent_w = (GtkWidget *)user_data;
|
||||
graph_analysis_create(graph_analysis_data);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
flow_graph_on_cancel(GtkButton *button _U_,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (graph_analysis_data->dlg.window) {
|
||||
window_destroy(graph_analysis_data->dlg.window);
|
||||
}
|
||||
window_destroy(GTK_WIDGET(user_data));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
flow_graph_on_delete(GtkButton *button _U_,
|
||||
gpointer user_data _U_)
|
||||
{
|
||||
if (graph_analysis_data->dlg.window) {
|
||||
window_destroy(graph_analysis_data->dlg.window);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* INTERFACE */
|
||||
/****************************************************************************/
|
||||
static gboolean
|
||||
add_flow_sequence_item(const void *key _U_, void *value, void *userdata)
|
||||
{
|
||||
register_analysis_t* analysis = (register_analysis_t*)value;
|
||||
GtkWidget* combo_box = (GtkWidget*)userdata;
|
||||
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), sequence_analysis_get_ui_name(analysis));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
flow_graph_dlg_create(void)
|
||||
{
|
||||
GtkWidget *flow_graph_dlg_w;
|
||||
GtkWidget *main_vb;
|
||||
GtkWidget *hbuttonbox;
|
||||
GtkWidget *bt_cancel, *bt_ok;
|
||||
#if 0
|
||||
GtkWidget *top_label = NULL;
|
||||
#endif
|
||||
GtkWidget *flow_type_fr, *range_fr, *range_grid, *flow_type_grid, *node_addr_fr, *node_addr_grid;
|
||||
|
||||
flow_graph_dlg_w = dlg_window_new("Wireshark: Flow Graph"); /* transient_for top_level */
|
||||
gtk_window_set_destroy_with_parent (GTK_WINDOW(flow_graph_dlg_w), TRUE);
|
||||
|
||||
gtk_window_set_default_size(GTK_WINDOW(flow_graph_dlg_w), 250, 150);
|
||||
|
||||
main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 0, FALSE);
|
||||
gtk_container_add(GTK_CONTAINER(flow_graph_dlg_w), main_vb);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (main_vb), 7);
|
||||
|
||||
#if 0
|
||||
top_label = gtk_label_new ("Choose packets to include in the graph");
|
||||
gtk_box_pack_start (GTK_BOX (main_vb), top_label, FALSE, FALSE, 8);
|
||||
#endif
|
||||
|
||||
gtk_widget_show(flow_graph_dlg_w);
|
||||
|
||||
/*** Packet range frame ***/
|
||||
range_fr = gtk_frame_new("Choose packets");
|
||||
gtk_box_pack_start(GTK_BOX(main_vb), range_fr, FALSE, FALSE, 5);
|
||||
|
||||
range_grid = ws_gtk_grid_new();
|
||||
gtk_container_set_border_width(GTK_CONTAINER(range_grid), 5);
|
||||
gtk_container_add(GTK_CONTAINER(range_fr), range_grid);
|
||||
|
||||
/* Process all packets */
|
||||
select_all_rb = gtk_radio_button_new_with_mnemonic_from_widget(NULL, "_All packets");
|
||||
gtk_widget_set_tooltip_text (select_all_rb, ("Process all packets"));
|
||||
g_signal_connect(select_all_rb, "toggled", G_CALLBACK(toggle_select_all), NULL);
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(range_grid), select_all_rb, 0, 0, 1, 1,
|
||||
(GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
|
||||
if (display_filter == NULL) {
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(select_all_rb),TRUE);
|
||||
}
|
||||
gtk_widget_show(select_all_rb);
|
||||
|
||||
/* Process displayed packets */
|
||||
select_displayed_rb = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(select_all_rb),
|
||||
"_Displayed packets");
|
||||
gtk_widget_set_tooltip_text (select_displayed_rb, ("Process displayed packets"));
|
||||
g_signal_connect(select_displayed_rb, "toggled", G_CALLBACK(toggle_select_displayed), NULL);
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(range_grid), select_displayed_rb, 0, 1, 1, 1,
|
||||
(GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
|
||||
if (display_filter != NULL) {
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(select_displayed_rb),TRUE);
|
||||
}
|
||||
gtk_widget_show(select_displayed_rb);
|
||||
|
||||
gtk_widget_show(range_grid);
|
||||
gtk_widget_show(range_fr);
|
||||
|
||||
/*** Flow type frame ***/
|
||||
flow_type_fr = gtk_frame_new("Choose flow type");
|
||||
gtk_box_pack_start(GTK_BOX(main_vb), flow_type_fr, FALSE, FALSE, 5);
|
||||
|
||||
flow_type_grid = ws_gtk_grid_new();
|
||||
gtk_container_set_border_width(GTK_CONTAINER(flow_type_grid), 5);
|
||||
gtk_container_add(GTK_CONTAINER(flow_type_fr), flow_type_grid);
|
||||
|
||||
select_analysis_combo = gtk_combo_box_text_new();
|
||||
g_signal_connect(select_analysis_combo, "changed", G_CALLBACK(sequence_combo_box_changed_cb), NULL);
|
||||
sequence_analysis_table_iterate_tables(add_flow_sequence_item, select_analysis_combo);
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(select_analysis_combo), 0);
|
||||
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(flow_type_grid), select_analysis_combo, 0, 0, 1, 1,
|
||||
(GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
|
||||
gtk_widget_show(select_analysis_combo);
|
||||
|
||||
gtk_widget_show(flow_type_grid);
|
||||
gtk_widget_show(flow_type_fr);
|
||||
|
||||
/*** Node address type frame ***/
|
||||
node_addr_fr = gtk_frame_new("Choose node address type");
|
||||
gtk_box_pack_start(GTK_BOX(main_vb), node_addr_fr, FALSE, FALSE, 5);
|
||||
|
||||
node_addr_grid = ws_gtk_grid_new();
|
||||
gtk_container_set_border_width(GTK_CONTAINER(node_addr_grid), 5);
|
||||
gtk_container_add(GTK_CONTAINER(node_addr_fr), node_addr_grid);
|
||||
|
||||
/* Source / Dest address */
|
||||
src_dst_rb = gtk_radio_button_new_with_mnemonic_from_widget(NULL, "_Standard source/destination addresses");
|
||||
gtk_widget_set_tooltip_text (src_dst_rb,
|
||||
("Nodes in the diagram are identified with source and destination addresses"));
|
||||
g_signal_connect(src_dst_rb, "toggled", G_CALLBACK(toggle_select_srcdst), NULL);
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(node_addr_grid), src_dst_rb, 0, 0, 1, 1,
|
||||
(GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
|
||||
if (graph_analysis->any_addr) {
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(src_dst_rb),TRUE);
|
||||
}
|
||||
gtk_widget_show(src_dst_rb);
|
||||
|
||||
/* Network source / dest address */
|
||||
net_src_dst_rb = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(src_dst_rb),
|
||||
"_Network source/destination addresses");
|
||||
gtk_widget_set_tooltip_text (net_src_dst_rb,
|
||||
("Nodes in the diagram are identified with network source and destination addresses"));
|
||||
g_signal_connect(net_src_dst_rb, "toggled", G_CALLBACK(toggle_select_netsrcdst), NULL);
|
||||
ws_gtk_grid_attach_extended(GTK_GRID(node_addr_grid), net_src_dst_rb, 0, 1, 1, 1,
|
||||
(GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0);
|
||||
if (!graph_analysis->any_addr) {
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(net_src_dst_rb),TRUE);
|
||||
}
|
||||
gtk_widget_show(net_src_dst_rb);
|
||||
|
||||
gtk_widget_show(node_addr_grid);
|
||||
gtk_widget_show(node_addr_fr);
|
||||
|
||||
/* button row */
|
||||
hbuttonbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
|
||||
gtk_box_pack_start (GTK_BOX (main_vb), hbuttonbox, FALSE, FALSE, 5);
|
||||
gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox), GTK_BUTTONBOX_SPREAD);
|
||||
gtk_box_set_spacing (GTK_BOX (hbuttonbox), 30);
|
||||
|
||||
bt_ok = ws_gtk_button_new_from_stock(GTK_STOCK_OK);
|
||||
gtk_box_pack_start(GTK_BOX(hbuttonbox), bt_ok, TRUE, TRUE, 0);
|
||||
gtk_widget_set_tooltip_text (bt_ok, "Show the flow graph");
|
||||
g_signal_connect(bt_ok, "clicked", G_CALLBACK(flow_graph_on_ok), flow_graph_dlg_w);
|
||||
gtk_widget_show(bt_ok);
|
||||
|
||||
bt_cancel = ws_gtk_button_new_from_stock(GTK_STOCK_CANCEL);
|
||||
gtk_box_pack_start(GTK_BOX(hbuttonbox), bt_cancel, TRUE, TRUE, 0);
|
||||
gtk_widget_set_can_default(bt_cancel, TRUE);
|
||||
gtk_widget_set_tooltip_text (bt_cancel, "Cancel this dialog");
|
||||
g_signal_connect(bt_cancel, "clicked", G_CALLBACK(flow_graph_on_cancel), flow_graph_dlg_w);
|
||||
|
||||
g_signal_connect(flow_graph_dlg_w, "delete_event", G_CALLBACK(flow_graph_on_delete), NULL);
|
||||
g_signal_connect(flow_graph_dlg_w, "destroy", G_CALLBACK(flow_graph_on_destroy), NULL);
|
||||
|
||||
gtk_widget_show_all(flow_graph_dlg_w);
|
||||
window_present(flow_graph_dlg_w);
|
||||
|
||||
flow_graph_dlg = flow_graph_dlg_w;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/* PUBLIC */
|
||||
/****************************************************************************/
|
||||
|
||||
/* init function for tap */
|
||||
static void
|
||||
flow_graph_init_tap(const char *dummy _U_, void *userdata _U_)
|
||||
{
|
||||
/* The storage allocated by flow_graph_data_init() and graph_analysis_init() */
|
||||
/* will be considered to be "associated with" the flow_graph_dlg dialog box. */
|
||||
/* It will be freed when the flow_graph_dlg dialog box is destroyed. */
|
||||
if (flow_graph_dlg != NULL) {
|
||||
g_assert(graph_analysis != NULL);
|
||||
g_assert(graph_analysis_data != NULL);
|
||||
/* There's already a dialog box; reactivate it. */
|
||||
reactivate_window(flow_graph_dlg);
|
||||
} else {
|
||||
g_assert(graph_analysis == NULL);
|
||||
g_assert(graph_analysis_data == NULL);
|
||||
|
||||
/* initialize graph items store */
|
||||
flow_graph_data_init();
|
||||
|
||||
/* init the Graph Analysis */
|
||||
graph_analysis_data = graph_analysis_init(graph_analysis);
|
||||
|
||||
flow_graph_dlg_create();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/* entry point when called via the GTK menu */
|
||||
void
|
||||
flow_graph_launch(GtkAction *action _U_, gpointer user_data _U_)
|
||||
{
|
||||
flow_graph_init_tap("",NULL);
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
static stat_tap_ui flow_graph_ui = {
|
||||
REGISTER_STAT_GROUP_GENERIC,
|
||||
NULL,
|
||||
"flow_graph",
|
||||
flow_graph_init_tap,
|
||||
0,
|
||||
NULL
|
||||
};
|
||||
|
||||
void
|
||||
register_tap_listener_flow_graph(void)
|
||||
{
|
||||
register_stat_tap_ui(&flow_graph_ui,NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
||||
* :indentSize=8:tabSize=8:noTabs=false:
|
||||
*/
|
File diff suppressed because it is too large
Load Diff
|
@ -1,86 +0,0 @@
|
|||
/* follow_stream.h
|
||||
* Common routines for following data streams
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*/
|
||||
|
||||
#ifndef __FOLLOW_STREAM_H__
|
||||
#define __FOLLOW_STREAM_H__
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <epan/follow.h>
|
||||
|
||||
|
||||
typedef struct _gtk_follow_info {
|
||||
show_type_t show_type;
|
||||
GtkWidget *text;
|
||||
GtkWidget *ascii_bt;
|
||||
GtkWidget *ebcdic_bt;
|
||||
GtkWidget *hexdump_bt;
|
||||
GtkWidget *carray_bt;
|
||||
GtkWidget *raw_bt;
|
||||
GtkWidget *find_dlg_w;
|
||||
GtkWidget *filter_te;
|
||||
GtkWidget *streamwindow;
|
||||
follow_read_stream_func read_stream;
|
||||
} gtk_follow_info_t;
|
||||
|
||||
#define E_FOLLOW_INFO_KEY "follow_info_key"
|
||||
|
||||
/** Redraw the text in all "Follow TCP Stream" windows. */
|
||||
extern void follow_stream_redraw_all(void);
|
||||
|
||||
/** User requested the "Follow TCP Stream" dialog box by menu or toolbar.
|
||||
*
|
||||
* @param widget parent widget (unused)
|
||||
* @param data unused
|
||||
*/
|
||||
extern void follow_tcp_stream_cb( GtkWidget *widget, gpointer data);
|
||||
|
||||
/* Follow the UDP stream, if any, to which the last packet that we called
|
||||
a dissection routine on belongs (this might be the most recently
|
||||
selected packet, or it might be the last packet in the file). */
|
||||
void follow_udp_stream_cb(GtkWidget * w, gpointer data _U_);
|
||||
|
||||
/* Follow the HTTP stream, if any, to which the last packet that we called
|
||||
a dissection routine on belongs (this might be the most recently
|
||||
selected packet, or it might be the last packet in the file). */
|
||||
void follow_http_stream_cb(GtkWidget * w, gpointer data _U_);
|
||||
|
||||
/* Follow the SSL stream, if any, to which the last packet that we called
|
||||
a dissection routine on belongs (this might be the most recently
|
||||
selected packet, or it might be the last packet in the file). */
|
||||
void follow_ssl_stream_cb(GtkWidget * w, gpointer data _U_);
|
||||
|
||||
|
||||
#endif /* __FOLLOW_STREAM_H__ */
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
||||
* :indentSize=4:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -1,378 +0,0 @@
|
|||
/* font_utils.c
|
||||
* Utilities to use for font manipulation
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <epan/packet.h>
|
||||
#include <epan/prefs.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <wsutil/unicode-utils.h>
|
||||
#endif
|
||||
|
||||
#include "ui/recent.h"
|
||||
#include "ui/simple_dialog.h"
|
||||
|
||||
#include "ui/gtk/main.h"
|
||||
#include "ui/gtk/gtkglobals.h"
|
||||
#include "ui/gtk/font_utils.h"
|
||||
#include "ui/gtk/packet_panes.h"
|
||||
#include "ui/gtk/follow_stream.h"
|
||||
#include "ui/gtk/packet_list.h"
|
||||
|
||||
|
||||
static PangoFontDescription *m_r_font;
|
||||
|
||||
|
||||
/* Get the regular user font.
|
||||
*
|
||||
* @return the regular user font
|
||||
*/
|
||||
PangoFontDescription *user_font_get_regular(void)
|
||||
{
|
||||
return m_r_font;
|
||||
}
|
||||
|
||||
static void
|
||||
set_fonts(PangoFontDescription *regular)
|
||||
{
|
||||
/* Yes, assert. The code that loads the font should check
|
||||
* for NULL and provide its own error message. */
|
||||
g_assert(m_r_font);
|
||||
m_r_font = regular;
|
||||
}
|
||||
|
||||
void
|
||||
view_zoom_in_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||
{
|
||||
gint save_gui_zoom_level;
|
||||
|
||||
save_gui_zoom_level = recent.gui_zoom_level;
|
||||
recent.gui_zoom_level++;
|
||||
switch (user_font_apply()) {
|
||||
|
||||
case FA_SUCCESS:
|
||||
break;
|
||||
|
||||
case FA_ZOOMED_TOO_FAR:
|
||||
recent.gui_zoom_level = save_gui_zoom_level; /* undo zoom */
|
||||
break;
|
||||
|
||||
case FA_FONT_NOT_AVAILABLE:
|
||||
/* We assume this means that the specified size isn't available. */
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Your current font isn't available in the next larger size.\n");
|
||||
recent.gui_zoom_level = save_gui_zoom_level; /* undo zoom */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
view_zoom_out_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||
{
|
||||
gint save_gui_zoom_level;
|
||||
|
||||
save_gui_zoom_level = recent.gui_zoom_level;
|
||||
recent.gui_zoom_level--;
|
||||
switch (user_font_apply()) {
|
||||
|
||||
case FA_SUCCESS:
|
||||
break;
|
||||
|
||||
case FA_ZOOMED_TOO_FAR:
|
||||
recent.gui_zoom_level = save_gui_zoom_level; /* undo zoom */
|
||||
break;
|
||||
|
||||
case FA_FONT_NOT_AVAILABLE:
|
||||
/* We assume this means that the specified size isn't available. */
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Your current font isn't available in the next smaller size.\n");
|
||||
recent.gui_zoom_level = save_gui_zoom_level; /* undo zoom */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
view_zoom_100_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||
{
|
||||
gint save_gui_zoom_level;
|
||||
|
||||
save_gui_zoom_level = recent.gui_zoom_level;
|
||||
recent.gui_zoom_level = 0;
|
||||
switch (user_font_apply()) {
|
||||
|
||||
case FA_SUCCESS:
|
||||
break;
|
||||
|
||||
case FA_ZOOMED_TOO_FAR:
|
||||
recent.gui_zoom_level = save_gui_zoom_level; /* undo zoom */
|
||||
break;
|
||||
|
||||
case FA_FONT_NOT_AVAILABLE:
|
||||
/* We assume this means that the specified size isn't available.
|
||||
XXX - this "shouldn't happen". */
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Your current font couldn't be reloaded at the size you selected.\n");
|
||||
recent.gui_zoom_level = save_gui_zoom_level; /* undo zoom */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
gboolean
|
||||
user_font_test(gchar *font_name)
|
||||
{
|
||||
PangoFontDescription *new_r_font;
|
||||
|
||||
new_r_font = pango_font_description_from_string(font_name);
|
||||
if (new_r_font == NULL) {
|
||||
/* Oops, that font didn't work.
|
||||
Tell the user, but don't tear down the font selection
|
||||
dialog, so that they can try again. */
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"The font you selected can't be loaded.");
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Given a font name, construct the name of a version of that font with
|
||||
the current zoom factor applied. */
|
||||
static char *
|
||||
font_zoom(char *gui_font_name)
|
||||
{
|
||||
char *new_font_name;
|
||||
char *font_name_dup;
|
||||
char *font_name_p;
|
||||
long font_point_size_l;
|
||||
|
||||
if (recent.gui_zoom_level == 0) {
|
||||
/* There is no zoom factor - just return the name */
|
||||
return g_strdup(gui_font_name);
|
||||
}
|
||||
|
||||
font_name_dup = g_strdup(gui_font_name);
|
||||
|
||||
/* find the start of the font_size string */
|
||||
font_name_p = strrchr(font_name_dup, ' ');
|
||||
*font_name_p = '\0';
|
||||
font_name_p++;
|
||||
|
||||
/* calculate the new font size */
|
||||
font_point_size_l = strtol(font_name_p, NULL, 10);
|
||||
font_point_size_l += recent.gui_zoom_level;
|
||||
/* make sure the size didn't become zero or negative */
|
||||
if (font_point_size_l <= 0)
|
||||
return NULL;
|
||||
|
||||
/* build a new font name */
|
||||
new_font_name = g_strdup_printf("%s %ld", font_name_dup, font_point_size_l);
|
||||
|
||||
g_free(font_name_dup);
|
||||
|
||||
return new_font_name;
|
||||
}
|
||||
|
||||
fa_ret_t
|
||||
user_font_apply(void) {
|
||||
char *gui_font_name;
|
||||
PangoFontDescription *new_r_font;
|
||||
PangoFontDescription *old_r_font = NULL;
|
||||
|
||||
/* convert font name to reflect the zoom level */
|
||||
gui_font_name = font_zoom(prefs.gui_gtk2_font_name);
|
||||
if (gui_font_name == NULL)
|
||||
return FA_ZOOMED_TOO_FAR;
|
||||
|
||||
/* load normal font */
|
||||
new_r_font = pango_font_description_from_string(gui_font_name);
|
||||
if (new_r_font == NULL) {
|
||||
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 */
|
||||
packet_list_set_font(new_r_font);
|
||||
set_ptree_font_all(new_r_font);
|
||||
old_r_font = m_r_font;
|
||||
set_fonts(new_r_font);
|
||||
|
||||
/* Redraw the packet bytes windows. */
|
||||
redraw_packet_bytes_all();
|
||||
|
||||
/* Redraw the "Follow TCP Stream" windows. */
|
||||
follow_stream_redraw_all();
|
||||
|
||||
/* We're no longer using the old fonts; unreference them. */
|
||||
if (old_r_font != NULL)
|
||||
pango_font_description_free(old_r_font);
|
||||
g_free(gui_font_name);
|
||||
|
||||
return FA_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#define NAME_BUFFER_LEN 32
|
||||
|
||||
static char appfontname[128] = "tahoma 8";
|
||||
|
||||
static void
|
||||
set_app_font_gtk2(const char *fontname)
|
||||
{
|
||||
GtkSettings *settings;
|
||||
|
||||
if (fontname != NULL && *fontname == 0) return;
|
||||
|
||||
settings = gtk_settings_get_default();
|
||||
|
||||
if (fontname == NULL) {
|
||||
g_object_set(G_OBJECT(settings), "gtk-font-name", appfontname, NULL);
|
||||
} else {
|
||||
GtkWidget *w;
|
||||
PangoFontDescription *pfd;
|
||||
PangoContext *pc;
|
||||
PangoFont *pfont;
|
||||
|
||||
w = gtk_label_new(NULL);
|
||||
pfd = pango_font_description_from_string(fontname);
|
||||
pc = gtk_widget_get_pango_context(w);
|
||||
pfont = pango_context_load_font(pc, pfd);
|
||||
|
||||
if (pfont != NULL) {
|
||||
g_strlcpy(appfontname, fontname, 128);
|
||||
appfontname[127] = '\0';
|
||||
g_object_set(G_OBJECT(settings), "gtk-font-name", appfontname, NULL);
|
||||
}
|
||||
|
||||
gtk_widget_destroy(w);
|
||||
pango_font_description_free(pfd);
|
||||
}
|
||||
}
|
||||
|
||||
static char *default_windows_menu_fontspec_gtk2(void)
|
||||
{
|
||||
gchar *fontspec = NULL;
|
||||
NONCLIENTMETRICS ncm;
|
||||
|
||||
memset(&ncm, 0, sizeof ncm);
|
||||
ncm.cbSize = sizeof ncm;
|
||||
|
||||
if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0)) {
|
||||
HDC screen = GetDC(0);
|
||||
double y_scale = 72.0 / GetDeviceCaps(screen, LOGPIXELSY);
|
||||
int point_size = (int) (ncm.lfMenuFont.lfHeight * y_scale);
|
||||
|
||||
if (point_size < 0) point_size = -point_size;
|
||||
fontspec = g_strdup_printf("%s %d", ncm.lfMenuFont.lfFaceName,
|
||||
point_size);
|
||||
ReleaseDC(0, screen);
|
||||
}
|
||||
|
||||
return fontspec;
|
||||
}
|
||||
|
||||
static void try_to_get_windows_font_gtk2(void)
|
||||
{
|
||||
gchar *fontspec;
|
||||
|
||||
fontspec = default_windows_menu_fontspec_gtk2();
|
||||
|
||||
if (fontspec != NULL) {
|
||||
int match;
|
||||
PangoFontDescription *pfd;
|
||||
PangoFont *pfont;
|
||||
PangoContext *pc;
|
||||
GtkWidget *w;
|
||||
|
||||
pfd = pango_font_description_from_string(fontspec);
|
||||
|
||||
w = gtk_label_new(NULL);
|
||||
pc = gtk_widget_get_pango_context(w);
|
||||
pfont = pango_context_load_font(pc, pfd);
|
||||
match = (pfont != NULL);
|
||||
|
||||
pango_font_description_free(pfd);
|
||||
g_object_unref(G_OBJECT(pc));
|
||||
gtk_widget_destroy(w);
|
||||
|
||||
if (match) set_app_font_gtk2(fontspec);
|
||||
g_free(fontspec);
|
||||
}
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
|
||||
|
||||
void font_init(void)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
/* try to load the application font for GTK2 */
|
||||
try_to_get_windows_font_gtk2();
|
||||
#endif
|
||||
|
||||
/* Try to load the regular fixed-width font */
|
||||
m_r_font = pango_font_description_from_string(prefs.gui_gtk2_font_name);
|
||||
if (m_r_font == NULL) {
|
||||
/* XXX - pop this up as a dialog box? no */
|
||||
fprintf(stderr, "wireshark: Warning: font %s not found - defaulting to Monospace 9\n",
|
||||
prefs.gui_gtk2_font_name);
|
||||
if ((m_r_font = pango_font_description_from_string("Monospace 9")) == NULL)
|
||||
{
|
||||
fprintf(stderr, "wireshark: Error: font Monospace 9 not found\n");
|
||||
exit(1);
|
||||
}
|
||||
g_free(prefs.gui_gtk2_font_name);
|
||||
prefs.gui_gtk2_font_name = g_strdup("Monospace 9");
|
||||
}
|
||||
|
||||
/* Call this for the side-effects that set_fonts() produces */
|
||||
set_fonts(m_r_font);
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
||||
* :indentSize=4:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -1,67 +0,0 @@
|
|||
/* font_utils.h
|
||||
* Declarations of utilities to use for font manipulation
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
|
||||
/** @file
|
||||
* Utilities for font manipulation.
|
||||
*
|
||||
* There are two different fonts used:
|
||||
* - the application font for menu's, dialog's and such
|
||||
* - the user font for the packet panes
|
||||
*
|
||||
* The user font is also available in regular (m_r_font) and bold (m_b_font) versions.
|
||||
*/
|
||||
|
||||
#ifndef __FONT_UTILS_H__
|
||||
#define __FONT_UTILS_H__
|
||||
|
||||
/** 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_ZOOMED_TOO_FAR, /**< we've zoomed too far */
|
||||
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);
|
||||
|
||||
/** Test, if the given font name is available.
|
||||
*
|
||||
* @param font_name the font to test
|
||||
* @return TRUE, if this font is available
|
||||
*/
|
||||
extern gboolean user_font_test(gchar *font_name);
|
||||
|
||||
/** Get the regular user font.
|
||||
*
|
||||
* @return the regular user font
|
||||
*/
|
||||
extern PangoFontDescription *user_font_get_regular(void);
|
||||
|
||||
#endif
|
|
@ -1,655 +0,0 @@
|
|||
/*
|
||||
* funnel_stat.c
|
||||
*
|
||||
* EPAN's funneled GUI mini-API
|
||||
*
|
||||
* (c) 2006, Luis E. Garcia Ontanon <luis@ontanon.org>
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Most of the code here has been harvested from other Wireshark gtk modules.
|
||||
* most from prefs_dlg.c and about_dlg.c
|
||||
*
|
||||
* (From original checkin message:
|
||||
* The funneled GUI mini API.
|
||||
* A very reduced set of gui ops (by now just a text window)
|
||||
* that can be funneled to dissectors (even plugins) via epan.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <epan/prefs.h>
|
||||
#include <epan/funnel.h>
|
||||
|
||||
#include "ui/progress_dlg.h"
|
||||
#include "ui/simple_dialog.h"
|
||||
#include <epan/color_filters.h>
|
||||
|
||||
#include "ui/gtk/gui_utils.h"
|
||||
#include "ui/gtk/dlg_utils.h"
|
||||
#include "ui/gtk/font_utils.h"
|
||||
#include "ui/gtk/gui_stat_menu.h"
|
||||
#include "ui/gtk/main.h"
|
||||
#include "ui/gtk/webbrowser.h"
|
||||
#include "ui/gtk/gtkglobals.h"
|
||||
#include "ui/gtk/old-gtk-compat.h"
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
void register_tap_listener_gtkfunnel(void);
|
||||
|
||||
struct _funnel_text_window_t {
|
||||
GtkWidget* win;
|
||||
GtkWidget* txt;
|
||||
GtkWidget* button_hbox;
|
||||
GtkWidget* bt_close;
|
||||
text_win_close_cb_t close_cb;
|
||||
void* close_data;
|
||||
GPtrArray* buttons;
|
||||
};
|
||||
|
||||
struct _funnel_tree_window_t {
|
||||
GtkWidget *win;
|
||||
|
||||
};
|
||||
|
||||
struct _funnel_node_t {
|
||||
void* dummy;
|
||||
};
|
||||
|
||||
static void text_window_cancel_button_cb(GtkWidget *bt _U_, gpointer data) {
|
||||
funnel_text_window_t* tw = (funnel_text_window_t *)data;
|
||||
|
||||
window_destroy(GTK_WIDGET(tw->win));
|
||||
tw->win = NULL;
|
||||
|
||||
if (tw->close_cb)
|
||||
tw->close_cb(tw->close_data);
|
||||
}
|
||||
|
||||
static void unref_text_win_cancel_bt_cb(GtkWidget *bt _U_, gpointer data) {
|
||||
funnel_text_window_t* tw = (funnel_text_window_t *)data;
|
||||
guint i;
|
||||
|
||||
window_destroy(GTK_WIDGET(tw->win));
|
||||
tw->win = NULL;
|
||||
|
||||
if (tw->close_cb)
|
||||
tw->close_cb(tw->close_data);
|
||||
|
||||
for (i = 0; i < tw->buttons->len; i++) {
|
||||
funnel_bt_t* cbd = (funnel_bt_t *)g_ptr_array_index(tw->buttons,i);
|
||||
/* XXX a free cb should be passed somehow */
|
||||
if (cbd->data && cbd->free_data_fcn) cbd->free_data_fcn(cbd->data);
|
||||
if (cbd->free_fcn) cbd->free_fcn(cbd);
|
||||
}
|
||||
g_ptr_array_free(tw->buttons,TRUE);
|
||||
g_free(tw);
|
||||
}
|
||||
|
||||
|
||||
static gboolean text_window_unref_del_event_cb(GtkWidget *win _U_, GdkEvent *event _U_, gpointer user_data) {
|
||||
funnel_text_window_t* tw = (funnel_text_window_t *)user_data;
|
||||
guint i;
|
||||
|
||||
window_destroy(GTK_WIDGET(tw->win));
|
||||
tw->win = NULL;
|
||||
|
||||
if (tw->close_cb)
|
||||
tw->close_cb(tw->close_data);
|
||||
|
||||
for (i = 0; i < tw->buttons->len; i++) {
|
||||
funnel_bt_t* cbd = (funnel_bt_t *)g_ptr_array_index(tw->buttons,i);
|
||||
/* XXX a free cb should be passed somehow */
|
||||
if (cbd->data && cbd->free_data_fcn) cbd->free_data_fcn(cbd->data);
|
||||
if (cbd->free_fcn) cbd->free_fcn(cbd);
|
||||
}
|
||||
g_ptr_array_free(tw->buttons,TRUE);
|
||||
g_free(tw);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean text_window_delete_event_cb(GtkWidget *win _U_, GdkEvent *event _U_, gpointer user_data)
|
||||
{
|
||||
funnel_text_window_t* tw = (funnel_text_window_t *)user_data;
|
||||
|
||||
window_destroy(GTK_WIDGET(tw->win));
|
||||
tw->win = NULL;
|
||||
|
||||
if (tw->close_cb)
|
||||
tw->close_cb(tw->close_data);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static funnel_text_window_t* new_text_window(const char* title) {
|
||||
funnel_text_window_t* tw = (funnel_text_window_t *)g_malloc(sizeof(funnel_text_window_t));
|
||||
GtkWidget *txt_scrollw, *main_vb, *hbox;
|
||||
|
||||
tw->close_cb = NULL;
|
||||
tw->close_data = NULL;
|
||||
tw->buttons = g_ptr_array_new();
|
||||
|
||||
tw->win = dlg_window_new(title); /* transient_for top_level */
|
||||
gtk_window_set_destroy_with_parent (GTK_WINDOW(tw->win), TRUE);
|
||||
|
||||
g_signal_connect(tw->win, "delete-event", G_CALLBACK(text_window_delete_event_cb), tw);
|
||||
|
||||
txt_scrollw = scrolled_window_new(NULL, NULL);
|
||||
main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(main_vb), 6);
|
||||
gtk_container_add(GTK_CONTAINER(tw->win), main_vb);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX (main_vb), txt_scrollw, TRUE, TRUE, 0);
|
||||
|
||||
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(txt_scrollw),
|
||||
GTK_SHADOW_IN);
|
||||
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scrollw),
|
||||
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
tw->txt = gtk_text_view_new();
|
||||
gtk_text_view_set_editable(GTK_TEXT_VIEW(tw->txt), FALSE);
|
||||
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tw->txt), GTK_WRAP_WORD);
|
||||
gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(tw->txt), FALSE);
|
||||
|
||||
gtk_text_view_set_left_margin(GTK_TEXT_VIEW(tw->txt), 4);
|
||||
gtk_text_view_set_right_margin(GTK_TEXT_VIEW(tw->txt), 4);
|
||||
|
||||
hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0, FALSE);
|
||||
gtk_widget_show(hbox);
|
||||
|
||||
tw->button_hbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
|
||||
gtk_button_box_set_layout(GTK_BUTTON_BOX(tw->button_hbox), GTK_BUTTONBOX_START);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(hbox), tw->button_hbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show(tw->button_hbox);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(main_vb), hbox, FALSE, FALSE, 0);
|
||||
|
||||
tw->bt_close = gtk_button_new_with_label("Close");
|
||||
gtk_widget_set_can_default(tw->bt_close, TRUE);
|
||||
g_object_set_data(G_OBJECT(hbox), "Close", tw->bt_close);
|
||||
|
||||
gtk_box_pack_end(GTK_BOX(hbox), tw->bt_close, FALSE, FALSE, 0);
|
||||
gtk_widget_show(tw->bt_close);
|
||||
|
||||
g_signal_connect(tw->bt_close, "clicked", G_CALLBACK(text_window_cancel_button_cb), tw);
|
||||
gtk_widget_grab_default(tw->bt_close);
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(txt_scrollw), tw->txt);
|
||||
gtk_window_resize(GTK_WINDOW(tw->win),400,300);
|
||||
gtk_widget_show_all(tw->win);
|
||||
|
||||
return tw;
|
||||
}
|
||||
|
||||
|
||||
static void text_window_clear(funnel_text_window_t* tw)
|
||||
{
|
||||
GtkTextBuffer *buf;
|
||||
|
||||
if (! tw->win) return;
|
||||
|
||||
buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tw->txt));
|
||||
|
||||
gtk_text_buffer_set_text(buf, "", 0);
|
||||
}
|
||||
|
||||
|
||||
static void text_window_append(funnel_text_window_t* tw, const char *str)
|
||||
{
|
||||
GtkWidget *txt;
|
||||
int nchars;
|
||||
GtkTextBuffer *buf;
|
||||
GtkTextIter iter;
|
||||
|
||||
if (! tw->win) return;
|
||||
|
||||
txt = tw->txt;
|
||||
nchars = (int) strlen(str);
|
||||
|
||||
|
||||
buf= gtk_text_view_get_buffer(GTK_TEXT_VIEW(txt));
|
||||
|
||||
gtk_text_buffer_get_end_iter(buf, &iter);
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
gtk_widget_override_font(GTK_WIDGET(txt), user_font_get_regular());
|
||||
#else
|
||||
gtk_widget_modify_font(GTK_WIDGET(txt), user_font_get_regular());
|
||||
#endif
|
||||
if (!g_utf8_validate(str, -1, NULL))
|
||||
printf("Invalid utf8 encoding: %s\n", str);
|
||||
|
||||
gtk_text_buffer_insert(buf, &iter, str, nchars);
|
||||
}
|
||||
|
||||
|
||||
static void text_window_set_text(funnel_text_window_t* tw, const char* text)
|
||||
{
|
||||
if (! tw->win) return;
|
||||
|
||||
text_window_clear(tw);
|
||||
text_window_append(tw, text);
|
||||
}
|
||||
|
||||
|
||||
static void text_window_prepend(funnel_text_window_t* tw, const char *str _U_) {
|
||||
GtkWidget *txt;
|
||||
int nchars;
|
||||
GtkTextBuffer *buf;
|
||||
GtkTextIter iter;
|
||||
|
||||
if (! tw->win) return;
|
||||
|
||||
txt = tw->txt;
|
||||
nchars = (int) strlen(str);
|
||||
|
||||
|
||||
buf= gtk_text_view_get_buffer(GTK_TEXT_VIEW(txt));
|
||||
|
||||
gtk_text_buffer_get_start_iter(buf, &iter);
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
gtk_widget_override_font(GTK_WIDGET(txt), user_font_get_regular());
|
||||
#else
|
||||
gtk_widget_modify_font(GTK_WIDGET(txt), user_font_get_regular());
|
||||
#endif
|
||||
if (!g_utf8_validate(str, -1, NULL))
|
||||
printf("Invalid utf8 encoding: %s\n", str);
|
||||
|
||||
gtk_text_buffer_insert(buf, &iter, str, nchars);
|
||||
}
|
||||
|
||||
static const gchar* text_window_get_text(funnel_text_window_t* tw) {
|
||||
GtkWidget *txt;
|
||||
GtkTextBuffer *buf;
|
||||
GtkTextIter start;
|
||||
GtkTextIter end;
|
||||
|
||||
if (! tw->win) return "";
|
||||
|
||||
txt = tw->txt;
|
||||
|
||||
buf= gtk_text_view_get_buffer(GTK_TEXT_VIEW(txt));
|
||||
gtk_text_buffer_get_start_iter(buf, &start);
|
||||
gtk_text_buffer_get_end_iter(buf, &end);
|
||||
|
||||
return gtk_text_buffer_get_text(buf, &start, &end, FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void text_window_set_close_cb(funnel_text_window_t* tw, text_win_close_cb_t cb, void* data) {
|
||||
tw->close_cb = cb;
|
||||
tw->close_data = data;
|
||||
}
|
||||
|
||||
static void text_window_destroy(funnel_text_window_t* tw) {
|
||||
if (tw->win) {
|
||||
/*
|
||||
* the window is still there and its callbacks refer to this data structure
|
||||
* we need to change the callback so that they free tw.
|
||||
*/
|
||||
g_signal_connect(tw->bt_close, "clicked", G_CALLBACK(unref_text_win_cancel_bt_cb), tw);
|
||||
g_signal_connect(tw->win, "delete-event", G_CALLBACK(text_window_unref_del_event_cb), tw);
|
||||
} else {
|
||||
guint i;
|
||||
/*
|
||||
* we have no window anymore a human user closed
|
||||
* the window already just free the container
|
||||
*/
|
||||
for (i = 0; i < tw->buttons->len; i++) {
|
||||
funnel_bt_t* cbd = (funnel_bt_t *)g_ptr_array_index(tw->buttons,i);
|
||||
/* XXX a free cb should be passed somehow */
|
||||
if (cbd->data && cbd->free_data_fcn) cbd->free_data_fcn(cbd->data);
|
||||
if (cbd->free_fcn) cbd->free_fcn(cbd);
|
||||
}
|
||||
g_ptr_array_free(tw->buttons,TRUE);
|
||||
g_free(tw);
|
||||
}
|
||||
}
|
||||
|
||||
static void text_window_set_editable(funnel_text_window_t* tw, gboolean editable){
|
||||
gtk_text_view_set_editable(GTK_TEXT_VIEW(tw->txt), editable);
|
||||
gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(tw->txt), editable);
|
||||
}
|
||||
|
||||
static gboolean text_window_button_cb(GtkWidget *bt _U_, gpointer user_data)
|
||||
{
|
||||
funnel_bt_t* cbd = (funnel_bt_t *)user_data;
|
||||
|
||||
if (cbd->func) {
|
||||
return cbd->func(cbd->tw,cbd->data);
|
||||
} else {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static void text_window_add_button(funnel_text_window_t* tw, funnel_bt_t* cbd, const gchar* label) {
|
||||
GtkWidget *button;
|
||||
|
||||
cbd->tw = tw;
|
||||
g_ptr_array_add(tw->buttons,cbd);
|
||||
|
||||
button = gtk_button_new_with_label(label);
|
||||
gtk_widget_set_can_default(button, TRUE);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(tw->button_hbox), button, FALSE, FALSE, 0);
|
||||
|
||||
gtk_widget_show(button);
|
||||
g_signal_connect(button, "clicked", G_CALLBACK(text_window_button_cb), cbd);
|
||||
|
||||
}
|
||||
|
||||
|
||||
struct _funnel_dlg_data {
|
||||
GtkWidget* win;
|
||||
GPtrArray* entries;
|
||||
funnel_dlg_cb_t dlg_cb;
|
||||
void* data;
|
||||
};
|
||||
|
||||
static gboolean funnel_dlg_cb(GtkWidget *win _U_, gpointer user_data)
|
||||
{
|
||||
struct _funnel_dlg_data* dd = (struct _funnel_dlg_data *)user_data;
|
||||
guint i;
|
||||
guint len = dd->entries->len;
|
||||
GPtrArray* returns = g_ptr_array_new();
|
||||
|
||||
for(i=0; i<len; i++) {
|
||||
GtkEntry* entry = (GtkEntry *)g_ptr_array_index(dd->entries,i);
|
||||
g_ptr_array_add(returns,g_strdup(gtk_entry_get_text(entry)));
|
||||
}
|
||||
|
||||
g_ptr_array_add(returns,NULL);
|
||||
|
||||
if (dd->dlg_cb)
|
||||
dd->dlg_cb((gchar**)returns->pdata,dd->data);
|
||||
|
||||
window_destroy(GTK_WIDGET(dd->win));
|
||||
|
||||
g_ptr_array_free(returns,FALSE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void funnel_cancel_btn_cb(GtkWidget *bt _U_, gpointer data) {
|
||||
GtkWidget* win = (GtkWidget *)data;
|
||||
|
||||
window_destroy(GTK_WIDGET(win));
|
||||
}
|
||||
|
||||
static void funnel_new_dialog(const gchar* title,
|
||||
const gchar** fieldnames,
|
||||
funnel_dlg_cb_t dlg_cb,
|
||||
void* data) {
|
||||
GtkWidget *win, *main_grid, *main_vb, *bbox, *bt_cancel, *bt_ok;
|
||||
guint i;
|
||||
const gchar* fieldname;
|
||||
struct _funnel_dlg_data* dd = (struct _funnel_dlg_data *)g_malloc(sizeof(struct _funnel_dlg_data));
|
||||
|
||||
dd->entries = g_ptr_array_new();
|
||||
dd->dlg_cb = dlg_cb;
|
||||
dd->data = data;
|
||||
|
||||
win = dlg_window_new(title);
|
||||
|
||||
dd->win = win;
|
||||
|
||||
for (i=0; fieldnames[i]; i++);
|
||||
gtk_window_resize(GTK_WINDOW(win),400,10*(i+2));
|
||||
|
||||
main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 5, FALSE);
|
||||
gtk_container_add(GTK_CONTAINER(win), main_vb);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(main_vb), 6);
|
||||
|
||||
main_grid = ws_gtk_grid_new();
|
||||
gtk_box_pack_start(GTK_BOX(main_vb), main_grid, FALSE, FALSE, 0);
|
||||
ws_gtk_grid_set_row_spacing(GTK_GRID(main_grid), 10);
|
||||
ws_gtk_grid_set_column_spacing(GTK_GRID(main_grid), 15);
|
||||
|
||||
for (i = 0; (fieldname = fieldnames[i]) ; i++) {
|
||||
GtkWidget *entry, *label;
|
||||
|
||||
label = gtk_label_new(fieldname);
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 1.0f, 0.5f);
|
||||
ws_gtk_grid_attach_defaults(GTK_GRID(main_grid), label, 0, i+1, 1, 1);
|
||||
gtk_widget_show(label);
|
||||
|
||||
entry = gtk_entry_new();
|
||||
g_ptr_array_add(dd->entries,entry);
|
||||
ws_gtk_grid_attach_defaults(GTK_GRID(main_grid), entry, 1, i+1, 1, 1);
|
||||
gtk_widget_show(entry);
|
||||
}
|
||||
|
||||
bbox = dlg_button_row_new(GTK_STOCK_CANCEL,GTK_STOCK_OK, NULL);
|
||||
gtk_box_pack_start(GTK_BOX(main_vb), bbox, FALSE, FALSE, 0);
|
||||
|
||||
bt_ok = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
|
||||
g_signal_connect(bt_ok, "clicked", G_CALLBACK(funnel_dlg_cb), dd);
|
||||
gtk_widget_grab_default(bt_ok);
|
||||
|
||||
bt_cancel = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
|
||||
g_signal_connect(bt_cancel, "clicked", G_CALLBACK(funnel_cancel_btn_cb), win);
|
||||
gtk_widget_grab_default(bt_cancel);
|
||||
|
||||
gtk_widget_show(main_grid);
|
||||
gtk_widget_show(main_vb);
|
||||
gtk_widget_show(win);
|
||||
}
|
||||
|
||||
static const gchar * funnel_get_filter(funnel_ops_id_t *ops_id _U_ _U_) {
|
||||
return gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
|
||||
}
|
||||
|
||||
static void funnel_set_filter(funnel_ops_id_t *ops_id _U_, const char* filter_string) {
|
||||
gtk_entry_set_text(GTK_ENTRY(main_display_filter_widget), filter_string);
|
||||
}
|
||||
|
||||
static void funnel_set_color_filter_slot(guint8 filt_nr, const gchar* filter_string) {
|
||||
gchar *err_msg = NULL;
|
||||
if (!color_filters_set_tmp(filt_nr, (gchar *)filter_string, FALSE, &err_msg)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
||||
g_free(err_msg);
|
||||
}
|
||||
}
|
||||
|
||||
static void funnel_apply_filter(funnel_ops_id_t *ops_id _U_) {
|
||||
const char* filter_string = gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
|
||||
main_filter_packets(&cfile, filter_string, FALSE);
|
||||
}
|
||||
|
||||
/* XXX: finish this */
|
||||
static void funnel_logger(const gchar *log_domain _U_,
|
||||
GLogLevelFlags log_level _U_,
|
||||
const gchar *message,
|
||||
gpointer user_data _U_) {
|
||||
fputs(message,stderr);
|
||||
}
|
||||
|
||||
static void funnel_retap_packets(funnel_ops_id_t *ops_id _U_) {
|
||||
cf_retap_packets(&cfile);
|
||||
}
|
||||
|
||||
static gboolean funnel_open_file(funnel_ops_id_t *ops_id _U_, const char* fname, const char* filter, char** err_str) {
|
||||
int err = 0;
|
||||
dfilter_t *rfcode = NULL;
|
||||
|
||||
*err_str = NULL;
|
||||
|
||||
switch (cfile.state) {
|
||||
case FILE_CLOSED:
|
||||
case FILE_READ_DONE:
|
||||
case FILE_READ_ABORTED:
|
||||
break;
|
||||
case FILE_READ_IN_PROGRESS:
|
||||
*err_str = g_strdup("file read in progress");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (filter) {
|
||||
if (!dfilter_compile(filter, &rfcode, err_str)) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* This closes the current file if it succeeds. */
|
||||
if (cf_open(&cfile, fname, WTAP_TYPE_AUTO, FALSE, &err) != CF_OK) {
|
||||
*err_str = g_strdup(g_strerror(err));
|
||||
dfilter_free(rfcode);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
cfile.rfcode = rfcode;
|
||||
|
||||
switch (cf_read(&cfile, FALSE)) {
|
||||
case CF_READ_OK:
|
||||
case CF_READ_ERROR:
|
||||
break;
|
||||
default:
|
||||
*err_str = g_strdup("problem while reading file");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static struct progdlg* funnel_new_progress_window(funnel_ops_id_t *ops_id _U_, const gchar* label, const gchar* task, gboolean terminate_is_stop, gboolean *stop_flag) {
|
||||
return create_progress_dlg(top_level, label, task, terminate_is_stop, stop_flag);
|
||||
}
|
||||
|
||||
static void funnel_update_progress(struct progdlg* win, float pr, const gchar* task) {
|
||||
update_progress_dlg(win, pr, task);
|
||||
}
|
||||
|
||||
static void funnel_destroy_progress_window(struct progdlg* win) {
|
||||
destroy_progress_dlg(win);
|
||||
}
|
||||
|
||||
static void funnel_reload_packets(funnel_ops_id_t *ops_id _U_) {
|
||||
if (cfile.state == FILE_READ_DONE) cf_reload(&cfile);
|
||||
}
|
||||
|
||||
static const funnel_ops_t funnel_ops = {
|
||||
NULL, /* ops_id */
|
||||
new_text_window,
|
||||
text_window_set_text,
|
||||
text_window_append,
|
||||
text_window_prepend,
|
||||
text_window_clear,
|
||||
text_window_get_text,
|
||||
text_window_set_close_cb,
|
||||
text_window_set_editable,
|
||||
text_window_destroy,
|
||||
text_window_add_button,
|
||||
/*...,*/
|
||||
funnel_new_dialog,
|
||||
NULL,
|
||||
funnel_logger,
|
||||
funnel_retap_packets,
|
||||
copy_to_clipboard,
|
||||
funnel_get_filter,
|
||||
funnel_set_filter,
|
||||
funnel_set_color_filter_slot,
|
||||
funnel_open_file,
|
||||
funnel_reload_packets,
|
||||
NULL,
|
||||
funnel_apply_filter,
|
||||
browser_open_url,
|
||||
browser_open_data_file,
|
||||
funnel_new_progress_window,
|
||||
funnel_update_progress,
|
||||
funnel_destroy_progress_window
|
||||
};
|
||||
|
||||
|
||||
typedef struct _menu_cb_t {
|
||||
void (*callback)(gpointer);
|
||||
void* callback_data;
|
||||
gboolean retap;
|
||||
} menu_cb_t;
|
||||
|
||||
static void our_menu_callback(void* unused _U_, gpointer data) {
|
||||
menu_cb_t* mcb = (menu_cb_t *)data;
|
||||
mcb->callback(mcb->callback_data);
|
||||
if (mcb->retap) cf_retap_packets(&cfile);
|
||||
}
|
||||
|
||||
static void register_menu_cb(const char *name,
|
||||
register_stat_group_t group,
|
||||
void (*callback)(gpointer),
|
||||
gpointer callback_data,
|
||||
gboolean retap) {
|
||||
|
||||
menu_cb_t* mcb = (menu_cb_t *)g_malloc(sizeof(menu_cb_t));
|
||||
const char *label = NULL, *str = NULL;
|
||||
|
||||
mcb->callback = callback;
|
||||
mcb->callback_data = callback_data;
|
||||
mcb->retap = retap;
|
||||
|
||||
str = strrchr(name,'/');
|
||||
if(str){
|
||||
label = str+1;
|
||||
}else{
|
||||
label = name;
|
||||
}
|
||||
|
||||
register_menu_bar_menu_items(
|
||||
stat_group_name(group), /* GUI path to the place holder in the menu */
|
||||
name, /* Action name */
|
||||
NULL, /* Stock id */
|
||||
label, /* label */
|
||||
NULL, /* Accelerator */
|
||||
NULL, /* Tooltip */
|
||||
our_menu_callback, /* Callback */
|
||||
mcb, /* callback data */
|
||||
TRUE, /* enabled */
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void initialize_funnel_ops(void) {
|
||||
funnel_set_funnel_ops(&funnel_ops);
|
||||
}
|
||||
|
||||
void
|
||||
register_tap_listener_gtkfunnel(void)
|
||||
{
|
||||
funnel_register_all_menus(register_menu_cb);
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
||||
* :indentSize=4:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -1,180 +0,0 @@
|
|||
/* goto_dlg.c
|
||||
* Routines for "go to packet" window
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../../globals.h"
|
||||
#include "ui/simple_dialog.h"
|
||||
|
||||
#include "ui/gtk/goto_dlg.h"
|
||||
#include "ui/gtk/dlg_utils.h"
|
||||
#include "ui/gtk/gui_utils.h"
|
||||
#include "ui/gtk/help_dlg.h"
|
||||
#include "ui/gtk/packet_list.h"
|
||||
|
||||
/* Capture callback data keys */
|
||||
#define E_GOTO_FNUMBER_KEY "goto_fnumber_te"
|
||||
|
||||
static void
|
||||
goto_frame_ok_cb(GtkWidget *ok_bt, gpointer parent_w);
|
||||
|
||||
void
|
||||
goto_frame_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||
{
|
||||
GtkWidget *goto_frame_w, *main_vb, *fnumber_hb, *fnumber_lb, *fnumber_te,
|
||||
*bbox, *ok_bt, *cancel_bt, *help_bt;
|
||||
|
||||
goto_frame_w = dlg_window_new("Wireshark: Go To Packet");
|
||||
|
||||
/* Container for each row of widgets */
|
||||
main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
|
||||
gtk_container_add(GTK_CONTAINER(goto_frame_w), main_vb);
|
||||
gtk_widget_show(main_vb);
|
||||
|
||||
/* Frame number row */
|
||||
fnumber_hb = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
|
||||
gtk_box_pack_start(GTK_BOX (main_vb), fnumber_hb, TRUE, TRUE, 0);
|
||||
gtk_widget_show(fnumber_hb);
|
||||
|
||||
fnumber_lb = gtk_label_new("Packet number:");
|
||||
gtk_box_pack_start(GTK_BOX(fnumber_hb), fnumber_lb, FALSE, FALSE, 0);
|
||||
gtk_widget_show(fnumber_lb);
|
||||
|
||||
fnumber_te = gtk_entry_new();
|
||||
gtk_box_pack_start(GTK_BOX(fnumber_hb), fnumber_te, FALSE, FALSE, 0);
|
||||
gtk_widget_show(fnumber_te);
|
||||
|
||||
/* Button row: OK and cancel buttons */
|
||||
bbox = dlg_button_row_new(GTK_STOCK_JUMP_TO, GTK_STOCK_CANCEL, GTK_STOCK_HELP, NULL);
|
||||
gtk_box_pack_start(GTK_BOX (main_vb), bbox, TRUE, TRUE, 0);
|
||||
|
||||
gtk_widget_show(bbox);
|
||||
|
||||
ok_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_JUMP_TO);
|
||||
g_signal_connect(ok_bt, "clicked", G_CALLBACK(goto_frame_ok_cb), goto_frame_w);
|
||||
|
||||
cancel_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
|
||||
window_set_cancel_button(goto_frame_w, cancel_bt, window_cancel_button_cb);
|
||||
|
||||
help_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
|
||||
g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb), (gpointer)HELP_GOTO_DIALOG);
|
||||
|
||||
gtk_widget_grab_default(ok_bt);
|
||||
|
||||
/* Catch the "activate" signal on the frame number text entry, so that
|
||||
if the user types Return there, we act as if the "OK" button
|
||||
had been selected, as happens if Return is typed if some widget
|
||||
that *doesn't* handle the Return key has the input focus. */
|
||||
dlg_set_activate(fnumber_te, ok_bt);
|
||||
|
||||
/* Give the initial focus to the "Packet number" entry box. */
|
||||
gtk_widget_grab_focus(fnumber_te);
|
||||
|
||||
/* Attach pointers to needed widgets to the capture prefs window/object */
|
||||
g_object_set_data(G_OBJECT(goto_frame_w), E_GOTO_FNUMBER_KEY, fnumber_te);
|
||||
|
||||
g_signal_connect(goto_frame_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
||||
|
||||
gtk_widget_show(goto_frame_w);
|
||||
window_present(goto_frame_w);
|
||||
}
|
||||
|
||||
static void
|
||||
goto_frame_ok_cb(GtkWidget *ok_bt _U_, gpointer parent_w)
|
||||
{
|
||||
GtkWidget *fnumber_te;
|
||||
const gchar *fnumber_text;
|
||||
guint fnumber;
|
||||
char *p;
|
||||
|
||||
fnumber_te = (GtkWidget *)g_object_get_data(G_OBJECT(parent_w), E_GOTO_FNUMBER_KEY);
|
||||
|
||||
fnumber_text = gtk_entry_get_text(GTK_ENTRY(fnumber_te));
|
||||
fnumber = (guint) strtoul(fnumber_text, &p, 10);
|
||||
if (p == fnumber_text || *p != '\0') {
|
||||
/* Illegal number.
|
||||
XXX - what about negative numbers (which "strtoul()" allows)?
|
||||
Can we hack up signal handlers for the widget to make it
|
||||
reject attempts to type in characters other than digits?
|
||||
What about numbers > the maximum possible guint? */
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"The packet number you entered isn't a valid number.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (cf_goto_frame(&cfile, fnumber)) {
|
||||
/* We succeeded in going to that frame; we're done. */
|
||||
window_destroy(GTK_WIDGET(parent_w));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Go to frame specified by currently selected protocol tree item.
|
||||
*/
|
||||
void
|
||||
goto_framenum_cb(GtkWidget *w _U_, gpointer data _U_)
|
||||
{
|
||||
cf_goto_framenum(&cfile);
|
||||
}
|
||||
|
||||
void
|
||||
goto_top_frame_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||
{
|
||||
packet_list_select_first_row();
|
||||
}
|
||||
|
||||
void
|
||||
goto_bottom_frame_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||
{
|
||||
packet_list_select_last_row();
|
||||
}
|
||||
|
||||
void
|
||||
goto_next_frame_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||
{
|
||||
packet_list_next();
|
||||
}
|
||||
|
||||
void
|
||||
goto_previous_frame_cb(GtkWidget *w _U_, gpointer d _U_)
|
||||
{
|
||||
packet_list_prev();
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local Variables:
|
||||
* c-basic-offset: 2
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=2 tabstop=8 expandtab:
|
||||
* :indentSize=2:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -1,74 +0,0 @@
|
|||
/* goto_dlg.h
|
||||
* Definitions for "go to frame" window
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __GOTO_DLG_H__
|
||||
#define __GOTO_DLG_H__
|
||||
|
||||
/** @file
|
||||
* "Go To" dialog box and similar functions.
|
||||
* @ingroup dialog_group
|
||||
*/
|
||||
|
||||
/** User requested the "Go To" dialog box by menu or toolbar.
|
||||
*
|
||||
* @param widget parent widget (unused)
|
||||
* @param data unused
|
||||
*/
|
||||
extern void goto_frame_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
/** User requested "Go To Corresponding Packet" by menu.
|
||||
*
|
||||
* @param widget parent widget (unused)
|
||||
* @param data unused
|
||||
*/
|
||||
extern void goto_framenum_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
/** User requested "Go To First Packet" by menu or toolbar.
|
||||
*
|
||||
* @param widget parent widget (unused)
|
||||
* @param data unused
|
||||
*/
|
||||
extern void goto_top_frame_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
/** User requested "Go To Last Packet" by menu or toolbar.
|
||||
*
|
||||
* @param widget parent widget (unused)
|
||||
* @param data unused
|
||||
*/
|
||||
extern void goto_bottom_frame_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
/** User requested "Go To Next Packet" by menu or toolbar.
|
||||
*
|
||||
* @param widget parent widget (unused)
|
||||
* @param data unused
|
||||
*/
|
||||
extern void goto_next_frame_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
/** User requested "Go To Previous Packet" by menu or toolbar.
|
||||
*
|
||||
* @param widget parent widget (unused)
|
||||
* @param data unused
|
||||
*/
|
||||
extern void goto_previous_frame_cb(GtkWidget *widget, gpointer data);
|
||||
|
||||
#endif /* goto_dlg.h */
|
File diff suppressed because it is too large
Load Diff
|
@ -1,111 +0,0 @@
|
|||
/* graph_analysis.h
|
||||
* Graphic Analysis addition for Wireshark
|
||||
*
|
||||
* Copyright 2004, Verso Technologies Inc.
|
||||
* By Alejandro Vaquero <alejandrovaquero@yahoo.com>
|
||||
*
|
||||
* based on rtp_analysis.c and io_stat
|
||||
*
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __GRAPH_ANALYSIS_H__
|
||||
#define __GRAPH_ANALYSIS_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <epan/address.h>
|
||||
#include <epan/sequence_analysis.h>
|
||||
|
||||
/** max number of nodes to display, each node will be an IP address */
|
||||
#define MAX_NUM_COL_CONV 10
|
||||
#define NUM_DISPLAY_ITEMS 1000
|
||||
|
||||
typedef struct _display_items {
|
||||
guint32 frame_number; /**< frame number */
|
||||
guint16 port_src;
|
||||
guint16 port_dst;
|
||||
gchar *frame_label; /**< the label on top of the arrow */
|
||||
gchar *time_str; /**< timestamp */
|
||||
gchar *comment; /**< a comment that appears at the right of the graph */
|
||||
guint16 conv_num; /**< the conversation number, each conversation will be colored */
|
||||
guint16 src_node; /**< this is used by graph_analysis.c to identify the node */
|
||||
guint16 dst_node; /**< a node is an IP address that will be displayed in columns */
|
||||
guint16 line_style; /**< the arrow line width in pixels*/
|
||||
} display_items_t;
|
||||
|
||||
typedef struct _graph_analysis_dialog_data_t {
|
||||
GtkWidget *window;
|
||||
GtkWidget *parent_w;
|
||||
gboolean needs_redraw;
|
||||
gboolean inverse; /**< set the nodes in reverse mode as "dst <---- src" instead of "src ----> dst"*/
|
||||
gint selected_row;
|
||||
GtkWidget *draw_area_time;
|
||||
GtkWidget *draw_area;
|
||||
GtkWidget *draw_area_comments;
|
||||
#if GTK_CHECK_VERSION(2,22,0)
|
||||
cairo_surface_t *surface_time;
|
||||
cairo_surface_t *surface_main;
|
||||
cairo_surface_t *surface_comments;
|
||||
cairo_surface_t *surface_tile_select;
|
||||
#else
|
||||
GdkPixmap *pixmap_time;
|
||||
GdkPixmap *pixmap_main;
|
||||
GdkPixmap *pixmap_comments;
|
||||
GdkPixmap *pixmap_tile_select;
|
||||
#endif
|
||||
GtkWidget *scroll_window;
|
||||
GtkWidget *scroll_window_time; /**< to enable mouse scroll from this area */
|
||||
GtkWidget *scroll_window_comments; /**< to enable mouse scroll from this area */
|
||||
GtkWidget *v_scrollbar;
|
||||
GtkAdjustment *v_scrollbar_adjustment;
|
||||
GtkWidget *hpane;
|
||||
int surface_width;
|
||||
int surface_height;
|
||||
guint16 first_node; /**< the first node on the left to show in the screen */
|
||||
guint32 first_item; /**< the first item (row) to show from the top */
|
||||
guint32 last_item; /**< the last item displayed (for correct mouse scroll handling) */
|
||||
guint32 selected_item; /**< the selected item */
|
||||
display_items_t items[NUM_DISPLAY_ITEMS];
|
||||
guint32 left_x_border;
|
||||
char *title; /**< Graph analysis window's title */
|
||||
} graph_analysis_dialog_data_t;
|
||||
|
||||
typedef void (*destroy_user_data_cb)(void *data);
|
||||
|
||||
/** structure that holds general information and the dialog */
|
||||
typedef struct _graph_analysis_data_t {
|
||||
/**> graphic data */
|
||||
seq_analysis_info_t *graph_info;
|
||||
|
||||
/**> dialog associated data */
|
||||
graph_analysis_dialog_data_t dlg;
|
||||
guint32 num_items;
|
||||
destroy_user_data_cb on_destroy_user_data; /**< callback info for destroy */
|
||||
void *data; /**< data to be passed when on destroy */
|
||||
} graph_analysis_data_t;
|
||||
|
||||
graph_analysis_data_t* graph_analysis_init(seq_analysis_info_t *sainfo);
|
||||
void graph_analysis_create(graph_analysis_data_t* user_data);
|
||||
void graph_analysis_update(graph_analysis_data_t* user_data);
|
||||
void graph_analysis_redraw(graph_analysis_data_t* user_data);
|
||||
|
||||
|
||||
#endif /* __GRAPH_ANALYSIS_H__ */
|
|
@ -1,429 +0,0 @@
|
|||
/* gsm_map_summary.c
|
||||
* Routines for GSM MAP Statictics summary window
|
||||
*
|
||||
* Copyright 2004, Michael Lum <mlum [AT] telostech.com>
|
||||
* In association with Telos Technology Inc.
|
||||
*
|
||||
* Modified from summary_dlg.c
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <epan/packet.h>
|
||||
#include <epan/tap.h>
|
||||
#include <epan/asn1.h>
|
||||
#include <epan/dissectors/packet-gsm_map.h>
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
#include "ui/simple_dialog.h"
|
||||
#include "ui/summary.h"
|
||||
|
||||
#include <epan/stat_tap_ui.h>
|
||||
#include "ui/gtk/gui_stat_menu.h"
|
||||
|
||||
#include "ui/gtk/dlg_utils.h"
|
||||
#include "ui/gtk/gui_utils.h"
|
||||
|
||||
/** Gsm map statistic data */
|
||||
typedef struct _gsm_map_stat_t {
|
||||
int opr_code[GSM_MAP_MAX_NUM_OPR_CODES];
|
||||
int size[GSM_MAP_MAX_NUM_OPR_CODES];
|
||||
|
||||
int opr_code_rr[GSM_MAP_MAX_NUM_OPR_CODES];
|
||||
int size_rr[GSM_MAP_MAX_NUM_OPR_CODES];
|
||||
} gsm_map_stat_t;
|
||||
|
||||
gsm_map_stat_t gsm_map_stat;
|
||||
|
||||
#define SUM_STR_MAX 1024
|
||||
|
||||
void register_tap_listener_gtk_gsm_map_summary(void);
|
||||
|
||||
static void
|
||||
add_string_to_box(gchar *str, GtkWidget *box)
|
||||
{
|
||||
GtkWidget *lb;
|
||||
lb = gtk_label_new(str);
|
||||
gtk_misc_set_alignment(GTK_MISC(lb), 0.0f, 0.5f);
|
||||
gtk_box_pack_start(GTK_BOX(box), lb,FALSE,FALSE, 0);
|
||||
gtk_widget_show(lb);
|
||||
}
|
||||
|
||||
void gsm_map_stat_gtk_sum_cb(GtkAction *action _U_, gpointer user_data _U_)
|
||||
{
|
||||
summary_tally summary;
|
||||
GtkWidget *sum_open_w,
|
||||
*main_vb, *file_fr, *data_fr, *file_box,
|
||||
*data_box, *bbox, *close_bt,
|
||||
*invoke_fr, *invoke_box,
|
||||
*rr_fr, *rr_box,
|
||||
*tot_fr, *tot_box;
|
||||
|
||||
gchar string_buff[SUM_STR_MAX];
|
||||
double seconds;
|
||||
int i;
|
||||
int tot_invokes, tot_rr;
|
||||
double tot_invokes_size, tot_rr_size;
|
||||
|
||||
if (cfile.state == FILE_CLOSED) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* initialize the tally */
|
||||
summary_fill_in(&cfile, &summary);
|
||||
|
||||
/* initial computations */
|
||||
seconds = summary.stop_time - summary.start_time;
|
||||
|
||||
sum_open_w = dlg_window_new("GSM MAP Statistics: Summary"); /* transient_for top_level */
|
||||
gtk_window_set_destroy_with_parent (GTK_WINDOW(sum_open_w), TRUE);
|
||||
|
||||
/* Container for each row of widgets */
|
||||
main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
|
||||
gtk_container_add(GTK_CONTAINER(sum_open_w), main_vb);
|
||||
gtk_widget_show(main_vb);
|
||||
|
||||
/* File frame */
|
||||
file_fr = gtk_frame_new("File");
|
||||
gtk_box_pack_start(GTK_BOX (main_vb), file_fr, TRUE, TRUE, 0);
|
||||
gtk_widget_show(file_fr);
|
||||
|
||||
file_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
|
||||
gtk_container_add(GTK_CONTAINER(file_fr), file_box);
|
||||
gtk_widget_show(file_box);
|
||||
|
||||
/* filename */
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Name: %s", ((summary.filename) ? summary.filename : "None"));
|
||||
add_string_to_box(string_buff, file_box);
|
||||
|
||||
/* length */
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Length: %" G_GINT64_MODIFIER "d", summary.file_length);
|
||||
add_string_to_box(string_buff, file_box);
|
||||
|
||||
/* format */
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Format: %s", wtap_file_type_subtype_string(summary.file_type));
|
||||
add_string_to_box(string_buff, file_box);
|
||||
|
||||
if (summary.snap != 0) {
|
||||
/* snapshot length */
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Snapshot length: %u", summary.snap);
|
||||
add_string_to_box(string_buff, file_box);
|
||||
}
|
||||
|
||||
/* Data frame */
|
||||
data_fr = gtk_frame_new("Data");
|
||||
gtk_box_pack_start(GTK_BOX (main_vb), data_fr, TRUE, TRUE, 0);
|
||||
gtk_widget_show(data_fr);
|
||||
|
||||
data_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
|
||||
gtk_container_add(GTK_CONTAINER(data_fr), data_box);
|
||||
gtk_widget_show(data_box);
|
||||
|
||||
/*
|
||||
* We must have no un-time-stamped packets (i.e., the number of
|
||||
* time-stamped packets must be the same as the number of packets),
|
||||
* and at least two time-stamped packets, in order for the elapsed
|
||||
* time to be valid.
|
||||
*/
|
||||
if (summary.packet_count_ts == summary.packet_count &&
|
||||
summary.packet_count_ts >= 2) {
|
||||
/* seconds */
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Elapsed time: %.3f seconds", summary.elapsed_time);
|
||||
add_string_to_box(string_buff, data_box);
|
||||
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Between first and last packet: %.3f seconds", seconds);
|
||||
add_string_to_box(string_buff, data_box);
|
||||
}
|
||||
|
||||
/* Packet count */
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Packet count: %i", summary.packet_count);
|
||||
add_string_to_box(string_buff, data_box);
|
||||
|
||||
tot_invokes = 0;
|
||||
tot_invokes_size = 0;
|
||||
for (i=0; i < GSM_MAP_MAX_NUM_OPR_CODES; i++)
|
||||
{
|
||||
tot_invokes += gsm_map_stat.opr_code[i];
|
||||
tot_invokes_size += gsm_map_stat.size[i];
|
||||
}
|
||||
|
||||
tot_rr = 0;
|
||||
tot_rr_size = 0;
|
||||
for (i=0; i < GSM_MAP_MAX_NUM_OPR_CODES; i++)
|
||||
{
|
||||
tot_rr += gsm_map_stat.opr_code_rr[i];
|
||||
tot_rr_size += gsm_map_stat.size_rr[i];
|
||||
}
|
||||
|
||||
/* Invoke frame */
|
||||
invoke_fr = gtk_frame_new("Invokes");
|
||||
gtk_box_pack_start(GTK_BOX (main_vb), invoke_fr, TRUE, TRUE, 0);
|
||||
gtk_widget_show(invoke_fr);
|
||||
|
||||
invoke_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
|
||||
gtk_container_add(GTK_CONTAINER(invoke_fr), invoke_box);
|
||||
gtk_widget_show(invoke_box);
|
||||
|
||||
/* Total number of invokes */
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Total number of Invokes: %u", tot_invokes);
|
||||
add_string_to_box(string_buff, invoke_box);
|
||||
|
||||
/*
|
||||
* We must have no un-time-stamped packets (i.e., the number of
|
||||
* time-stamped packets must be the same as the number of packets),
|
||||
* and at least two time-stamped packets, in order for the elapsed
|
||||
* time to be valid.
|
||||
*/
|
||||
if (summary.packet_count_ts == summary.packet_count &&
|
||||
summary.packet_count_ts >= 2) {
|
||||
/* Total number of invokes per second */
|
||||
if (seconds)
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Total number of Invokes per second: %.2f", tot_invokes/seconds);
|
||||
else
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Total number of Invokes per second: N/A");
|
||||
add_string_to_box(string_buff, invoke_box);
|
||||
}
|
||||
|
||||
/* Total size of invokes */
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Total number of bytes for Invokes: %.0f", tot_invokes_size);
|
||||
add_string_to_box(string_buff, invoke_box);
|
||||
|
||||
/* Average size of invokes */
|
||||
if (tot_invokes)
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per Invoke: %.2f", tot_invokes_size/tot_invokes);
|
||||
else
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per Invoke: N/A");
|
||||
add_string_to_box(string_buff, invoke_box);
|
||||
|
||||
/*
|
||||
* We must have no un-time-stamped packets (i.e., the number of
|
||||
* time-stamped packets must be the same as the number of packets),
|
||||
* and at least two time-stamped packets, in order for the elapsed
|
||||
* time to be valid.
|
||||
*/
|
||||
if (summary.packet_count_ts == summary.packet_count &&
|
||||
summary.packet_count_ts >= 2) {
|
||||
/* Average size of invokes per second */
|
||||
if (seconds)
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per second: %.2f", tot_invokes_size/seconds);
|
||||
else
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per second: N/A");
|
||||
add_string_to_box(string_buff, invoke_box);
|
||||
}
|
||||
|
||||
/* Return Results frame */
|
||||
rr_fr = gtk_frame_new("Return Results");
|
||||
gtk_box_pack_start(GTK_BOX (main_vb), rr_fr, TRUE, TRUE, 0);
|
||||
gtk_widget_show(rr_fr);
|
||||
|
||||
rr_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
|
||||
gtk_container_add(GTK_CONTAINER(rr_fr), rr_box);
|
||||
gtk_widget_show(rr_box);
|
||||
|
||||
/* Total number of return results */
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Total number of Return Results: %u", tot_rr);
|
||||
add_string_to_box(string_buff, rr_box);
|
||||
|
||||
/*
|
||||
* We must have no un-time-stamped packets (i.e., the number of
|
||||
* time-stamped packets must be the same as the number of packets),
|
||||
* and at least two time-stamped packets, in order for the elapsed
|
||||
* time to be valid.
|
||||
*/
|
||||
if (summary.packet_count_ts == summary.packet_count &&
|
||||
summary.packet_count_ts >= 2) {
|
||||
/* Total number of return results per second */
|
||||
if (seconds)
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Total number of Return Results per second: %.2f", tot_rr/seconds);
|
||||
else
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Total number of Return Results per second: N/A");
|
||||
add_string_to_box(string_buff, rr_box);
|
||||
}
|
||||
|
||||
/* Total size of return results */
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Total number of bytes for Return Results: %.0f", tot_rr_size);
|
||||
add_string_to_box(string_buff, rr_box);
|
||||
|
||||
/* Average size of return results */
|
||||
if (tot_rr)
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per Return Result: %.2f", tot_rr_size/tot_rr);
|
||||
else
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per Return Result: N/A");
|
||||
add_string_to_box(string_buff, rr_box);
|
||||
|
||||
/*
|
||||
* We must have no un-time-stamped packets (i.e., the number of
|
||||
* time-stamped packets must be the same as the number of packets),
|
||||
* and at least two time-stamped packets, in order for the elapsed
|
||||
* time to be valid.
|
||||
*/
|
||||
if (summary.packet_count_ts == summary.packet_count &&
|
||||
summary.packet_count_ts >= 2) {
|
||||
/* Average size of return results per second */
|
||||
if (seconds)
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per second: %.2f", tot_rr_size/seconds);
|
||||
else
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per second: N/A");
|
||||
add_string_to_box(string_buff, rr_box);
|
||||
}
|
||||
|
||||
/* Totals frame */
|
||||
tot_fr = gtk_frame_new("Totals");
|
||||
gtk_box_pack_start(GTK_BOX (main_vb), tot_fr, TRUE, TRUE, 0);
|
||||
gtk_widget_show(tot_fr);
|
||||
|
||||
tot_box = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
|
||||
gtk_container_add(GTK_CONTAINER(tot_fr), tot_box);
|
||||
gtk_widget_show(tot_box);
|
||||
|
||||
/* Total number of return results */
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Total number of GSM MAP messages: %u", tot_invokes + tot_rr);
|
||||
add_string_to_box(string_buff, tot_box);
|
||||
|
||||
/*
|
||||
* We must have no un-time-stamped packets (i.e., the number of
|
||||
* time-stamped packets must be the same as the number of packets),
|
||||
* and at least two time-stamped packets, in order for the elapsed
|
||||
* time to be valid.
|
||||
*/
|
||||
if (summary.packet_count_ts == summary.packet_count &&
|
||||
summary.packet_count_ts >= 2) {
|
||||
if (seconds)
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Total number of GSM MAP messages per second: %.2f",
|
||||
(tot_invokes + tot_rr)/seconds);
|
||||
else
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Total number of GSM MAP messages per second: N/A");
|
||||
add_string_to_box(string_buff, tot_box);
|
||||
}
|
||||
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Total number of bytes for GSM MAP messages: %.0f", tot_invokes_size + tot_rr_size);
|
||||
add_string_to_box(string_buff, tot_box);
|
||||
|
||||
if (tot_invokes + tot_rr)
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per GSM MAP messages: %.2f",
|
||||
(tot_invokes_size + tot_rr_size)/(tot_invokes + tot_rr));
|
||||
else
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per GSM MAP messages: N/A");
|
||||
add_string_to_box(string_buff, tot_box);
|
||||
|
||||
/*
|
||||
* We must have no un-time-stamped packets (i.e., the number of
|
||||
* time-stamped packets must be the same as the number of packets),
|
||||
* and at least two time-stamped packets, in order for the elapsed
|
||||
* time to be valid.
|
||||
*/
|
||||
if (summary.packet_count_ts == summary.packet_count &&
|
||||
summary.packet_count_ts >= 2) {
|
||||
if (seconds)
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes second: %.2f",
|
||||
(tot_invokes_size + tot_rr_size)/seconds);
|
||||
else
|
||||
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes second: N/A");
|
||||
add_string_to_box(string_buff, tot_box);
|
||||
}
|
||||
|
||||
/* Button row. */
|
||||
bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
|
||||
gtk_box_pack_start(GTK_BOX(main_vb), bbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show(bbox);
|
||||
|
||||
close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
|
||||
window_set_cancel_button(sum_open_w, close_bt, window_cancel_button_cb);
|
||||
|
||||
g_signal_connect(sum_open_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
||||
|
||||
gtk_widget_show(sum_open_w);
|
||||
window_present(sum_open_w);
|
||||
}
|
||||
|
||||
static void
|
||||
gsm_map_summary_reset(void *tapdata)
|
||||
{
|
||||
gsm_map_stat_t *stat_p = (gsm_map_stat_t *)tapdata;
|
||||
|
||||
memset(stat_p, 0, sizeof(gsm_map_stat_t));
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
gsm_map_summary_packet(
|
||||
void *tapdata,
|
||||
packet_info *pinfo _U_,
|
||||
epan_dissect_t *edt _U_,
|
||||
const void *data)
|
||||
{
|
||||
gsm_map_stat_t *stat_p = (gsm_map_stat_t *)tapdata;
|
||||
const gsm_map_tap_rec_t *data_p = (const gsm_map_tap_rec_t *)data;
|
||||
|
||||
if (data_p->invoke)
|
||||
{
|
||||
stat_p->opr_code[data_p->opcode]++;
|
||||
stat_p->size[data_p->opcode] += data_p->size;
|
||||
}
|
||||
else
|
||||
{
|
||||
stat_p->opr_code_rr[data_p->opcode]++;
|
||||
stat_p->size_rr[data_p->opcode] += data_p->size;
|
||||
}
|
||||
|
||||
return(FALSE); /* We have no draw callback */
|
||||
}
|
||||
|
||||
void
|
||||
register_tap_listener_gtk_gsm_map_summary(void)
|
||||
{
|
||||
GString *err_p;
|
||||
|
||||
memset((void *) &gsm_map_stat, 0, sizeof(gsm_map_stat_t));
|
||||
|
||||
err_p =
|
||||
register_tap_listener("gsm_map", &gsm_map_stat, NULL, 0,
|
||||
gsm_map_summary_reset,
|
||||
gsm_map_summary_packet,
|
||||
NULL);
|
||||
|
||||
if (err_p != NULL)
|
||||
{
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_p->str);
|
||||
g_string_free(err_p, TRUE);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local Variables:
|
||||
* c-basic-offset: 2
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=2 tabstop=8 expandtab:
|
||||
* :indentSize=2:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -1,127 +0,0 @@
|
|||
/* gtk_iface_monitor.c
|
||||
* interface monitor by Pontus Fuchs <pontus.fuchs@gmail.com>
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_LIBPCAP
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <caputils/iface_monitor.h>
|
||||
|
||||
#include "capture_opts.h"
|
||||
|
||||
#include "ui/capture_globals.h"
|
||||
#include "ui/iface_lists.h"
|
||||
|
||||
#include "ui/gtk/capture_dlg.h"
|
||||
#include "ui/gtk/gtk_iface_monitor.h"
|
||||
|
||||
GIOChannel *iface_mon_channel;
|
||||
|
||||
static void
|
||||
gtk_iface_mon_event_cb(const char *iface, int up)
|
||||
{
|
||||
int present = 0;
|
||||
guint ifs, j;
|
||||
interface_t device;
|
||||
interface_options interface_opts;
|
||||
|
||||
for (ifs = 0; ifs < global_capture_opts.all_ifaces->len; ifs++) {
|
||||
device = g_array_index(global_capture_opts.all_ifaces, interface_t, ifs);
|
||||
if (strcmp(device.name, iface) == 0) {
|
||||
present = 1;
|
||||
if (!up) {
|
||||
/*
|
||||
* Interface went down or disappeared; remove all instances
|
||||
* of it from the current list of interfaces selected
|
||||
* for capturing.
|
||||
*/
|
||||
for (j = 0; j < global_capture_opts.ifaces->len; j++) {
|
||||
interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, j);
|
||||
if (strcmp(interface_opts.name, device.name) == 0) {
|
||||
g_array_remove_index(global_capture_opts.ifaces, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (present == up)
|
||||
return;
|
||||
|
||||
/*
|
||||
* We've been told that there's a new interface or that an old
|
||||
* interface is gone; reload the list and refresh all places
|
||||
* that are displaying the list.
|
||||
*/
|
||||
refresh_local_interface_lists();
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_iface_mon_event(GIOChannel *source _U_, GIOCondition condition _U_, gpointer data _U_)
|
||||
{
|
||||
iface_mon_event();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
gtk_iface_mon_start(void)
|
||||
{
|
||||
int sock, err;
|
||||
err = iface_mon_start(>k_iface_mon_event_cb);
|
||||
if (err)
|
||||
return err;
|
||||
sock = iface_mon_get_sock();
|
||||
|
||||
iface_mon_channel = g_io_channel_unix_new(sock);
|
||||
g_io_channel_set_encoding(iface_mon_channel, NULL, NULL);
|
||||
g_io_add_watch(iface_mon_channel,
|
||||
(GIOCondition)(G_IO_IN|G_IO_ERR|G_IO_HUP),
|
||||
>k_iface_mon_event,
|
||||
NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
gtk_iface_mon_stop(void)
|
||||
{
|
||||
iface_mon_stop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* HAVE_LIBPCAP */
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 4
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
||||
* :indentSize=4:tabSize=8:noTabs=true:
|
||||
*/
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue