forked from osmocom/wireshark
Refactor GUI dependencies out of color_filters.[ch] and move it to epan directory.
This also moved color.h into color_filters.h Change-Id: Ic19e27aa1b3ec67e764aa7ee8bbef7b1187bb12e Reviewed-on: https://code.wireshark.org/review/12831 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
parent
c752daf4b8
commit
5e4bbcda98
|
@ -1014,7 +1014,7 @@ add_subdirectory( wiretap )
|
|||
add_subdirectory( wsutil )
|
||||
|
||||
if(NOT WIN32)
|
||||
add_custom_target(dumpabi DEPENDS dumpabi-libwireshark dumpabi-libwiretap dumpabi-libwsutil color.h)
|
||||
add_custom_target(dumpabi DEPENDS dumpabi-libwireshark dumpabi-libwiretap dumpabi-libwsutil)
|
||||
endif()
|
||||
|
||||
if(ENABLE_ECHLD)
|
||||
|
@ -1695,7 +1695,6 @@ if( (BUILD_wireshark AND QT_FOUND) OR (BUILD_wireshark_gtk AND GTK_FOUND) )
|
|||
set(WIRESHARK_SRC
|
||||
capture_info.c
|
||||
capture_opts.c
|
||||
color_filters.c
|
||||
file.c
|
||||
fileset.c
|
||||
summary.c
|
||||
|
|
|
@ -50,7 +50,6 @@ SHARK_COMMON_SRC = \
|
|||
# corresponding headers
|
||||
SHARK_COMMON_INCLUDES = \
|
||||
cfile.h \
|
||||
color.h \
|
||||
extcap.h \
|
||||
extcap_parser.h \
|
||||
file.h \
|
||||
|
@ -64,7 +63,6 @@ WIRESHARK_COMMON_SRC = \
|
|||
$(SHARK_COMMON_SRC) \
|
||||
capture_info.c \
|
||||
capture_opts.c \
|
||||
color_filters.c \
|
||||
file.c \
|
||||
fileset.c \
|
||||
summary.c
|
||||
|
@ -73,7 +71,6 @@ WIRESHARK_COMMON_SRC = \
|
|||
WIRESHARK_COMMON_INCLUDES = \
|
||||
capture_info.h \
|
||||
capture_opts.h \
|
||||
color_filters.h \
|
||||
globals.h \
|
||||
log.h \
|
||||
summary.h \
|
||||
|
|
|
@ -454,6 +454,15 @@ androiddump.exe : $(LIBS_CHECK) config.h androiddump.obj wsutil\libwsutil.lib wi
|
|||
mt.exe -nologo -manifest "androiddump.exe.manifest" -outputresource:androiddump.exe;1
|
||||
!ENDIF
|
||||
|
||||
randpktdump.exe : $(LIBS_CHECK) config.h randpktdump.obj randpkt-core.obj wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib
|
||||
@echo Linking $@
|
||||
$(LINK) @<<
|
||||
/OUT:randpktdump.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:WINDOWS randpktdump.obj randpkt-core.obj $(randpktdump_LIBS)
|
||||
<<
|
||||
!IFDEF MANIFEST_INFO_REQUIRED
|
||||
mt.exe -nologo -manifest "randpktdump.exe.manifest" -outputresource:randpktdump.exe;1
|
||||
!ENDIF
|
||||
|
||||
!IFDEF LIBSSH_DIR
|
||||
sshdump.exe : $(LIBS_CHECK) config.h sshdump.obj wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib
|
||||
@echo Linking $@
|
||||
|
@ -465,15 +474,6 @@ sshdump.exe : $(LIBS_CHECK) config.h sshdump.obj wsutil\libwsutil.lib wiretap\wi
|
|||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
randpktdump.exe : $(LIBS_CHECK) config.h randpktdump.obj randpkt-core.obj wsutil\libwsutil.lib wiretap\wiretap-$(WTAP_VERSION).lib
|
||||
@echo Linking $@
|
||||
$(LINK) @<<
|
||||
/OUT:randpktdump.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:WINDOWS randpktdump.obj randpkt-core.obj $(randpktdump_LIBS)
|
||||
<<
|
||||
!IFDEF MANIFEST_INFO_REQUIRED
|
||||
mt.exe -nologo -manifest "randpktdump.exe.manifest" -outputresource:randpktdump.exe;1
|
||||
!ENDIF
|
||||
|
||||
dumpcap.exe : $(LIBS_CHECK) config.h $(dumpcap_OBJECTS) caputils wsutil\libwsutil.lib image\dumpcap.res
|
||||
@echo Linking $@
|
||||
$(LINK) @<<
|
||||
|
|
74
color.h
74
color.h
|
@ -1,74 +0,0 @@
|
|||
/* color.h
|
||||
* Definitions for "toolkit-independent" colors
|
||||
*
|
||||
* 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_H__
|
||||
#define __COLOR_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* Data structure holding RGB value for a color.
|
||||
*
|
||||
* XXX - yes, I know, there's a "pixel" value in there as well; for
|
||||
* now, it's intended to look just like a GdkColor but not to require
|
||||
* that any GTK+ header files be included in order to use it.
|
||||
* The way we handle colors needs to be cleaned up somewhat, in order
|
||||
* to keep toolkit-specific stuff separate from toolkit-independent stuff.
|
||||
*/
|
||||
typedef struct {
|
||||
guint32 pixel;
|
||||
guint16 red;
|
||||
guint16 green;
|
||||
guint16 blue;
|
||||
} color_t;
|
||||
|
||||
/** Initialize a color with R, G, and B values, including any toolkit-dependent
|
||||
** work that needs to be done.
|
||||
*
|
||||
* @param color the color_t to be filled
|
||||
* @param red the red value for the color
|
||||
* @param green the green value for the color
|
||||
* @param blue the blue value for the color
|
||||
* @return TRUE if it succeeds, FALSE if it fails
|
||||
*/
|
||||
gboolean initialize_color(color_t *color, guint16 red, guint16 green, guint16 blue);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __COLOR_H__ */
|
||||
|
||||
/*
|
||||
* 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,6 +1,5 @@
|
|||
usr/lib/*/libwireshark.so
|
||||
usr/lib/*/pkgconfig/wireshark.pc
|
||||
color.h usr/include/wireshark
|
||||
obj-*/config.h usr/include/wireshark
|
||||
register.h usr/include/wireshark
|
||||
epan/stat_groups.h usr/include/wireshark
|
||||
|
|
|
@ -1592,6 +1592,7 @@ set(LIBWIRESHARK_FILES
|
|||
capture_dissectors.c
|
||||
charsets.c
|
||||
circuit.c
|
||||
color_filters.c
|
||||
column.c
|
||||
column-utils.c
|
||||
conversation.c
|
||||
|
@ -1764,7 +1765,7 @@ endif()
|
|||
|
||||
ABICHECK(libwireshark)
|
||||
|
||||
set(TOP_LEVEL_HEADERS ${CMAKE_BINARY_DIR}/config.h ${CMAKE_SOURCE_DIR}/color.h ${CMAKE_SOURCE_DIR}/register.h)
|
||||
set(TOP_LEVEL_HEADERS ${CMAKE_BINARY_DIR}/config.h ${CMAKE_SOURCE_DIR}/register.h)
|
||||
file(GLOB CRYPT_HEADERS crypt/*.h)
|
||||
file(GLOB COMPRESS_HEADERS compress/*.h)
|
||||
file(GLOB DFILTER_HEADERS dfilter/*.h ../tools/lemon/cppmagic.h)
|
||||
|
|
|
@ -300,7 +300,7 @@ endif
|
|||
dumpabi-libwireshark: all abi-descriptor.xml
|
||||
rm -rf abi-check-headers abi_dumps .libs/*.abi.tar.gz
|
||||
mkdir abi-check-headers
|
||||
cp ../color.h ../config.h ../register.h abi-check-headers/
|
||||
cp ../config.h ../register.h abi-check-headers/
|
||||
mkdir abi-check-headers/epan
|
||||
cp *.h abi-check-headers/epan
|
||||
mkdir abi-check-headers/crypt
|
||||
|
|
|
@ -32,6 +32,7 @@ LIBWIRESHARK_SRC = \
|
|||
capture_dissectors.c \
|
||||
charsets.c \
|
||||
circuit.c \
|
||||
color_filters.c \
|
||||
column.c \
|
||||
column-utils.c \
|
||||
conversation.c \
|
||||
|
@ -161,6 +162,7 @@ LIBWIRESHARK_INCLUDES = \
|
|||
charsets.h \
|
||||
chdlctypes.h \
|
||||
circuit.h \
|
||||
color_filters.h \
|
||||
column.h \
|
||||
column-info.h \
|
||||
column-utils.h \
|
||||
|
|
|
@ -35,20 +35,17 @@
|
|||
#include <wsutil/file_util.h>
|
||||
|
||||
#include <epan/packet.h>
|
||||
#include "color.h"
|
||||
#include "color_filters.h"
|
||||
#include "file.h"
|
||||
#include <epan/dfilter/dfilter.h>
|
||||
#include <epan/prefs.h>
|
||||
|
||||
#include "ui/simple_dialog.h"
|
||||
#include "ui/ui_util.h"
|
||||
|
||||
#define RED_COMPONENT(x) (guint16) (((((x) >> 16) & 0xff) * 65535 / 255))
|
||||
#define GREEN_COMPONENT(x) (guint16) (((((x) >> 8) & 0xff) * 65535 / 255))
|
||||
#define BLUE_COMPONENT(x) (guint16) ( (((x) & 0xff) * 65535 / 255))
|
||||
|
||||
static gboolean read_users_filters(GSList **cfl);
|
||||
static gboolean read_users_filters(GSList **cfl, gchar** err_msg, initialize_color_func init_func, color_filter_add_cb_func add_cb);
|
||||
|
||||
/* the currently active filters */
|
||||
static GSList *color_filter_list = NULL;
|
||||
|
@ -87,7 +84,7 @@ color_filter_new(const gchar *name, /* The name of the filter to create
|
|||
|
||||
/* Add ten empty (temporary) colorfilters for easy coloring */
|
||||
static void
|
||||
color_filters_add_tmp(GSList **cfl)
|
||||
color_filters_add_tmp(GSList **cfl, initialize_color_func init_func)
|
||||
{
|
||||
gchar *name = NULL;
|
||||
guint32 i;
|
||||
|
@ -107,11 +104,11 @@ color_filters_add_tmp(GSList **cfl)
|
|||
|
||||
/* retrieve background and foreground colors */
|
||||
cval = strtoul(fg_colors[i-1], NULL, 16);
|
||||
initialize_color(&fg_color, RED_COMPONENT(cval),
|
||||
init_func(&fg_color, RED_COMPONENT(cval),
|
||||
GREEN_COMPONENT(cval),
|
||||
BLUE_COMPONENT(cval) );
|
||||
cval = strtoul(bg_colors[i-1], NULL, 16);
|
||||
initialize_color(&bg_color, RED_COMPONENT(cval),
|
||||
init_func(&bg_color, RED_COMPONENT(cval),
|
||||
GREEN_COMPONENT(cval),
|
||||
BLUE_COMPONENT(cval) );
|
||||
colorf = color_filter_new(name, NULL, &bg_color, &fg_color, TRUE);
|
||||
|
@ -138,17 +135,16 @@ color_filters_find_by_name_cb(gconstpointer arg1, gconstpointer arg2)
|
|||
|
||||
|
||||
/* Set the filter off a temporary colorfilters and enable it */
|
||||
void
|
||||
color_filters_set_tmp(guint8 filt_nr, const gchar *filter, gboolean disabled)
|
||||
gboolean
|
||||
color_filters_set_tmp(guint8 filt_nr, const gchar *filter, gboolean disabled, gchar **err_msg)
|
||||
{
|
||||
gchar *name = NULL;
|
||||
const gchar *tmpfilter = NULL;
|
||||
GSList *cfl;
|
||||
color_filter_t *colorf;
|
||||
dfilter_t *compiled_filter;
|
||||
gchar *err_msg;
|
||||
guint8 i;
|
||||
|
||||
gchar *local_err_msg = NULL;
|
||||
/* Go through the temporary filters and look for the same filter string.
|
||||
* If found, clear it so that a filter can be "moved" up and down the list
|
||||
*/
|
||||
|
@ -171,11 +167,10 @@ color_filters_set_tmp(guint8 filt_nr, const gchar *filter, gboolean disabled)
|
|||
* or if we found a matching filter string which need to be cleared
|
||||
*/
|
||||
tmpfilter = ( (filter==NULL) || (i!=filt_nr) ) ? "frame" : filter;
|
||||
if (!dfilter_compile(tmpfilter, &compiled_filter, &err_msg)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Could not compile color filter name: \"%s\""
|
||||
" text: \"%s\".\n%s", name, filter, err_msg);
|
||||
g_free(err_msg);
|
||||
if (!dfilter_compile(tmpfilter, &compiled_filter, &local_err_msg)) {
|
||||
*err_msg = g_strdup_printf( "Could not compile color filter name: \"%s\" text: \"%s\".\n%s", name, filter, local_err_msg);
|
||||
g_free(local_err_msg);
|
||||
return FALSE;
|
||||
} else {
|
||||
if (colorf->filter_text != NULL)
|
||||
g_free(colorf->filter_text);
|
||||
|
@ -191,7 +186,7 @@ color_filters_set_tmp(guint8 filt_nr, const gchar *filter, gboolean disabled)
|
|||
}
|
||||
g_free(name);
|
||||
}
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
const color_filter_t *
|
||||
|
@ -211,17 +206,18 @@ color_filters_tmp_color(guint8 filter_num) {
|
|||
}
|
||||
|
||||
/* Reset the temporary colorfilters */
|
||||
void
|
||||
color_filters_reset_tmp(void)
|
||||
gboolean
|
||||
color_filters_reset_tmp(gchar **err_msg)
|
||||
{
|
||||
guint8 i;
|
||||
|
||||
for ( i=1 ; i<=10 ; i++ ) {
|
||||
color_filters_set_tmp(i, NULL, TRUE);
|
||||
if (!color_filters_set_tmp(i, NULL, TRUE, err_msg))
|
||||
return FALSE;
|
||||
}
|
||||
/* Remember that there are now *no* temporary coloring filters set */
|
||||
tmp_colors_set = FALSE;
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* delete the specified filter */
|
||||
|
@ -296,23 +292,33 @@ color_filter_list_clone(GSList *cfl)
|
|||
}
|
||||
|
||||
/* Initialize the filter structures (reading from file) for general running, including app startup */
|
||||
void
|
||||
color_filters_init(void)
|
||||
gboolean
|
||||
color_filters_init(gchar** err_msg, initialize_color_func init_func, color_filter_add_cb_func add_cb)
|
||||
{
|
||||
/* delete all currently existing filters */
|
||||
color_filter_list_delete(&color_filter_list);
|
||||
|
||||
/* start the list with the temporary colorizing rules */
|
||||
color_filters_add_tmp(&color_filter_list);
|
||||
color_filters_add_tmp(&color_filter_list, init_func);
|
||||
|
||||
/* try to read the users filters */
|
||||
if (!read_users_filters(&color_filter_list))
|
||||
if (!read_users_filters(&color_filter_list, err_msg, init_func, add_cb)) {
|
||||
gchar* local_err_msg = NULL;
|
||||
|
||||
/* if that failed, try to read the global filters */
|
||||
color_filters_read_globals(&color_filter_list);
|
||||
if (!color_filters_read_globals(&color_filter_list, &local_err_msg, init_func, add_cb)) {
|
||||
/* Show the first error */
|
||||
g_free(local_err_msg);
|
||||
}
|
||||
|
||||
return (*err_msg == NULL);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
color_filters_reload(void)
|
||||
gboolean
|
||||
color_filters_reload(gchar** err_msg, initialize_color_func init_func, color_filter_add_cb_func add_cb)
|
||||
{
|
||||
/* "move" old entries to the deleted list
|
||||
* we must keep them until the dissection no longer needs them */
|
||||
|
@ -320,12 +326,21 @@ color_filters_reload(void)
|
|||
color_filter_list = NULL;
|
||||
|
||||
/* start the list with the temporary colorizing rules */
|
||||
color_filters_add_tmp(&color_filter_list);
|
||||
color_filters_add_tmp(&color_filter_list, init_func);
|
||||
|
||||
/* try to read the users filters */
|
||||
if (!read_users_filters(&color_filter_list))
|
||||
if (!read_users_filters(&color_filter_list, err_msg, init_func, add_cb)) {
|
||||
gchar* local_err_msg = NULL;
|
||||
|
||||
/* if that failed, try to read the global filters */
|
||||
color_filters_read_globals(&color_filter_list);
|
||||
if (!color_filters_read_globals(&color_filter_list, &local_err_msg, init_func, add_cb)) {
|
||||
/* Show the first error */
|
||||
g_free(local_err_msg);
|
||||
}
|
||||
|
||||
return (*err_msg == NULL);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -335,32 +350,44 @@ color_filters_cleanup(void)
|
|||
color_filter_list_delete(&color_filter_deleted_list);
|
||||
}
|
||||
|
||||
typedef struct _color_clone
|
||||
{
|
||||
gpointer user_data;
|
||||
color_filter_add_cb_func add_cb;
|
||||
} color_clone_t;
|
||||
|
||||
static void
|
||||
color_filters_clone_cb(gpointer filter_arg, gpointer user_data)
|
||||
{
|
||||
color_clone_t* clone_data = (color_clone_t*)user_data;
|
||||
color_filter_t * new_colorf = color_filter_clone((color_filter_t *)filter_arg);
|
||||
color_filter_add_cb (new_colorf, user_data);
|
||||
|
||||
clone_data->add_cb (new_colorf, clone_data->user_data);
|
||||
}
|
||||
|
||||
void
|
||||
color_filters_clone(gpointer user_data)
|
||||
color_filters_clone(gpointer user_data, color_filter_add_cb_func add_cb)
|
||||
{
|
||||
g_slist_foreach(color_filter_list, color_filters_clone_cb, user_data);
|
||||
color_clone_t clone_data;
|
||||
|
||||
clone_data.user_data = user_data;
|
||||
clone_data.add_cb = add_cb;
|
||||
g_slist_foreach(color_filter_list, color_filters_clone_cb, &clone_data);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
color_filter_compile_cb(gpointer filter_arg, gpointer unused _U_)
|
||||
color_filter_compile_cb(gpointer filter_arg, gpointer err)
|
||||
{
|
||||
color_filter_t *colorf = (color_filter_t *)filter_arg;
|
||||
gchar *err_msg;
|
||||
gchar **err_msg = (gchar**)err;
|
||||
gchar *local_err_msg = NULL;
|
||||
|
||||
g_assert(colorf->c_colorfilter == NULL);
|
||||
if (!dfilter_compile(colorf->filter_text, &colorf->c_colorfilter, &err_msg)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Could not compile color filter name: \"%s\" text: \"%s\".\n%s",
|
||||
colorf->filter_name, colorf->filter_text, err_msg);
|
||||
g_free(err_msg);
|
||||
if (!dfilter_compile(colorf->filter_text, &colorf->c_colorfilter, &local_err_msg)) {
|
||||
*err_msg = g_strdup_printf("Could not compile color filter name: \"%s\" text: \"%s\".\n%s",
|
||||
colorf->filter_name, colorf->filter_text, local_err_msg);
|
||||
g_free(local_err_msg);
|
||||
/* this filter was compilable before, so this should never happen */
|
||||
/* except if the OK button of the parent window has been clicked */
|
||||
/* so don't use g_assert_not_reached() but check the filters again */
|
||||
|
@ -368,17 +395,17 @@ color_filter_compile_cb(gpointer filter_arg, gpointer unused _U_)
|
|||
}
|
||||
|
||||
static void
|
||||
color_filter_validate_cb(gpointer filter_arg, gpointer unused _U_)
|
||||
color_filter_validate_cb(gpointer filter_arg, gpointer err)
|
||||
{
|
||||
color_filter_t *colorf = (color_filter_t *)filter_arg;
|
||||
gchar *err_msg;
|
||||
gchar **err_msg = (gchar**)err;
|
||||
gchar *local_err_msg;
|
||||
|
||||
g_assert(colorf->c_colorfilter == NULL);
|
||||
if (!dfilter_compile(colorf->filter_text, &colorf->c_colorfilter, &err_msg)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Removing color filter name: \"%s\" text: \"%s\".\n%s",
|
||||
colorf->filter_name, colorf->filter_text, err_msg);
|
||||
g_free(err_msg);
|
||||
if (!dfilter_compile(colorf->filter_text, &colorf->c_colorfilter, &local_err_msg)) {
|
||||
*err_msg = g_strdup_printf("Removing color filter name: \"%s\" text: \"%s\".\n%s",
|
||||
colorf->filter_name, colorf->filter_text, local_err_msg);
|
||||
g_free(local_err_msg);
|
||||
/* Delete the color filter from the list of color filters. */
|
||||
color_filter_valid_list = g_slist_remove(color_filter_valid_list, colorf);
|
||||
color_filter_delete(colorf);
|
||||
|
@ -386,9 +413,13 @@ color_filter_validate_cb(gpointer filter_arg, gpointer unused _U_)
|
|||
}
|
||||
|
||||
/* apply changes from the edit list */
|
||||
void
|
||||
color_filters_apply(GSList *tmp_cfl, GSList *edit_cfl)
|
||||
gboolean
|
||||
color_filters_apply(GSList *tmp_cfl, GSList *edit_cfl, gchar** err_msg)
|
||||
{
|
||||
gboolean ret = TRUE;
|
||||
|
||||
*err_msg = NULL;
|
||||
|
||||
/* "move" old entries to the deleted list
|
||||
* we must keep them until the dissection no longer needs them */
|
||||
color_filter_deleted_list = g_slist_concat(color_filter_deleted_list, color_filter_list);
|
||||
|
@ -401,13 +432,21 @@ color_filters_apply(GSList *tmp_cfl, GSList *edit_cfl)
|
|||
color_filter_list_clone(edit_cfl) );
|
||||
|
||||
/* compile all filter */
|
||||
g_slist_foreach(color_filter_valid_list, color_filter_validate_cb, NULL);
|
||||
g_slist_foreach(color_filter_valid_list, color_filter_validate_cb, err_msg);
|
||||
if (*err_msg != NULL) {
|
||||
ret = FALSE;
|
||||
}
|
||||
|
||||
/* clone all list entries from tmp/edit to normal list */
|
||||
color_filter_list = color_filter_list_clone(color_filter_valid_list);
|
||||
|
||||
/* compile all filter */
|
||||
g_slist_foreach(color_filter_list, color_filter_compile_cb, NULL);
|
||||
g_slist_foreach(color_filter_list, color_filter_compile_cb, err_msg);
|
||||
if (*err_msg != NULL) {
|
||||
ret = FALSE;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
@ -422,13 +461,6 @@ tmp_color_filters_used(void)
|
|||
return tmp_colors_set;
|
||||
}
|
||||
|
||||
void
|
||||
color_filters_enable(gboolean enable)
|
||||
{
|
||||
packet_list_enable_color(enable);
|
||||
}
|
||||
|
||||
|
||||
/* prepare the epan_dissect_t for the filter */
|
||||
static void
|
||||
prime_edt(gpointer data, gpointer user_data)
|
||||
|
@ -478,7 +510,7 @@ color_filters_colorize_packet(epan_dissect_t *edt)
|
|||
/* XXX - Would it make more sense to use GStrings here instead of reallocing
|
||||
our buffers? */
|
||||
static gboolean
|
||||
read_filters_file(FILE *f, gpointer user_data)
|
||||
read_filters_file(FILE *f, gpointer user_data, gchar** err_msg, initialize_color_func init_func, color_filter_add_cb_func add_cb)
|
||||
{
|
||||
#define INIT_BUF_SIZE 128
|
||||
gchar *name = NULL;
|
||||
|
@ -490,6 +522,7 @@ read_filters_file(FILE *f, gpointer user_data)
|
|||
guint16 fg_r, fg_g, fg_b, bg_r, bg_g, bg_b;
|
||||
gboolean disabled = FALSE;
|
||||
gboolean skip_end_of_line = FALSE;
|
||||
gboolean ret = TRUE;
|
||||
|
||||
name = (gchar *)g_malloc(name_len + 1);
|
||||
filter_exp = (gchar *)g_malloc(filter_exp_len + 1);
|
||||
|
@ -584,34 +617,32 @@ read_filters_file(FILE *f, gpointer user_data)
|
|||
color_t bg_color, fg_color;
|
||||
color_filter_t *colorf;
|
||||
dfilter_t *temp_dfilter;
|
||||
gchar *err_msg;
|
||||
gchar *local_err_msg = NULL;
|
||||
|
||||
if (!dfilter_compile(filter_exp, &temp_dfilter, &err_msg)) {
|
||||
if (!dfilter_compile(filter_exp, &temp_dfilter, &local_err_msg)) {
|
||||
g_warning("Could not compile \"%s\" in colorfilters file.\n%s",
|
||||
name, err_msg);
|
||||
g_free(err_msg);
|
||||
name, local_err_msg);
|
||||
g_free(local_err_msg);
|
||||
prefs.unknown_colorfilters = TRUE;
|
||||
|
||||
skip_end_of_line = TRUE;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!initialize_color(&fg_color, fg_r, fg_g, fg_b)) {
|
||||
if (!init_func(&fg_color, fg_r, fg_g, fg_b)) {
|
||||
/* oops */
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Could not allocate foreground color "
|
||||
"specified in input file for %s.", name);
|
||||
*err_msg = g_strdup_printf("Could not allocate foreground color specified in input file for %s.", name);
|
||||
dfilter_free(temp_dfilter);
|
||||
skip_end_of_line = TRUE;
|
||||
ret = FALSE;
|
||||
continue;
|
||||
}
|
||||
if (!initialize_color(&bg_color, bg_r, bg_g, bg_b)) {
|
||||
if (!init_func(&bg_color, bg_r, bg_g, bg_b)) {
|
||||
/* oops */
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Could not allocate background color "
|
||||
"specified in input file for %s.", name);
|
||||
*err_msg = g_strdup_printf("Could not allocate background color specified in input file for %s.", name);
|
||||
dfilter_free(temp_dfilter);
|
||||
skip_end_of_line = TRUE;
|
||||
ret = FALSE;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -627,7 +658,7 @@ read_filters_file(FILE *f, gpointer user_data)
|
|||
/* external call */
|
||||
/* just editing, don't need the compiled filter */
|
||||
dfilter_free(temp_dfilter);
|
||||
color_filter_add_cb (colorf, user_data);
|
||||
add_cb(colorf, user_data);
|
||||
}
|
||||
} /* if sscanf */
|
||||
|
||||
|
@ -636,12 +667,12 @@ read_filters_file(FILE *f, gpointer user_data)
|
|||
|
||||
g_free(name);
|
||||
g_free(filter_exp);
|
||||
return TRUE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* read filters from the user's filter file */
|
||||
static gboolean
|
||||
read_users_filters(GSList **cfl)
|
||||
read_users_filters(GSList **cfl, gchar** err_msg, initialize_color_func init_func, color_filter_add_cb_func add_cb)
|
||||
{
|
||||
gchar *path;
|
||||
FILE *f;
|
||||
|
@ -651,8 +682,7 @@ read_users_filters(GSList **cfl)
|
|||
path = get_persconffile_path("colorfilters", TRUE);
|
||||
if ((f = ws_fopen(path, "r")) == NULL) {
|
||||
if (errno != ENOENT) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Could not open filter file\n\"%s\": %s.", path,
|
||||
*err_msg = g_strdup_printf("Could not open filter file\n\"%s\": %s.", path,
|
||||
g_strerror(errno));
|
||||
}
|
||||
g_free(path);
|
||||
|
@ -661,14 +691,14 @@ read_users_filters(GSList **cfl)
|
|||
g_free(path);
|
||||
path = NULL;
|
||||
|
||||
ret = read_filters_file(f, cfl);
|
||||
ret = read_filters_file(f, cfl, err_msg, init_func, add_cb);
|
||||
fclose(f);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* read filters from the filter file */
|
||||
gboolean
|
||||
color_filters_read_globals(gpointer user_data)
|
||||
color_filters_read_globals(gpointer user_data, gchar** err_msg, initialize_color_func init_func, color_filter_add_cb_func add_cb)
|
||||
{
|
||||
gchar *path;
|
||||
FILE *f;
|
||||
|
@ -678,8 +708,7 @@ color_filters_read_globals(gpointer user_data)
|
|||
path = get_datafile_path("colorfilters");
|
||||
if ((f = ws_fopen(path, "r")) == NULL) {
|
||||
if (errno != ENOENT) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Could not open global filter file\n\"%s\": %s.", path,
|
||||
*err_msg = g_strdup_printf("Could not open global filter file\n\"%s\": %s.", path,
|
||||
g_strerror(errno));
|
||||
}
|
||||
g_free(path);
|
||||
|
@ -688,26 +717,25 @@ color_filters_read_globals(gpointer user_data)
|
|||
g_free(path);
|
||||
path = NULL;
|
||||
|
||||
ret = read_filters_file(f, user_data);
|
||||
ret = read_filters_file(f, user_data, err_msg, init_func, add_cb);
|
||||
fclose(f);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* read filters from some other filter file (import) */
|
||||
gboolean
|
||||
color_filters_import(const gchar *path, const gpointer user_data)
|
||||
color_filters_import(const gchar *path, const gpointer user_data, gchar** err_msg, initialize_color_func init_func, color_filter_add_cb_func add_cb)
|
||||
{
|
||||
FILE *f;
|
||||
gboolean ret;
|
||||
|
||||
if ((f = ws_fopen(path, "r")) == NULL) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Could not open\n%s\nfor reading: %s.",
|
||||
*err_msg = g_strdup_printf("Could not open\n%s\nfor reading: %s.",
|
||||
path, g_strerror(errno));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ret = read_filters_file(f, user_data);
|
||||
ret = read_filters_file(f, user_data, err_msg, init_func, add_cb);
|
||||
fclose(f);
|
||||
return ret;
|
||||
}
|
||||
|
@ -757,7 +785,7 @@ write_filters_file(const GSList *cfl, FILE *f, gboolean only_selected)
|
|||
|
||||
/* save filters in users filter file */
|
||||
gboolean
|
||||
color_filters_write(GSList *cfl)
|
||||
color_filters_write(GSList *cfl, gchar** err_msg)
|
||||
{
|
||||
gchar *pf_dir_path;
|
||||
gchar *path;
|
||||
|
@ -766,8 +794,7 @@ color_filters_write(GSList *cfl)
|
|||
/* Create the directory that holds personal configuration files,
|
||||
if necessary. */
|
||||
if (create_persconffile_dir(&pf_dir_path) == -1) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Can't create directory\n\"%s\"\nfor color files: %s.",
|
||||
*err_msg = g_strdup_printf("Can't create directory\n\"%s\"\nfor color files: %s.",
|
||||
pf_dir_path, g_strerror(errno));
|
||||
g_free(pf_dir_path);
|
||||
return FALSE;
|
||||
|
@ -775,8 +802,7 @@ color_filters_write(GSList *cfl)
|
|||
|
||||
path = get_persconffile_path("colorfilters", TRUE);
|
||||
if ((f = ws_fopen(path, "w+")) == NULL) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Could not open\n%s\nfor writing: %s.",
|
||||
*err_msg = g_strdup_printf("Could not open\n%s\nfor writing: %s.",
|
||||
path, g_strerror(errno));
|
||||
g_free(path);
|
||||
return FALSE;
|
||||
|
@ -789,13 +815,12 @@ color_filters_write(GSList *cfl)
|
|||
|
||||
/* save filters in some other filter file (export) */
|
||||
gboolean
|
||||
color_filters_export(const gchar *path, const GSList *cfl, gboolean only_marked)
|
||||
color_filters_export(const gchar *path, const GSList *cfl, gboolean only_marked, gchar** err_msg)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
if ((f = ws_fopen(path, "w+")) == NULL) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Could not open\n%s\nfor writing: %s.",
|
||||
*err_msg = g_strdup_printf("Could not open\n%s\nfor writing: %s.",
|
||||
path, g_strerror(errno));
|
||||
return FALSE;
|
||||
}
|
|
@ -22,12 +22,41 @@
|
|||
#ifndef __COLOR_FILTERS_H__
|
||||
#define __COLOR_FILTERS_H__
|
||||
|
||||
#include "ws_symbol_export.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
struct epan_dissect;
|
||||
|
||||
/*
|
||||
* Data structure holding RGB value for a color.
|
||||
*
|
||||
* XXX - yes, I know, there's a "pixel" value in there as well; for
|
||||
* now, it's intended to look just like a GdkColor but not to require
|
||||
* that any GTK+ header files be included in order to use it.
|
||||
* The way we handle colors needs to be cleaned up somewhat, in order
|
||||
* to keep toolkit-specific stuff separate from toolkit-independent stuff.
|
||||
*/
|
||||
typedef struct {
|
||||
guint32 pixel;
|
||||
guint16 red;
|
||||
guint16 green;
|
||||
guint16 blue;
|
||||
} color_t;
|
||||
|
||||
/** Initialize a color with R, G, and B values, including any toolkit-dependent
|
||||
** work that needs to be done.
|
||||
*
|
||||
* @param color the color_t to be filled
|
||||
* @param red the red value for the color
|
||||
* @param green the green value for the color
|
||||
* @param blue the blue value for the color
|
||||
* @return TRUE if it succeeds, FALSE if it fails
|
||||
*/
|
||||
typedef gboolean (*initialize_color_func)(color_t *color, guint16 red, guint16 green, guint16 blue);
|
||||
|
||||
#define CONVERSATION_COLOR_PREFIX "___conversation_color_filter___"
|
||||
/** @file
|
||||
* Color filters.
|
||||
|
@ -49,34 +78,34 @@ typedef struct _color_filter {
|
|||
void *color_edit_dlg_info; /* if filter is being edited, ptr to req'd info. GTK+ only. */
|
||||
} color_filter_t;
|
||||
|
||||
/** A color filter was added (while importing).
|
||||
* (color_filters.c calls this for every filter coming in)
|
||||
*
|
||||
* @param colorf the new color filter
|
||||
* @param user_data from caller
|
||||
*/
|
||||
typedef void (*color_filter_add_cb_func)(color_filter_t *colorf, gpointer user_data);
|
||||
|
||||
/** Init the color filters (incl. initial read from file). */
|
||||
void color_filters_init(void);
|
||||
WS_DLL_PUBLIC gboolean color_filters_init(gchar** err_msg, initialize_color_func init_func, color_filter_add_cb_func add_cb);
|
||||
|
||||
/** Reload the color filters */
|
||||
void color_filters_reload(void);
|
||||
WS_DLL_PUBLIC gboolean color_filters_reload(gchar** err_msg, initialize_color_func init_func, color_filter_add_cb_func add_cb);
|
||||
|
||||
/** Cleanup remaining color filter zombies */
|
||||
void color_filters_cleanup(void);
|
||||
WS_DLL_PUBLIC void color_filters_cleanup(void);
|
||||
|
||||
/** Color filters currently used?
|
||||
*
|
||||
* @return TRUE, if filters are used
|
||||
*/
|
||||
gboolean color_filters_used(void);
|
||||
WS_DLL_PUBLIC gboolean color_filters_used(void);
|
||||
|
||||
/** Are there any temporary coloring filters used?
|
||||
*
|
||||
* @return TRUE, if temporary coloring filters are used
|
||||
*/
|
||||
gboolean tmp_color_filters_used(void);
|
||||
|
||||
/** En-/disable color filters
|
||||
*
|
||||
* @param enable TRUE to enable (default)
|
||||
*/
|
||||
void
|
||||
color_filters_enable(gboolean enable);
|
||||
WS_DLL_PUBLIC gboolean tmp_color_filters_used(void);
|
||||
|
||||
/** Set the filter string of a temporary color filter
|
||||
*
|
||||
|
@ -84,43 +113,43 @@ color_filters_enable(gboolean enable);
|
|||
* @param filter the new filter-string
|
||||
* @param disabled whether the filter-rule should be disabled
|
||||
*/
|
||||
void
|
||||
color_filters_set_tmp(guint8 filt_nr, const gchar *filter, gboolean disabled);
|
||||
WS_DLL_PUBLIC gboolean
|
||||
color_filters_set_tmp(guint8 filt_nr, const gchar *filter, gboolean disabled, gchar **err_msg);
|
||||
|
||||
/** Get a temporary color filter.
|
||||
*
|
||||
* @param filter_num A number from 1 to 10 specifying the color to fetch.
|
||||
* @return The corresponding color or NULL.
|
||||
*/
|
||||
const color_filter_t *
|
||||
WS_DLL_PUBLIC const color_filter_t *
|
||||
color_filters_tmp_color(guint8 filter_num);
|
||||
|
||||
/** Reset the temporary color filters
|
||||
*
|
||||
*/
|
||||
void
|
||||
color_filters_reset_tmp(void);
|
||||
WS_DLL_PUBLIC gboolean
|
||||
color_filters_reset_tmp(gchar **err_msg);
|
||||
|
||||
/* Prime the epan_dissect_t with all the compiler
|
||||
* color filters of the current filter list.
|
||||
*
|
||||
* @param the epan dissector details
|
||||
*/
|
||||
void color_filters_prime_edt(struct epan_dissect *edt);
|
||||
WS_DLL_PUBLIC void color_filters_prime_edt(struct epan_dissect *edt);
|
||||
|
||||
/** Colorize a specific packet.
|
||||
*
|
||||
* @param edt the dissected packet
|
||||
* @return the matching color filter or NULL
|
||||
*/
|
||||
const color_filter_t *
|
||||
WS_DLL_PUBLIC const color_filter_t *
|
||||
color_filters_colorize_packet(struct epan_dissect *edt);
|
||||
|
||||
/** Clone the currently active filter list.
|
||||
*
|
||||
* @param user_data will be returned by each call to to color_filter_add_cb()
|
||||
*/
|
||||
void color_filters_clone(gpointer user_data);
|
||||
WS_DLL_PUBLIC void color_filters_clone(gpointer user_data, color_filter_add_cb_func add_cb);
|
||||
|
||||
/** Load filters (import) from some other filter file.
|
||||
*
|
||||
|
@ -128,23 +157,14 @@ void color_filters_clone(gpointer user_data);
|
|||
* @param user_data will be returned by each call to to color_filter_add_cb()
|
||||
* @return TRUE, if read succeeded
|
||||
*/
|
||||
gboolean color_filters_import(const gchar *path, const gpointer user_data);
|
||||
WS_DLL_PUBLIC gboolean color_filters_import(const gchar *path, const gpointer user_data, gchar** err_msg, initialize_color_func init_func, color_filter_add_cb_func add_cb);
|
||||
|
||||
/** Read filters from the global filter file (not the users file).
|
||||
*
|
||||
* @param user_data will be returned by each call to to color_filter_add_cb()
|
||||
* @return TRUE, if read succeeded
|
||||
*/
|
||||
gboolean color_filters_read_globals(gpointer user_data);
|
||||
|
||||
/** A color filter was added (while importing).
|
||||
* (color_filters.c calls this for every filter coming in)
|
||||
*
|
||||
* @param colorf the new color filter
|
||||
* @param user_data from caller
|
||||
*/
|
||||
void color_filter_add_cb (color_filter_t *colorf, gpointer user_data);
|
||||
|
||||
WS_DLL_PUBLIC gboolean color_filters_read_globals(gpointer user_data, gchar** err_msg, initialize_color_func init_func, color_filter_add_cb_func add_cb);
|
||||
|
||||
|
||||
/** Apply a changed filter list.
|
||||
|
@ -152,14 +172,14 @@ void color_filter_add_cb (color_filter_t *colorf, gpointer user_data);
|
|||
* @param tmp_cfl the temporary color filter list to apply
|
||||
* @param edit_cfl the edited permanent color filter list to apply
|
||||
*/
|
||||
void color_filters_apply(GSList *tmp_cfl, GSList *edit_cfl);
|
||||
WS_DLL_PUBLIC gboolean color_filters_apply(GSList *tmp_cfl, GSList *edit_cfl, gchar** err_msg);
|
||||
|
||||
/** Save filters in users filter file.
|
||||
*
|
||||
* @param cfl the filter list to write
|
||||
* @return TRUE if write succeeded
|
||||
*/
|
||||
gboolean color_filters_write(GSList *cfl);
|
||||
WS_DLL_PUBLIC gboolean color_filters_write(GSList *cfl, gchar** err_msg);
|
||||
|
||||
/** Save filters (export) to some other filter file.
|
||||
*
|
||||
|
@ -168,7 +188,7 @@ gboolean color_filters_write(GSList *cfl);
|
|||
* @param only_selected TRUE if only the selected filters should be saved
|
||||
* @return TRUE, if write succeeded
|
||||
*/
|
||||
gboolean color_filters_export(const gchar *path, const GSList *cfl, gboolean only_selected);
|
||||
WS_DLL_PUBLIC gboolean color_filters_export(const gchar *path, const GSList *cfl, gboolean only_selected, gchar** err_msg);
|
||||
|
||||
/** Create a new color filter (g_malloc'ed).
|
||||
*
|
||||
|
@ -179,7 +199,7 @@ gboolean color_filters_export(const gchar *path, const GSList *cfl, gboolean onl
|
|||
* @param disabled gboolean
|
||||
* @return the new color filter
|
||||
*/
|
||||
color_filter_t *color_filter_new(
|
||||
WS_DLL_PUBLIC color_filter_t *color_filter_new(
|
||||
const gchar *name, const gchar *filter_string,
|
||||
color_t *bg_color, color_t *fg_color, gboolean disabled);
|
||||
|
||||
|
@ -187,13 +207,13 @@ color_filter_t *color_filter_new(
|
|||
*
|
||||
* @param colorf the color filter to be removed
|
||||
*/
|
||||
void color_filter_delete(color_filter_t *colorf);
|
||||
WS_DLL_PUBLIC void color_filter_delete(color_filter_t *colorf);
|
||||
|
||||
/** Delete a filter list including all entries.
|
||||
*
|
||||
* @param cfl the filter list to delete
|
||||
*/
|
||||
void color_filter_list_delete(GSList **cfl);
|
||||
WS_DLL_PUBLIC void color_filter_list_delete(GSList **cfl);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
|
@ -39,8 +39,7 @@
|
|||
#include <wsutil/md5.h>
|
||||
#include <wsutil/str_util.h>
|
||||
|
||||
#include "color.h"
|
||||
#include "color_filters.h"
|
||||
#include <epan/color_filters.h>
|
||||
|
||||
#include "file-file.h"
|
||||
|
||||
|
|
|
@ -44,8 +44,7 @@
|
|||
#include "packet-frame.h"
|
||||
#include "log.h"
|
||||
|
||||
#include "color.h"
|
||||
#include "color_filters.h"
|
||||
#include <epan/color_filters.h>
|
||||
|
||||
void proto_register_frame(void);
|
||||
void proto_reg_handoff_frame(void);
|
||||
|
|
|
@ -29,7 +29,7 @@ extern "C" {
|
|||
|
||||
#include <glib.h>
|
||||
|
||||
#include "color.h"
|
||||
#include "color_filters.h"
|
||||
|
||||
#include <epan/params.h>
|
||||
#include <epan/range.h>
|
||||
|
|
3
file.c
3
file.c
|
@ -53,9 +53,8 @@
|
|||
#include <epan/dfilter/dfilter-macro.h>
|
||||
#include <epan/strutil.h>
|
||||
#include <epan/addr_resolv.h>
|
||||
#include <epan/color_filters.h>
|
||||
|
||||
#include "color.h"
|
||||
#include "color_filters.h"
|
||||
#include "cfile.h"
|
||||
#include "file.h"
|
||||
#include "fileset.h"
|
||||
|
|
|
@ -31,8 +31,7 @@
|
|||
#include <epan/prefs.h>
|
||||
|
||||
#include "globals.h"
|
||||
#include "color.h"
|
||||
#include "color_filters.h"
|
||||
#include <epan/color_filters.h>
|
||||
|
||||
#include <wsutil/file_util.h>
|
||||
|
||||
|
@ -40,6 +39,7 @@
|
|||
|
||||
#include "ui/util.h"
|
||||
#include "ui/alert_box.h"
|
||||
#include "ui/simple_dialog.h"
|
||||
#include "ui/file_dialog.h"
|
||||
#include "ui/recent.h"
|
||||
#include "ui/ui_util.h"
|
||||
|
@ -2245,7 +2245,7 @@ file_color_import_cmd_cb(GtkWidget *color_filters, gpointer filter_list _U_)
|
|||
win32_import_color_file(GDK_WINDOW_HWND(gtk_widget_get_window(top_level)), color_filters);
|
||||
#else /* USE_WIN32_FILE_DIALOGS */
|
||||
GtkWidget *main_vb, *cfglobal_but;
|
||||
gchar *cf_name, *s;
|
||||
gchar *cf_name, *s, *err_msg = NULL;
|
||||
|
||||
/* No Apply button, and "OK" just sets our text widget, it doesn't
|
||||
activate it (i.e., it doesn't cause us to try to open the file). */
|
||||
|
@ -2277,11 +2277,13 @@ file_color_import_cmd_cb(GtkWidget *color_filters, gpointer filter_list _U_)
|
|||
}
|
||||
|
||||
/* Try to open the color filter file. */
|
||||
if (!color_filters_import(cf_name, color_filters)) {
|
||||
if (!color_filters_import(cf_name, color_filters, &err_msg, initialize_color, color_filter_add_cb)) {
|
||||
/* We couldn't open it; don't dismiss the open dialog box,
|
||||
just leave it around so that the user can, after they
|
||||
dismiss the alert box popped up for the open error,
|
||||
try again. */
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
||||
g_free(err_msg);
|
||||
g_free(cf_name);
|
||||
continue;
|
||||
}
|
||||
|
@ -2341,6 +2343,7 @@ file_color_export_cmd_cb(GtkWidget *w _U_, gpointer filter_list)
|
|||
GtkWidget *cfselect_cb;
|
||||
gchar *cf_name;
|
||||
gchar *dirname;
|
||||
gchar *err_msg = NULL;
|
||||
|
||||
color_selected = FALSE;
|
||||
|
||||
|
@ -2390,10 +2393,12 @@ file_color_export_cmd_cb(GtkWidget *w _U_, gpointer filter_list)
|
|||
|
||||
/* Write out the filters (all, or only the ones that are currently
|
||||
displayed or selected) to the file with the specified name. */
|
||||
if (!color_filters_export(cf_name, (GSList *)filter_list, color_selected)) {
|
||||
if (!color_filters_export(cf_name, (GSList *)filter_list, color_selected, &err_msg)) {
|
||||
/* The write failed; don't dismiss the open dialog box,
|
||||
just leave it around so that the user can, after they
|
||||
dismiss the alert box popped up for the error, try again. */
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
||||
g_free(err_msg);
|
||||
g_free(cf_name);
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -28,8 +28,7 @@
|
|||
|
||||
#include <epan/packet.h>
|
||||
#include <epan/prefs.h>
|
||||
|
||||
#include "../color_filters.h"
|
||||
#include <epan/color_filters.h>
|
||||
|
||||
#include "simple_dialog.h"
|
||||
|
||||
|
@ -149,6 +148,17 @@ int color_selected_count(void)
|
|||
return count;
|
||||
}
|
||||
|
||||
|
||||
/* a new color filter was read in from a filter file */
|
||||
void
|
||||
color_filter_add_cb(color_filter_t *colorf, gpointer user_data)
|
||||
{
|
||||
GtkWidget *color_filters = (GtkWidget*)user_data;
|
||||
|
||||
add_filter_to_list(colorf, color_filters, FALSE);
|
||||
|
||||
gtk_widget_grab_focus(color_filters);
|
||||
}
|
||||
/* Create the "Coloring Rules" dialog. */
|
||||
static GtkWidget*
|
||||
colorize_dialog_new (char *filter)
|
||||
|
@ -406,7 +416,7 @@ colorize_dialog_new (char *filter)
|
|||
gtk_widget_grab_focus(color_filters);
|
||||
|
||||
/* prepare filter list content */
|
||||
color_filters_clone(color_filters);
|
||||
color_filters_clone(color_filters, color_filter_add_cb);
|
||||
g_object_set_data(G_OBJECT(color_win), COLOR_FILTER_LIST, &color_filter_edit_list);
|
||||
|
||||
gtk_widget_show_all(color_win);
|
||||
|
@ -734,18 +744,6 @@ add_filter_to_list(gpointer filter_arg, gpointer list_arg, gboolean prepend)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* a new color filter was read in from a filter file */
|
||||
void
|
||||
color_filter_add_cb(color_filter_t *colorf, gpointer user_data)
|
||||
{
|
||||
GtkWidget *color_filters = (GtkWidget*)user_data;
|
||||
|
||||
add_filter_to_list(colorf, color_filters, FALSE);
|
||||
|
||||
gtk_widget_grab_focus(color_filters);
|
||||
}
|
||||
|
||||
/* Create a new filter, add it to the list, and pop up an
|
||||
"Edit color filter" dialog box to edit it. */
|
||||
static void
|
||||
|
@ -955,6 +953,7 @@ static void
|
|||
color_clear_cmd(GtkWidget *widget)
|
||||
{
|
||||
GtkWidget * color_filters;
|
||||
gchar* err_msg = NULL;
|
||||
|
||||
color_filters = (GtkWidget *)g_object_get_data(G_OBJECT(widget), COLOR_FILTERS_CL);
|
||||
|
||||
|
@ -964,7 +963,11 @@ color_clear_cmd(GtkWidget *widget)
|
|||
}
|
||||
|
||||
/* try to read the global filters */
|
||||
color_filters_read_globals(color_filters);
|
||||
if (!color_filters_read_globals(color_filters, &err_msg, initialize_color, color_filter_add_cb))
|
||||
{
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
||||
g_free(err_msg);
|
||||
}
|
||||
}
|
||||
|
||||
/* User pressed "clear" button: ask user before really doing it */
|
||||
|
@ -1013,12 +1016,17 @@ color_clear_cb(GtkWidget *widget, gpointer data _U_) {
|
|||
static void
|
||||
overwrite_existing_colorfilters_cb(gpointer dialog _U_, gint btn, gpointer data _U_)
|
||||
{
|
||||
gchar* err_msg = NULL;
|
||||
|
||||
switch (btn) {
|
||||
case(ESD_BTN_SAVE):
|
||||
/* overwrite the file*/
|
||||
if (!color_filters_write(color_filter_edit_list))
|
||||
if (!color_filters_write(color_filter_edit_list, &err_msg))
|
||||
{
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Could not open colorfilter file: %s", g_strerror(errno));
|
||||
"Could not open colorfilter file: %s", err_msg);
|
||||
g_free(err_msg);
|
||||
}
|
||||
else
|
||||
prefs.unknown_colorfilters = FALSE;
|
||||
break;
|
||||
|
@ -1032,6 +1040,7 @@ overwrite_existing_colorfilters_cb(gpointer dialog _U_, gint btn, gpointer data
|
|||
static void
|
||||
colorfilters_main_save(void)
|
||||
{
|
||||
gchar* err_msg = NULL;
|
||||
if (prefs.unknown_colorfilters) {
|
||||
gpointer dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_SAVE_DONTSAVE,
|
||||
"Obsolete or unrecognized color filters have been detected. "
|
||||
|
@ -1041,8 +1050,9 @@ colorfilters_main_save(void)
|
|||
|
||||
simple_dialog_set_cb(dialog, overwrite_existing_colorfilters_cb, NULL);
|
||||
} else {
|
||||
if (!color_filters_write(color_filter_edit_list))
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Could not open filter file: %s", g_strerror(errno));
|
||||
if (!color_filters_write(color_filter_edit_list, &err_msg))
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Could not open filter file: %s", err_msg);
|
||||
g_free(err_msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1064,6 +1074,8 @@ color_ok_cb(GtkButton *button _U_, gpointer user_data _U_)
|
|||
static void
|
||||
color_apply_cb(GtkButton *button _U_, gpointer user_data _U_)
|
||||
{
|
||||
gchar* err_msg = NULL;
|
||||
|
||||
/* if we don't have a Save button, just save the settings now */
|
||||
if (!prefs.gui_use_pref_save)
|
||||
colorfilters_main_save();
|
||||
|
@ -1071,7 +1083,10 @@ color_apply_cb(GtkButton *button _U_, gpointer user_data _U_)
|
|||
/* Apply the coloring rules, both the temporary ones in
|
||||
* color_filter_tmp_list as the permanent ones in color_filter_edit_list
|
||||
* */
|
||||
color_filters_apply(color_filter_tmp_list, color_filter_edit_list);
|
||||
if (!color_filters_apply(color_filter_tmp_list, color_filter_edit_list, &err_msg)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
||||
g_free(err_msg);
|
||||
}
|
||||
|
||||
/* colorize list */
|
||||
packet_list_colorize_packets();
|
||||
|
|
|
@ -26,8 +26,7 @@
|
|||
|
||||
#include <epan/dfilter/dfilter.h>
|
||||
|
||||
#include "../color.h"
|
||||
#include "../color_filters.h"
|
||||
#include <epan/color_filters.h>
|
||||
|
||||
#include "ui/simple_dialog.h"
|
||||
|
||||
|
|
|
@ -26,17 +26,14 @@
|
|||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "../color.h"
|
||||
|
||||
|
||||
#include "ui/gtk/color_utils.h"
|
||||
#if 0
|
||||
static GdkColormap* sys_cmap;
|
||||
static GdkColormap* our_cmap = NULL;
|
||||
#endif
|
||||
GdkColor WHITE = { 0, 65535, 65535, 65535 };
|
||||
/*GdkColor LTGREY = { 0, 57343, 57343, 57343 };*/
|
||||
GdkColor BLACK = { 0, 0, 0, 0 };
|
||||
/* static GdkColor WHITE = { 0, 65535, 65535, 65535 }; */
|
||||
/*static GdkColor LTGREY = { 0, 57343, 57343, 57343 };*/
|
||||
/* static GdkColor BLACK = { 0, 0, 0, 0 }; */
|
||||
|
||||
/*
|
||||
* Initialize a color with R, G, and B values, including any toolkit-dependent
|
||||
|
|
|
@ -24,20 +24,12 @@
|
|||
#define __COLORS_H__
|
||||
|
||||
#include "ui/gtk/gui_utils.h"
|
||||
#include <epan/color_filters.h>
|
||||
|
||||
/** @file
|
||||
* Definitions for color structures and routines
|
||||
*/
|
||||
|
||||
/** The color white. */
|
||||
extern GdkColor WHITE;
|
||||
|
||||
/** The color light-grey. */
|
||||
extern GdkColor LTGREY;
|
||||
|
||||
/** The color black. */
|
||||
extern GdkColor BLACK;
|
||||
|
||||
/** Initialize the colors. */
|
||||
void colors_init(void);
|
||||
|
||||
|
|
|
@ -64,8 +64,7 @@
|
|||
#include "globals.h"
|
||||
|
||||
/* Color settings */
|
||||
#include "color.h"
|
||||
#include "color_filters.h"
|
||||
#include <epan/color_filters.h>
|
||||
#include "packet_list.h"
|
||||
|
||||
|
||||
|
@ -539,6 +538,7 @@ comparestat_draw(void *arg)
|
|||
frame_info *fInfo;
|
||||
guint32 first_file_amount, second_file_amount;
|
||||
char* addr_str;
|
||||
gchar *err_msg = NULL;
|
||||
|
||||
/* initial steps, clear all data before start*/
|
||||
cs->zebra_time.secs=0;
|
||||
|
@ -591,7 +591,10 @@ comparestat_draw(void *arg)
|
|||
g_string_printf(filter_str, "%s %s %s %s", "eth.dst==", addr_str, "|| eth.dst==", addr_str);
|
||||
wmem_free(NULL, addr_str);
|
||||
}
|
||||
color_filters_set_tmp(COLOR_N, filter_str->str, FALSE);
|
||||
if (!color_filters_set_tmp(COLOR_N, filter_str->str, FALSE, &err_msg)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
||||
g_free(err_msg);
|
||||
}
|
||||
packet_list_colorize_packets();
|
||||
/* Variance */
|
||||
cs->stats.variance=compare_variance;
|
||||
|
|
|
@ -44,7 +44,8 @@
|
|||
#include <epan/funnel.h>
|
||||
|
||||
#include "ui/progress_dlg.h"
|
||||
#include "../color_filters.h"
|
||||
#include "ui/simple_dialog.h"
|
||||
#include <epan/color_filters.h>
|
||||
|
||||
#include "ui/gtk/gui_utils.h"
|
||||
#include "ui/gtk/dlg_utils.h"
|
||||
|
@ -465,7 +466,11 @@ static void funnel_set_filter(funnel_ops_id_t *ops_id _U_, const char* filter_st
|
|||
}
|
||||
|
||||
static void funnel_set_color_filter_slot(guint8 filt_nr, const gchar* filter_string) {
|
||||
color_filters_set_tmp(filt_nr, (gchar *)filter_string, FALSE);
|
||||
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_) {
|
||||
|
|
|
@ -97,8 +97,7 @@
|
|||
#include "../file.h"
|
||||
#include "../frame_tvbuff.h"
|
||||
#include "../summary.h"
|
||||
#include "../color.h"
|
||||
#include "../color_filters.h"
|
||||
#include <epan/color_filters.h>
|
||||
#include "../register.h"
|
||||
#include "../ringbuffer.h"
|
||||
#include "../log.h"
|
||||
|
@ -355,6 +354,7 @@ void
|
|||
colorize_selected_ptree_cb(GtkWidget *w _U_, gpointer data _U_, guint8 filt_nr)
|
||||
{
|
||||
char *filter = NULL;
|
||||
gchar *err_msg = NULL;
|
||||
|
||||
if (cfile.finfo_selected) {
|
||||
filter = proto_construct_match_selected_string(cfile.finfo_selected,
|
||||
|
@ -370,9 +370,16 @@ colorize_selected_ptree_cb(GtkWidget *w _U_, gpointer data _U_, guint8 filt_nr)
|
|||
color_display_with_filter(filter);
|
||||
} else {
|
||||
if (filt_nr==255) {
|
||||
color_filters_reset_tmp();
|
||||
if (!color_filters_reset_tmp(&err_msg)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
||||
g_free(err_msg);
|
||||
}
|
||||
} else {
|
||||
color_filters_set_tmp(filt_nr,filter, FALSE);
|
||||
if (!color_filters_set_tmp(filt_nr,filter, FALSE, &err_msg)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
||||
g_free(err_msg);
|
||||
}
|
||||
|
||||
}
|
||||
packet_list_colorize_packets();
|
||||
}
|
||||
|
@ -1351,7 +1358,7 @@ main_colorize_changed(gboolean packet_list_colorize)
|
|||
/* change colorization */
|
||||
if(packet_list_colorize != recent.packet_list_colorize) {
|
||||
recent.packet_list_colorize = packet_list_colorize;
|
||||
color_filters_enable(packet_list_colorize);
|
||||
packet_list_enable_color(packet_list_colorize);
|
||||
packet_list_colorize_packets();
|
||||
}
|
||||
}
|
||||
|
@ -2215,7 +2222,7 @@ main(int argc, char *argv[])
|
|||
gint pl_size = 280, tv_size = 95, bv_size = 75;
|
||||
gchar *rc_file, *cf_name = NULL, *rfilter = NULL, *dfilter = NULL, *jfilter = NULL;
|
||||
dfilter_t *rfcode = NULL;
|
||||
gchar *err_msg;
|
||||
gchar *err_msg = NULL;
|
||||
gboolean rfilter_parse_failed = FALSE;
|
||||
e_prefs *prefs_p;
|
||||
char badopt;
|
||||
|
@ -3135,7 +3142,7 @@ main(int argc, char *argv[])
|
|||
g_free(rf_path);
|
||||
}
|
||||
|
||||
color_filters_enable(recent.packet_list_colorize);
|
||||
packet_list_enable_color(recent.packet_list_colorize);
|
||||
|
||||
/* rearrange all the widgets as we now have all recent settings ready for this */
|
||||
main_widgets_rearrange();
|
||||
|
@ -3173,7 +3180,10 @@ main(int argc, char *argv[])
|
|||
|
||||
dnd_init(top_level);
|
||||
|
||||
color_filters_init();
|
||||
if (!color_filters_init(&err_msg, initialize_color, color_filter_add_cb)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
||||
g_free(err_msg);
|
||||
}
|
||||
#ifdef HAVE_LIBPCAP
|
||||
capture_filter_init();
|
||||
#endif
|
||||
|
@ -3886,6 +3896,7 @@ void change_configuration_profile (const gchar *profile_name)
|
|||
char *gdp_path, *dp_path;
|
||||
char *rf_path;
|
||||
int rf_open_errno;
|
||||
gchar* err_msg = NULL;
|
||||
|
||||
/* First check if profile exists */
|
||||
if (!profile_exists(profile_name, FALSE)) {
|
||||
|
@ -3933,7 +3944,7 @@ void change_configuration_profile (const gchar *profile_name)
|
|||
}
|
||||
timestamp_set_type (recent.gui_time_format);
|
||||
timestamp_set_seconds_type (recent.gui_seconds_format);
|
||||
color_filters_enable(recent.packet_list_colorize);
|
||||
packet_list_enable_color(recent.packet_list_colorize);
|
||||
|
||||
prefs_to_capture_opts();
|
||||
prefs_apply_all();
|
||||
|
@ -3955,7 +3966,10 @@ void change_configuration_profile (const gchar *profile_name)
|
|||
}
|
||||
|
||||
/* Reload color filters */
|
||||
color_filters_reload();
|
||||
if (!color_filters_reload(&err_msg, initialize_color, color_filter_add_cb)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
||||
g_free(err_msg);
|
||||
}
|
||||
|
||||
/* Reload list of interfaces on welcome page */
|
||||
welcome_if_panel_reload();
|
||||
|
@ -3975,8 +3989,13 @@ void change_configuration_profile (const gchar *profile_name)
|
|||
void
|
||||
main_fields_changed (void)
|
||||
{
|
||||
gchar* err_msg = NULL;
|
||||
|
||||
/* Reload color filters */
|
||||
color_filters_reload();
|
||||
if (!color_filters_reload(&err_msg, initialize_color, color_filter_add_cb)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
||||
g_free(err_msg);
|
||||
}
|
||||
|
||||
/* Syntax check filter */
|
||||
filter_te_syntax_check_cb(main_display_filter_widget, NULL);
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include <epan/plugin_if.h>
|
||||
|
||||
#include "globals.h"
|
||||
#include "color_filters.h"
|
||||
#include <epan/color_filters.h>
|
||||
|
||||
#include "ui/main_statusbar.h"
|
||||
#include "ui/preference_utils.h"
|
||||
|
@ -193,9 +193,13 @@ colorize_conversation_cb(conversation_filter_t* color_filter, int action_num)
|
|||
{
|
||||
gchar *filter = NULL;
|
||||
packet_info *pi = &cfile.edt->pi;
|
||||
gchar *err_msg = NULL;
|
||||
|
||||
if (action_num == 255) {
|
||||
color_filters_reset_tmp();
|
||||
if (!color_filters_reset_tmp(&err_msg)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
||||
g_free(err_msg);
|
||||
}
|
||||
packet_list_colorize_packets();
|
||||
} else if (cfile.current_frame) {
|
||||
if (color_filter == NULL) {
|
||||
|
@ -239,7 +243,10 @@ colorize_conversation_cb(conversation_filter_t* color_filter, int action_num)
|
|||
color_display_with_filter(filter);
|
||||
} else {
|
||||
/* Set one of the temporary coloring filters */
|
||||
color_filters_set_tmp(action_num, filter, FALSE);
|
||||
if (!color_filters_set_tmp(action_num, filter, FALSE, &err_msg)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
||||
g_free(err_msg);
|
||||
}
|
||||
packet_list_colorize_packets();
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
#include "ui/gtk/packet_history.h"
|
||||
#include "ui/gtk/keys.h"
|
||||
#include "ui/gtk/menus.h"
|
||||
#include "color_filters.h"
|
||||
#include <epan/color_filters.h>
|
||||
#include "ui/gtk/color_utils.h"
|
||||
#include "ui/gtk/packet_win.h"
|
||||
#include "ui/gtk/main.h"
|
||||
|
|
|
@ -42,8 +42,7 @@
|
|||
#include <epan/epan_dissect.h>
|
||||
#include <epan/column.h>
|
||||
|
||||
#include "color.h"
|
||||
#include "color_filters.h"
|
||||
#include <epan/color_filters.h>
|
||||
#include "frame_tvbuff.h"
|
||||
|
||||
#include "globals.h"
|
||||
|
|
|
@ -191,7 +191,6 @@ SOURCES_WS_C = \
|
|||
../../capture_info.c \
|
||||
../../capture_opts.c \
|
||||
../../cfile.c \
|
||||
../../color_filters.c \
|
||||
../../extcap.c \
|
||||
../../extcap_parser.c \
|
||||
../../file.c \
|
||||
|
|
|
@ -23,28 +23,6 @@
|
|||
|
||||
#include "tango_colors.h"
|
||||
|
||||
/*
|
||||
* Initialize a color with R, G, and B values, including any toolkit-dependent
|
||||
* work that needs to be done.
|
||||
*/
|
||||
gboolean
|
||||
initialize_color(color_t *color, guint16 red, guint16 green, guint16 blue)
|
||||
{
|
||||
QColor qc;
|
||||
|
||||
// color_t uses 16-bit components to match Gtk+. Qt use 8.
|
||||
qc.setRgb(red>>8, green>>8, blue>>8);
|
||||
if (!qc.isValid())
|
||||
return FALSE;
|
||||
|
||||
// Match what color_filters.c does.
|
||||
color->red = red;
|
||||
color->green = green;
|
||||
color->blue = blue;
|
||||
color->pixel = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
const QColor ColorUtils::expert_color_comment = QColor ( 0xb7, 0xf7, 0x74 ); /* Green */
|
||||
const QColor ColorUtils::expert_color_chat = QColor ( 0x80, 0xb7, 0xf7 ); /* Light blue */
|
||||
const QColor ColorUtils::expert_color_note = QColor ( 0xa0, 0xff, 0xff ); /* Bright turquoise */
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include <glib.h>
|
||||
|
||||
#include "color.h"
|
||||
#include <epan/color_filters.h>
|
||||
|
||||
#include <QBrush>
|
||||
#include <QColor>
|
||||
|
@ -64,6 +64,8 @@ private:
|
|||
static const QList<QRgb> graph_colors_;
|
||||
};
|
||||
|
||||
void color_filter_qt_add_cb(color_filter_t *colorf, gpointer user_data);
|
||||
|
||||
#endif // COLOR_UTILS_H
|
||||
|
||||
/*
|
||||
|
|
|
@ -28,9 +28,10 @@
|
|||
#include "coloring_rules_dialog.h"
|
||||
#include <ui_coloring_rules_dialog.h>
|
||||
|
||||
#include "color.h"
|
||||
#include "color_filters.h"
|
||||
#include "epan/color_filters.h"
|
||||
|
||||
#include "ui/simple_dialog.h"
|
||||
#include "ui/simple_dialog.h"
|
||||
#include "epan/dfilter/dfilter.h"
|
||||
#include "epan/prefs.h"
|
||||
|
||||
|
@ -39,6 +40,7 @@
|
|||
#include "wsutil/filesystem.h"
|
||||
|
||||
#include "color_utils.h"
|
||||
#include "ui/ui_util.h"
|
||||
#include "display_filter_combo.h"
|
||||
#include "syntax_line_edit.h"
|
||||
#include "wireshark_application.h"
|
||||
|
@ -60,15 +62,6 @@
|
|||
// - Make the filter column narrower? It's easy to run into Qt's annoying
|
||||
// habit of horizontally scrolling QTreeWidgets here.
|
||||
|
||||
// Callback for color_filters_clone.
|
||||
void
|
||||
color_filter_add_cb(color_filter_t *colorf, gpointer user_data)
|
||||
{
|
||||
ColoringRulesDialog *coloring_rules_dialog = static_cast<ColoringRulesDialog*>(user_data);
|
||||
|
||||
if (!coloring_rules_dialog) return;
|
||||
coloring_rules_dialog->addColor(colorf);
|
||||
}
|
||||
|
||||
enum {
|
||||
name_col_ = 0,
|
||||
|
@ -93,7 +86,7 @@ ColoringRulesDialog::ColoringRulesDialog(QWidget *parent, QString add_filter) :
|
|||
ui->coloringRulesTreeWidget->setDropIndicatorShown(true);
|
||||
ui->coloringRulesTreeWidget->setDragDropMode(QAbstractItemView::InternalMove);
|
||||
|
||||
color_filters_clone(this);
|
||||
color_filters_clone(this, color_filter_add_cb);
|
||||
|
||||
for (int i = 0; i < ui->coloringRulesTreeWidget->columnCount(); i++) {
|
||||
ui->coloringRulesTreeWidget->setItemDelegateForColumn(i, &coloring_rules_tree_delegate_);
|
||||
|
@ -330,7 +323,11 @@ void ColoringRulesDialog::on_buttonBox_clicked(QAbstractButton *button)
|
|||
if (button == import_button_) {
|
||||
QString file_name = QFileDialog::getOpenFileName(this, wsApp->windowTitleString(tr("Import Coloring Rules")),
|
||||
wsApp->lastOpenDir().path());
|
||||
color_filters_import(file_name.toUtf8().constData(), this);
|
||||
gchar* err_msg = NULL;
|
||||
if (!color_filters_import(file_name.toUtf8().constData(), this, &err_msg, initialize_color, color_filter_add_cb)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
||||
g_free(err_msg);
|
||||
}
|
||||
} else if (button == export_button_) {
|
||||
int num_items = ui->coloringRulesTreeWidget->selectedItems().count();
|
||||
|
||||
|
@ -345,7 +342,11 @@ void ColoringRulesDialog::on_buttonBox_clicked(QAbstractButton *button)
|
|||
wsApp->lastOpenDir().path());
|
||||
if (!file_name.isEmpty()) {
|
||||
GSList *cfl = createColorFilterList();
|
||||
color_filters_export(file_name.toUtf8().constData(), cfl, FALSE);
|
||||
gchar* err_msg = NULL;
|
||||
if (!color_filters_export(file_name.toUtf8().constData(), cfl, FALSE, &err_msg)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
||||
g_free(err_msg);
|
||||
}
|
||||
color_filter_list_delete(&cfl);
|
||||
}
|
||||
}
|
||||
|
@ -354,6 +355,7 @@ void ColoringRulesDialog::on_buttonBox_clicked(QAbstractButton *button)
|
|||
void ColoringRulesDialog::on_buttonBox_accepted()
|
||||
{
|
||||
GSList *cfl = createColorFilterList();
|
||||
gchar* err_msg = NULL;
|
||||
if (prefs.unknown_colorfilters) {
|
||||
QMessageBox mb;
|
||||
mb.setText(tr("Your coloring rules file contains unknown rules"));
|
||||
|
@ -365,9 +367,13 @@ void ColoringRulesDialog::on_buttonBox_accepted()
|
|||
int result = mb.exec();
|
||||
if (result != QMessageBox::Save) return;
|
||||
}
|
||||
color_filters_apply(conversation_colors_, cfl);
|
||||
if (!color_filters_write(cfl)) {
|
||||
QMessageBox::warning(this, tr("Unable to save coloring rules"), g_strerror(errno));
|
||||
if (!color_filters_apply(conversation_colors_, cfl, &err_msg)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
||||
g_free(err_msg);
|
||||
}
|
||||
if (!color_filters_write(cfl, &err_msg)) {
|
||||
QMessageBox::warning(this, tr("Unable to save coloring rules: %s"), g_strerror(errno));
|
||||
g_free(err_msg);
|
||||
}
|
||||
color_filter_list_delete(&cfl);
|
||||
}
|
||||
|
@ -430,6 +436,38 @@ void ColoringRulesTreeDelegate::ruleNameChanged(const QString name)
|
|||
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize a color with R, G, and B values, including any toolkit-dependent
|
||||
* work that needs to be done.
|
||||
*/
|
||||
gboolean
|
||||
initialize_color(color_t *color, guint16 red, guint16 green, guint16 blue)
|
||||
{
|
||||
QColor qc;
|
||||
|
||||
// color_t uses 16-bit components to match Gtk+. Qt use 8.
|
||||
qc.setRgb(red>>8, green>>8, blue>>8);
|
||||
if (!qc.isValid())
|
||||
return FALSE;
|
||||
|
||||
// Match what color_filters.c does.
|
||||
color->red = red;
|
||||
color->green = green;
|
||||
color->blue = blue;
|
||||
color->pixel = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Callback for color_filters_clone.
|
||||
void
|
||||
color_filter_add_cb(color_filter_t *colorf, gpointer user_data)
|
||||
{
|
||||
ColoringRulesDialog *coloring_rules_dialog = static_cast<ColoringRulesDialog*>(user_data);
|
||||
|
||||
if (!coloring_rules_dialog) return;
|
||||
coloring_rules_dialog->addColor(colorf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines
|
||||
*
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
|
||||
#include <glib.h>
|
||||
|
||||
#include "color.h"
|
||||
|
||||
#include <epan/column-info.h>
|
||||
#include <epan/column.h>
|
||||
#include <epan/prefs.h>
|
||||
|
|
|
@ -23,13 +23,13 @@
|
|||
|
||||
#include <glib.h>
|
||||
|
||||
#include "color.h"
|
||||
#include "color_filters.h"
|
||||
#include "epan/color_filters.h"
|
||||
#include "file.h"
|
||||
|
||||
#include "epan/funnel.h"
|
||||
|
||||
#include "ui/progress_dlg.h"
|
||||
#include "ui/simple_dialog.h"
|
||||
|
||||
#include "funnel_statistics.h"
|
||||
#include "funnel_string_dialog.h"
|
||||
|
@ -230,7 +230,11 @@ void funnel_statistics_set_filter(funnel_ops_id_t *ops_id, const char* filter_st
|
|||
}
|
||||
|
||||
void funnel_statistics_set_color_filter_slot(guint8 filter_num, const gchar* filter_string) {
|
||||
color_filters_set_tmp(filter_num, (gchar *)filter_string, FALSE);
|
||||
gchar *err_msg = NULL;
|
||||
if (!color_filters_set_tmp(filter_num, (gchar *)filter_string, FALSE, &err_msg)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
||||
g_free(err_msg);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean funnel_statistics_open_file(funnel_ops_id_t *ops_id, const char* fname, const char* filter, char**) {
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include "ui/capture.h"
|
||||
#endif
|
||||
|
||||
#include "color_filters.h"
|
||||
#include "epan/color_filters.h"
|
||||
|
||||
#include "wsutil/file_util.h"
|
||||
#include "wsutil/filesystem.h"
|
||||
|
@ -1397,7 +1397,11 @@ void MainWindow::checkDisplayFilter()
|
|||
|
||||
void MainWindow::fieldsChanged()
|
||||
{
|
||||
color_filters_reload();
|
||||
gchar *err_msg = NULL;
|
||||
if (!color_filters_reload(&err_msg, initialize_color, color_filter_add_cb)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
||||
g_free(err_msg);
|
||||
}
|
||||
tap_listeners_dfilter_recompile();
|
||||
|
||||
emit checkDisplayFilter();
|
||||
|
@ -2245,7 +2249,7 @@ void MainWindow::on_actionViewNormalSize_triggered()
|
|||
|
||||
void MainWindow::on_actionViewColorizePacketList_triggered(bool checked) {
|
||||
recent.packet_list_colorize = checked;
|
||||
color_filters_enable(checked);
|
||||
packet_list_enable_color(checked);
|
||||
packet_list_->packetListModel()->resetColorized();
|
||||
}
|
||||
|
||||
|
@ -2302,7 +2306,11 @@ void MainWindow::colorizeConversation(bool create_rule)
|
|||
packet_list_, SLOT(recolorPackets()));
|
||||
coloring_rules_dialog.exec();
|
||||
} else {
|
||||
color_filters_set_tmp(cc_num, filter, FALSE);
|
||||
gchar *err_msg = NULL;
|
||||
if (!color_filters_set_tmp(cc_num, filter, FALSE, &err_msg)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
||||
g_free(err_msg);
|
||||
}
|
||||
packet_list_->recolorPackets();
|
||||
}
|
||||
}
|
||||
|
@ -2322,7 +2330,11 @@ void MainWindow::colorizeWithFilter()
|
|||
|
||||
if (ok) {
|
||||
// Assume "Color X"
|
||||
color_filters_set_tmp(color_number, filter.toUtf8().constData(), FALSE);
|
||||
gchar *err_msg = NULL;
|
||||
if (color_filters_set_tmp(color_number, filter.toUtf8().constData(), FALSE, &err_msg)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
||||
g_free(err_msg);
|
||||
}
|
||||
packet_list_->recolorPackets();
|
||||
} else {
|
||||
// New coloring rule
|
||||
|
@ -2336,7 +2348,11 @@ void MainWindow::colorizeWithFilter()
|
|||
|
||||
void MainWindow::on_actionViewColorizeResetColorization_triggered()
|
||||
{
|
||||
color_filters_reset_tmp();
|
||||
gchar *err_msg = NULL;
|
||||
if (!color_filters_reset_tmp(&err_msg)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
||||
g_free(err_msg);
|
||||
}
|
||||
packet_list_->recolorPackets();
|
||||
setMenusForSelectedPacket();
|
||||
}
|
||||
|
|
|
@ -26,8 +26,6 @@
|
|||
|
||||
#include <glib.h>
|
||||
|
||||
#include "color.h"
|
||||
|
||||
#include <epan/prefs.h>
|
||||
#include <epan/prefs-int.h>
|
||||
|
||||
|
|
|
@ -47,8 +47,7 @@
|
|||
|
||||
#include "wsutil/str_util.h"
|
||||
|
||||
#include "color.h"
|
||||
#include "color_filters.h"
|
||||
#include <epan/color_filters.h>
|
||||
#include "frame_tvbuff.h"
|
||||
|
||||
#include "color_utils.h"
|
||||
|
|
|
@ -32,8 +32,7 @@
|
|||
#include "ui/packet_list_utils.h"
|
||||
#include "ui/recent.h"
|
||||
|
||||
#include "color.h"
|
||||
#include "color_filters.h"
|
||||
#include <epan/color_filters.h>
|
||||
#include "frame_tvbuff.h"
|
||||
|
||||
#include "color_utils.h"
|
||||
|
|
|
@ -28,8 +28,7 @@
|
|||
#include <epan/column.h>
|
||||
#include <epan/conversation.h>
|
||||
|
||||
#include "color.h"
|
||||
#include "color_filters.h"
|
||||
#include <epan/color_filters.h>
|
||||
#include "frame_tvbuff.h"
|
||||
|
||||
#include <QStringList>
|
||||
|
|
|
@ -26,8 +26,6 @@
|
|||
|
||||
#include <glib.h>
|
||||
|
||||
#include "color.h"
|
||||
|
||||
#include <epan/prefs.h>
|
||||
|
||||
#include "wireshark_application.h"
|
||||
|
|
|
@ -48,8 +48,10 @@
|
|||
#include "ui/util.h"
|
||||
|
||||
#include "qt_ui_utils.h"
|
||||
#include "color_utils.h"
|
||||
#include "coloring_rules_dialog.h"
|
||||
|
||||
#include "color_filters.h"
|
||||
#include "epan/color_filters.h"
|
||||
#include "log.h"
|
||||
#include "recent_file_status.h"
|
||||
|
||||
|
@ -303,6 +305,7 @@ void WiresharkApplication::setConfigurationProfile(const gchar *profile_name)
|
|||
char *gdp_path, *dp_path;
|
||||
char *rf_path;
|
||||
int rf_open_errno;
|
||||
gchar *err_msg = NULL;
|
||||
|
||||
/* First check if profile exists */
|
||||
if (!profile_exists(profile_name, FALSE)) {
|
||||
|
@ -366,7 +369,7 @@ void WiresharkApplication::setConfigurationProfile(const gchar *profile_name)
|
|||
timestamp_set_type (recent.gui_time_format);
|
||||
timestamp_set_precision(recent.gui_time_precision);
|
||||
timestamp_set_seconds_type (recent.gui_seconds_format);
|
||||
color_filters_enable(recent.packet_list_colorize);
|
||||
packet_list_enable_color(recent.packet_list_colorize);
|
||||
tap_update_timer_.setInterval(prefs.tap_update_interval);
|
||||
|
||||
prefs_to_capture_opts();
|
||||
|
@ -391,7 +394,10 @@ void WiresharkApplication::setConfigurationProfile(const gchar *profile_name)
|
|||
}
|
||||
|
||||
/* Reload color filters */
|
||||
color_filters_reload();
|
||||
if (!color_filters_reload(&err_msg, initialize_color, color_filter_add_cb)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
||||
g_free(err_msg);
|
||||
}
|
||||
|
||||
emit localInterfaceListChanged();
|
||||
emit packetDissectionChanged();
|
||||
|
|
10
ui/ui_util.h
10
ui/ui_util.h
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include "epan/packet_info.h"
|
||||
#include "epan/column-utils.h"
|
||||
#include "epan/color_filters.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -82,6 +83,15 @@ gboolean packet_list_check_end(void); /* GTK+ only */
|
|||
gboolean packet_list_select_row_from_data(frame_data *fdata_needle);
|
||||
void packet_list_resize_column(gint col);
|
||||
|
||||
/* XXX - Yes this isn't the best place, but they are used by file_dlg_win32.c, which is supposed
|
||||
to be GUI independent, but has lots of GTK leanings. But if you put these in a GTK UI
|
||||
header file, file_dlg_win32.c complains about all of the GTK structures also in the header
|
||||
files
|
||||
Function names make it clear where they are coming from
|
||||
*/
|
||||
gboolean initialize_color(color_t *color, guint16 red, guint16 green, guint16 blue);
|
||||
void color_filter_add_cb(color_filter_t *colorf, gpointer user_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "epan/addr_resolv.h"
|
||||
#include "epan/prefs.h"
|
||||
|
||||
#include "color_filters.h"
|
||||
#include "epan/color_filters.h"
|
||||
|
||||
#include "ui/alert_box.h"
|
||||
#include "ui/help_url.h"
|
||||
|
@ -49,6 +49,7 @@
|
|||
#include "ui/simple_dialog.h"
|
||||
#include "ui/ssl_key_export.h"
|
||||
#include "ui/util.h"
|
||||
#include "ui/ui_util.h"
|
||||
|
||||
#include "file_dlg_win32.h"
|
||||
|
||||
|
@ -898,6 +899,7 @@ win32_export_color_file(HWND h_wnd, capture_file *cf, gpointer filter_list) {
|
|||
TCHAR file_name[MAX_PATH] = _T("");
|
||||
gchar *dirname;
|
||||
int ofnsize;
|
||||
gchar *err_msg = NULL;
|
||||
|
||||
ofnsize = win32_get_ofnsize();
|
||||
ofn = g_malloc0(ofnsize);
|
||||
|
@ -927,8 +929,12 @@ win32_export_color_file(HWND h_wnd, capture_file *cf, gpointer filter_list) {
|
|||
/* XXX - Support marked filters */
|
||||
if (GetSaveFileName(ofn)) {
|
||||
g_free( (void *) ofn);
|
||||
if (!color_filters_export(utf_16to8(file_name), filter_list, FALSE /* all filters */))
|
||||
if (!color_filters_export(utf_16to8(file_name), filter_list, FALSE /* all filters */, &err_msg))
|
||||
{
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
||||
g_free(err_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Save the directory name for future file dialogs. */
|
||||
dirname = get_dirname(utf_16to8(file_name)); /* Overwrites cf_name */
|
||||
|
@ -944,6 +950,7 @@ win32_import_color_file(HWND h_wnd, gpointer color_filters) {
|
|||
TCHAR file_name[MAX_PATH] = _T("");
|
||||
gchar *dirname;
|
||||
int ofnsize;
|
||||
gchar *err_msg = NULL;
|
||||
|
||||
ofnsize = win32_get_ofnsize();
|
||||
ofn = g_malloc0(ofnsize);
|
||||
|
@ -971,8 +978,11 @@ win32_import_color_file(HWND h_wnd, gpointer color_filters) {
|
|||
/* XXX - Support export limited to selected filters */
|
||||
if (GetOpenFileName(ofn)) {
|
||||
g_free( (void *) ofn);
|
||||
if (!color_filters_import(utf_16to8(file_name), color_filters))
|
||||
if (!color_filters_import(utf_16to8(file_name), color_filters, &err_msg, initialize_color, color_filter_add_cb)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
||||
g_free(err_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Save the directory name for future file dialogs. */
|
||||
dirname = get_dirname(utf_16to8(file_name)); /* Overwrites cf_name */
|
||||
|
|
|
@ -72,8 +72,7 @@
|
|||
|
||||
/* general (not Qt specific) */
|
||||
#include "file.h"
|
||||
#include "color.h"
|
||||
#include "color_filters.h"
|
||||
#include "epan/color_filters.h"
|
||||
#include "log.h"
|
||||
|
||||
#include "epan/rtd_table.h"
|
||||
|
@ -89,6 +88,8 @@
|
|||
#include "ui/util.h"
|
||||
|
||||
#include "ui/qt/conversation_dialog.h"
|
||||
#include "ui/qt/color_utils.h"
|
||||
#include "ui/qt/coloring_rules_dialog.h"
|
||||
#include "ui/qt/endpoint_dialog.h"
|
||||
#include "ui/qt/main_window.h"
|
||||
#include "ui/qt/response_time_delay_dialog.h"
|
||||
|
@ -1341,16 +1342,20 @@ int main(int argc, char *argv[])
|
|||
g_free(rf_path);
|
||||
}
|
||||
|
||||
color_filters_enable(recent.packet_list_colorize);
|
||||
packet_list_enable_color(recent.packet_list_colorize);
|
||||
|
||||
g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: fetch recent color settings");
|
||||
color_filters_enable(TRUE);
|
||||
packet_list_enable_color(TRUE);
|
||||
|
||||
////////
|
||||
|
||||
|
||||
////////
|
||||
color_filters_init();
|
||||
gchar* err_msg = NULL;
|
||||
if (!color_filters_init(&err_msg, initialize_color, color_filter_add_cb)) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
|
||||
g_free(err_msg);
|
||||
}
|
||||
|
||||
////////
|
||||
|
||||
|
|
Loading…
Reference in New Issue