2006-08-16 18:01:25 +00:00
/* airpcap_dlg.c
*
* $ Id $
*
2006-08-21 19:22:33 +00:00
* Giorgio Tino < giorgio . tino @ cacetech . com >
* Copyright ( c ) CACE Technologies , LLC 2006
2006-08-16 18:01:25 +00:00
*
* Wireshark - Network traffic analyzer
* By Gerald Combs < gerald @ wireshark . org >
* Copyright 2000 Gerald Combs
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
* of the License , or ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
2012-06-28 22:56:06 +00:00
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 USA .
2006-08-16 18:01:25 +00:00
*/
2012-09-20 01:48:30 +00:00
# include "config.h"
2006-08-16 18:01:25 +00:00
# ifdef HAVE_AIRPCAP
# include <gtk/gtk.h>
# include <string.h>
2013-11-17 02:55:14 +00:00
# include <wsutil/filesystem.h>
2007-12-04 08:33:20 +00:00
# include <epan/emem.h>
2006-10-19 00:48:03 +00:00
# include <epan/prefs.h>
2007-08-17 19:34:14 +00:00
# include <epan/frequency-utils.h>
2007-05-18 21:06:20 +00:00
# include <epan/crypt/wep-wpadefs.h>
2006-08-16 18:01:25 +00:00
2006-10-02 23:44:10 +00:00
# include <pcap.h>
2012-01-16 01:07:52 +00:00
# include "ui/simple_dialog.h"
2006-08-16 18:01:25 +00:00
2012-01-15 21:59:11 +00:00
# include "ui/gtk/main.h"
# include "ui/gtk/dlg_utils.h"
# include "ui/gtk/gui_utils.h"
# include "ui/gtk/dfilter_expr_dlg.h"
# include "ui/gtk/stock_icons.h"
# include "ui/gtk/gtkglobals.h"
# include "ui/gtk/help_dlg.h"
# include "ui/gtk/keys.h"
# include "ui/gtk/old-gtk-compat.h"
2013-03-24 16:47:38 +00:00
# include "ui/gtk/packet_win.h"
2006-10-19 00:48:03 +00:00
2006-08-16 18:01:25 +00:00
# include <airpcap.h>
# include "airpcap_loader.h"
# include "airpcap_gui_utils.h"
# include "airpcap_dlg.h"
2006-10-19 00:48:03 +00:00
/*
* Callback for the select row event in the key list widget
*/
2011-02-07 20:24:42 +00:00
static void
on_key_list_select_row ( GtkTreeSelection * selection , gpointer data )
2006-10-19 00:48:03 +00:00
{
2011-02-07 20:24:42 +00:00
GtkWidget * add_new_key_bt , * edit_key_bt , * remove_key_bt ;
GtkWidget * move_key_up_bt , * move_key_down_bt ;
GtkTreeIter iter ;
GtkTreeModel * model ;
GtkTreePath * path , * path_up , * path_down ;
2013-03-21 02:29:09 +00:00
add_new_key_bt = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( data ) , AIRPCAP_KEY_MGMT_NEW_KEY ) ;
edit_key_bt = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( data ) , AIRPCAP_KEY_MGMT_EDIT_KEY ) ;
remove_key_bt = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( data ) , AIRPCAP_KEY_MGMT_DELETE_KEY ) ;
move_key_up_bt = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( data ) , AIRPCAP_KEY_MGMT_UP_KEY ) ;
move_key_down_bt = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( data ) , AIRPCAP_KEY_MGMT_DOWN_KEY ) ;
2011-02-07 20:24:42 +00:00
if ( gtk_tree_selection_get_selected ( selection , & model , & iter ) ) {
path = gtk_tree_model_get_path ( model , & iter ) ;
path_up = gtk_tree_path_copy ( path ) ;
path_down = gtk_tree_path_copy ( path ) ;
gtk_tree_path_next ( path_down ) ;
2011-05-15 02:45:18 +00:00
2011-02-07 20:24:42 +00:00
if ( gtk_tree_model_iter_n_children ( model , NULL ) > = MAX_ENCRYPTION_KEYS ) {
gtk_widget_set_sensitive ( add_new_key_bt , FALSE ) ;
} else {
gtk_widget_set_sensitive ( add_new_key_bt , TRUE ) ;
}
2006-10-19 00:48:03 +00:00
2011-02-07 20:24:42 +00:00
gtk_widget_set_sensitive ( edit_key_bt , TRUE ) ;
gtk_widget_set_sensitive ( remove_key_bt , TRUE ) ;
2006-10-19 00:48:03 +00:00
2011-02-07 20:24:42 +00:00
/* ...and we have to use two different methods to figure out first/last because? */
if ( gtk_tree_path_prev ( path_up ) ) {
gtk_widget_set_sensitive ( move_key_up_bt , TRUE ) ;
} else {
gtk_widget_set_sensitive ( move_key_up_bt , FALSE ) ;
}
2006-12-05 19:24:25 +00:00
2011-02-07 20:24:42 +00:00
if ( gtk_tree_model_get_iter ( model , & iter , path_down ) ) {
gtk_widget_set_sensitive ( move_key_down_bt , TRUE ) ;
} else {
gtk_widget_set_sensitive ( move_key_down_bt , FALSE ) ;
}
2006-10-19 00:48:03 +00:00
2011-02-07 20:24:42 +00:00
gtk_tree_path_free ( path ) ;
gtk_tree_path_free ( path_up ) ;
gtk_tree_path_free ( path_down ) ;
} else {
gtk_widget_set_sensitive ( add_new_key_bt , FALSE ) ;
gtk_widget_set_sensitive ( edit_key_bt , FALSE ) ;
gtk_widget_set_sensitive ( remove_key_bt , FALSE ) ;
gtk_widget_set_sensitive ( move_key_up_bt , FALSE ) ;
gtk_widget_set_sensitive ( move_key_down_bt , FALSE ) ;
}
2006-10-19 00:48:03 +00:00
}
/*
2011-02-07 20:24:42 +00:00
* Callback for the select row event in the key list widget
2006-10-19 00:48:03 +00:00
*/
2011-02-07 20:24:42 +00:00
static void
on_key_list_reorder ( GtkTreeModel * model _U_ , GtkTreePath * path _U_ , GtkTreeIter * iter _U_ , gpointer no _U_ , gpointer data ) {
GtkTreeSelection * selection ;
2011-05-15 02:45:18 +00:00
2013-03-21 02:29:09 +00:00
selection = ( GtkTreeSelection * ) g_object_get_data ( G_OBJECT ( data ) , AIRPCAP_ADVANCED_EDIT_KEY_SELECTION_KEY ) ;
2011-02-07 20:24:42 +00:00
on_key_list_select_row ( selection , data ) ;
2006-10-19 00:48:03 +00:00
}
2006-08-16 18:01:25 +00:00
/*
2008-10-15 23:17:40 +00:00
* Callback for the crc checkbox
2006-08-16 18:01:25 +00:00
*/
static void
2009-05-13 17:13:03 +00:00
on_fcs_ck_toggled ( GtkWidget * w _U_ , gpointer user_data _U_ )
2007-01-26 06:34:05 +00:00
2006-08-16 18:01:25 +00:00
{
2008-10-17 23:48:33 +00:00
if ( airpcap_if_selected ! = NULL )
2007-01-26 06:34:05 +00:00
{
if ( airpcap_if_selected - > IsFcsPresent )
{
airpcap_if_selected - > IsFcsPresent = FALSE ;
airpcap_if_selected - > saved = FALSE ;
}
else
{
airpcap_if_selected - > IsFcsPresent = TRUE ;
airpcap_if_selected - > saved = FALSE ;
}
}
2006-08-16 18:01:25 +00:00
}
/*
* Callback for the wrong crc combo
*/
static void
2009-05-13 16:14:28 +00:00
on_edit_type_cb_changed ( GtkWidget * w , gpointer data )
2006-10-19 00:48:03 +00:00
{
2007-01-26 06:34:05 +00:00
GtkWidget * edit_key_w ;
GtkWidget * edit_ssid_te ;
2009-05-13 16:14:28 +00:00
GtkWidget * type_cb ;
2007-01-26 06:34:05 +00:00
GtkWidget * key_lb ;
GtkWidget * ssid_lb ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
gchar * type_text = NULL ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
edit_key_w = GTK_WIDGET ( data ) ;
2009-05-13 16:14:28 +00:00
type_cb = w ;
2006-10-19 00:48:03 +00:00
2013-03-21 02:29:09 +00:00
edit_ssid_te = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( edit_key_w ) , AIRPCAP_ADVANCED_EDIT_KEY_SSID_KEY ) ;
key_lb = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( edit_key_w ) , AIRPCAP_ADVANCED_EDIT_KEY_KEY_LABEL_KEY ) ;
ssid_lb = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( edit_key_w ) , AIRPCAP_ADVANCED_EDIT_KEY_SSID_LABEL_KEY ) ;
2006-10-19 00:48:03 +00:00
2011-07-24 15:22:21 +00:00
type_text = gtk_combo_box_text_get_active_text ( GTK_COMBO_BOX_TEXT ( type_cb ) ) ;
2006-10-19 00:48:03 +00:00
2011-02-07 20:24:42 +00:00
if ( g_ascii_strcasecmp ( type_text , " " ) )
2006-10-19 00:48:03 +00:00
{
2007-01-26 06:34:05 +00:00
/*
2008-10-15 23:17:40 +00:00
* If it is a WEP key , no SSID is required ! Gray out the entry text so
2007-01-26 06:34:05 +00:00
* it doesn ' t create confusion . . .
*/
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
if ( g_ascii_strcasecmp ( type_text , AIRPCAP_WEP_KEY_STRING ) = = 0 )
2006-10-19 00:48:03 +00:00
{
2007-01-26 06:34:05 +00:00
gtk_widget_set_sensitive ( edit_ssid_te , FALSE ) ;
/*
* Maybe the user has already entered some text into the SSID field
* and then switched to WEP . . .
*/
gtk_entry_set_text ( GTK_ENTRY ( edit_ssid_te ) , " " ) ;
gtk_label_set_text ( GTK_LABEL ( key_lb ) , " Key " ) ;
gtk_label_set_text ( GTK_LABEL ( ssid_lb ) , " " ) ;
2006-10-19 00:48:03 +00:00
}
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
else if ( g_ascii_strcasecmp ( type_text , AIRPCAP_WPA_BIN_KEY_STRING ) = = 0 )
2006-10-19 00:48:03 +00:00
{
2007-01-26 06:34:05 +00:00
gtk_widget_set_sensitive ( edit_ssid_te , FALSE ) ;
/*
* Maybe the user has already entered some text into the SSID field
2008-10-15 23:17:40 +00:00
* and then switched to WPA . . .
2007-01-26 06:34:05 +00:00
*/
gtk_entry_set_text ( GTK_ENTRY ( edit_ssid_te ) , " " ) ;
gtk_label_set_text ( GTK_LABEL ( key_lb ) , " Key " ) ;
gtk_label_set_text ( GTK_LABEL ( ssid_lb ) , " " ) ;
}
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
else if ( g_ascii_strcasecmp ( type_text , AIRPCAP_WPA_PWD_KEY_STRING ) = = 0 )
2007-01-26 06:34:05 +00:00
{
gtk_widget_set_sensitive ( edit_ssid_te , TRUE ) ;
/*
* Maybe the user has already entered some text into the SSID field
2008-10-15 23:17:40 +00:00
* and then switched to WPA . . .
2007-01-26 06:34:05 +00:00
*/
gtk_entry_set_text ( GTK_ENTRY ( edit_ssid_te ) , " " ) ;
gtk_label_set_text ( GTK_LABEL ( key_lb ) , " Passphrase " ) ;
gtk_label_set_text ( GTK_LABEL ( ssid_lb ) , " SSID " ) ;
2006-10-19 00:48:03 +00:00
}
}
2007-01-26 06:34:05 +00:00
gtk_widget_show ( edit_ssid_te ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
g_free ( type_text ) ;
2006-10-19 00:48:03 +00:00
}
/*
* Callback for the wrong crc combo
*/
static void
2009-05-13 16:14:28 +00:00
on_add_type_cb_changed ( GtkWidget * w , gpointer data )
2006-10-19 00:48:03 +00:00
{
2007-01-26 06:34:05 +00:00
GtkWidget * add_key_w ;
GtkWidget * add_ssid_te ;
2009-05-13 16:14:28 +00:00
GtkWidget * type_cb ;
2007-01-26 06:34:05 +00:00
GtkWidget * key_lb ;
GtkWidget * ssid_lb ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
gchar * type_text = NULL ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
add_key_w = GTK_WIDGET ( data ) ;
2009-05-13 16:14:28 +00:00
type_cb = w ;
2006-10-19 00:48:03 +00:00
2013-03-21 02:29:09 +00:00
add_ssid_te = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( add_key_w ) , AIRPCAP_ADVANCED_ADD_KEY_SSID_KEY ) ;
key_lb = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( add_key_w ) , AIRPCAP_ADVANCED_ADD_KEY_KEY_LABEL_KEY ) ;
ssid_lb = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( add_key_w ) , AIRPCAP_ADVANCED_ADD_KEY_SSID_LABEL_KEY ) ;
2006-10-19 00:48:03 +00:00
2011-07-24 15:22:21 +00:00
type_text = gtk_combo_box_text_get_active_text ( GTK_COMBO_BOX_TEXT ( type_cb ) ) ;
2006-10-19 00:48:03 +00:00
2011-02-07 20:24:42 +00:00
if ( g_ascii_strcasecmp ( type_text , " " ) )
2006-10-19 00:48:03 +00:00
{
2007-01-26 06:34:05 +00:00
/*
* If it is a WEP key , no SSID is required ! Gray out rhe entry text so
* it doesn ' t create confusion . . .
*/
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
if ( g_ascii_strcasecmp ( type_text , AIRPCAP_WEP_KEY_STRING ) = = 0 )
2006-10-19 00:48:03 +00:00
{
2007-01-26 06:34:05 +00:00
gtk_widget_set_sensitive ( add_ssid_te , FALSE ) ;
/*
* Maybe the user has already entered some text into the SSID field
* and then switched to WEP . . .
*/
gtk_entry_set_text ( GTK_ENTRY ( add_ssid_te ) , " " ) ;
gtk_label_set_text ( GTK_LABEL ( key_lb ) , " Key " ) ;
gtk_label_set_text ( GTK_LABEL ( ssid_lb ) , " " ) ;
2006-10-19 00:48:03 +00:00
}
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
else if ( g_ascii_strcasecmp ( type_text , AIRPCAP_WPA_BIN_KEY_STRING ) = = 0 )
2006-10-19 00:48:03 +00:00
{
2007-01-26 06:34:05 +00:00
gtk_widget_set_sensitive ( add_ssid_te , FALSE ) ;
/*
* Maybe the user has already entered some text into the SSID field
2008-10-15 23:17:40 +00:00
* and then switched to WPA . . .
2007-01-26 06:34:05 +00:00
*/
gtk_entry_set_text ( GTK_ENTRY ( add_ssid_te ) , " " ) ;
gtk_label_set_text ( GTK_LABEL ( key_lb ) , " Key " ) ;
gtk_label_set_text ( GTK_LABEL ( ssid_lb ) , " " ) ;
}
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
else if ( g_ascii_strcasecmp ( type_text , AIRPCAP_WPA_PWD_KEY_STRING ) = = 0 )
2007-01-26 06:34:05 +00:00
{
gtk_widget_set_sensitive ( add_ssid_te , TRUE ) ;
/*
* Maybe the user has already entered some text into the SSID field
2008-10-15 23:17:40 +00:00
* and then switched to WPA . . .
2007-01-26 06:34:05 +00:00
*/
gtk_entry_set_text ( GTK_ENTRY ( add_ssid_te ) , " " ) ;
gtk_label_set_text ( GTK_LABEL ( key_lb ) , " Passphrase " ) ;
gtk_label_set_text ( GTK_LABEL ( ssid_lb ) , " SSID " ) ;
2006-10-19 00:48:03 +00:00
}
}
2007-01-26 06:34:05 +00:00
gtk_widget_show ( add_ssid_te ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
g_free ( type_text ) ;
2006-10-19 00:48:03 +00:00
}
/*
* Callback for the wrong crc combo
*/
static void
2009-05-13 16:14:28 +00:00
on_fcs_filter_cb_changed ( GtkWidget * fcs_filter_cb , gpointer data _U_ )
2006-08-16 18:01:25 +00:00
{
2009-05-13 16:14:28 +00:00
gchar * fcs_filter_str ;
2007-01-26 06:34:05 +00:00
2009-05-13 16:14:28 +00:00
if ( fcs_filter_cb ! = NULL )
2007-01-26 06:34:05 +00:00
{
2011-07-24 15:22:21 +00:00
fcs_filter_str = gtk_combo_box_text_get_active_text ( GTK_COMBO_BOX_TEXT ( fcs_filter_cb ) ) ;
2009-05-13 16:14:28 +00:00
if ( fcs_filter_str & & ( g_ascii_strcasecmp ( " " , fcs_filter_str ) ) )
2007-01-26 06:34:05 +00:00
{
2009-05-13 16:14:28 +00:00
airpcap_if_selected - > CrcValidationOn = airpcap_get_validation_type ( fcs_filter_str ) ;
2007-01-26 06:34:05 +00:00
airpcap_if_selected - > saved = FALSE ;
}
2009-05-13 16:14:28 +00:00
g_free ( fcs_filter_str ) ;
2007-01-26 06:34:05 +00:00
}
2006-08-16 18:01:25 +00:00
}
/*
2007-05-18 21:06:20 +00:00
* Changed callback for the capture type combobox
2006-08-16 18:01:25 +00:00
*/
static void
2010-08-23 19:29:08 +00:00
on_capture_type_cb_changed ( GtkWidget * cb , gpointer user_data _U_ )
2006-08-16 18:01:25 +00:00
{
2009-05-13 16:14:28 +00:00
gchar * s ;
2006-08-16 18:01:25 +00:00
2010-11-28 00:00:58 +00:00
if ( cb = = NULL ) {
return ;
}
2011-05-15 02:45:18 +00:00
2011-07-24 15:22:21 +00:00
s = gtk_combo_box_text_get_active_text ( GTK_COMBO_BOX_TEXT ( cb ) ) ;
2006-08-16 18:01:25 +00:00
2010-11-28 00:00:58 +00:00
if ( ( g_ascii_strcasecmp ( " " , s ) ) )
{
airpcap_if_selected - > linkType = airpcap_get_link_type ( s ) ;
airpcap_if_selected - > saved = FALSE ;
}
2009-05-13 16:14:28 +00:00
g_free ( s ) ;
2006-08-16 18:01:25 +00:00
}
/*
* Thread function used to blink the led
*/
2011-02-07 20:24:42 +00:00
static gboolean
update_blink ( gpointer data )
2006-08-16 18:01:25 +00:00
{
2007-01-26 06:34:05 +00:00
airpcap_if_info_t * sel ;
PAirpcapHandle ad ;
gchar ebuf [ AIRPCAP_ERRBUF_SIZE ] ;
sel = ( airpcap_if_info_t * ) data ;
2007-05-18 21:06:20 +00:00
ad = airpcap_if_open ( sel - > name , ebuf ) ;
2007-01-26 06:34:05 +00:00
if ( ad )
{
if ( sel - > led )
{
airpcap_if_turn_led_off ( ad , 0 ) ;
sel - > led = FALSE ;
}
else
{
airpcap_if_turn_led_on ( ad , 0 ) ;
sel - > led = TRUE ;
}
airpcap_if_close ( ad ) ;
}
2008-07-08 02:25:30 +00:00
return TRUE ;
2006-08-16 18:01:25 +00:00
}
/*
* Blink button callback
*/
2011-02-07 20:24:42 +00:00
static void
2010-08-23 19:29:08 +00:00
on_blink_bt_clicked ( GtkWidget * blink_bt , gpointer data _U_ )
2006-08-16 18:01:25 +00:00
{
2007-01-26 06:34:05 +00:00
PAirpcapHandle ad = NULL ;
gchar ebuf [ AIRPCAP_ERRBUF_SIZE ] ;
2009-05-13 10:29:42 +00:00
if ( airpcap_if_selected ! = NULL ) {
2007-01-26 06:34:05 +00:00
if ( ! ( airpcap_if_selected - > blinking ) )
{
gtk_button_set_label ( GTK_BUTTON ( blink_bt ) , " Stop Blinking " ) ;
2008-07-08 02:25:30 +00:00
airpcap_if_selected - > tag = g_timeout_add ( 500 , update_blink , airpcap_if_selected ) ;
2007-01-26 06:34:05 +00:00
airpcap_if_selected - > blinking = TRUE ;
}
else
{
gtk_button_set_label ( GTK_BUTTON ( blink_bt ) , " Blink Led " ) ;
2008-07-08 02:25:30 +00:00
g_source_remove ( airpcap_if_selected - > tag ) ;
2007-01-26 06:34:05 +00:00
airpcap_if_selected - > blinking = FALSE ;
/* Switch on the led! */
ad = airpcap_if_open ( airpcap_if_selected - > name , ebuf ) ;
if ( ad )
{
2008-07-08 02:25:30 +00:00
g_source_remove ( airpcap_if_selected - > tag ) ;
2007-01-26 06:34:05 +00:00
airpcap_if_turn_led_on ( ad , 0 ) ;
airpcap_if_selected - > blinking = FALSE ;
airpcap_if_selected - > led = TRUE ;
airpcap_if_close ( ad ) ;
}
}
2009-05-13 16:14:28 +00:00
}
2006-08-16 18:01:25 +00:00
}
2006-10-19 00:48:03 +00:00
/*
* Callback for the ' Any ' adapter What ' s This button .
*/
2011-02-07 20:24:42 +00:00
static void
2010-08-23 19:29:08 +00:00
on_what_s_this_bt_clicked ( GtkWidget * blink_bt _U_ , gpointer data _U_ )
2006-10-19 00:48:03 +00:00
{
2007-01-26 06:34:05 +00:00
simple_dialog ( ESD_TYPE_INFO , ESD_BTN_OK ,
" The Multi-Channel Aggregator is a virtual device "
" that can be used to capture packets from all the "
" AirPcap adapters at the same time. \n "
" The Capture Type, FCS and Encryption settings of "
" this virtual device can be configured as for any "
" real adapter. \n The channel cannot be changed for "
" this adapter. \n "
" Refer to the AirPcap manual for more information. " ) ;
2006-10-19 00:48:03 +00:00
}
2006-08-16 18:01:25 +00:00
/* the window was closed, cleanup things */
2011-02-07 20:24:42 +00:00
static void
2010-08-23 19:29:08 +00:00
on_key_management_destroy ( GtkWidget * w _U_ , gpointer data )
2006-10-19 00:48:03 +00:00
{
2010-11-28 00:00:58 +00:00
GtkWidget * airpcap_advanced_w ,
* toolbar ;
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
gint * from_widget = NULL ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
/* Retrieve the GUI object pointers */
2010-11-28 00:00:58 +00:00
airpcap_advanced_w = GTK_WIDGET ( data ) ;
2006-08-16 18:01:25 +00:00
2010-11-28 00:00:58 +00:00
toolbar = GTK_WIDGET ( g_object_get_data ( G_OBJECT ( airpcap_advanced_w ) , AIRPCAP_TOOLBAR_KEY ) ) ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
/* ... */
2010-11-28 00:00:58 +00:00
from_widget = ( gint * ) g_object_get_data ( G_OBJECT ( toolbar ) , AIRPCAP_ADVANCED_FROM_KEY ) ;
2007-01-26 06:34:05 +00:00
/* gray out the toolbar (if we came here from the toolbar advanced button)*/
if ( * from_widget = = AIRPCAP_ADVANCED_FROM_TOOLBAR )
gtk_widget_set_sensitive ( toolbar , TRUE ) ;
else
gtk_widget_set_sensitive ( toolbar , FALSE ) ;
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
g_free ( from_widget ) ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
/* reload the configuration!!! Configuration has not been saved but
the corresponding structure has been modified probably . . . */
if ( airpcap_if_selected ! = NULL )
{
if ( ! airpcap_if_selected - > saved )
{
airpcap_load_selected_if_configuration ( airpcap_if_selected ) ;
}
}
2006-08-16 18:01:25 +00:00
2006-12-05 19:24:25 +00:00
}
2006-10-19 00:48:03 +00:00
/* the Advenced wireless Settings window was closed, cleanup things */
static void
2008-10-15 23:17:40 +00:00
on_airpcap_advanced_destroy ( GtkWidget * w _U_ , gpointer data )
2006-10-19 00:48:03 +00:00
{
2010-11-28 00:00:58 +00:00
GtkWidget * airpcap_advanced_w ,
* toolbar ;
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
gint * from_widget = NULL ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
/* Retrieve the GUI object pointers */
2010-11-28 00:00:58 +00:00
airpcap_advanced_w = GTK_WIDGET ( data ) ;
2006-10-19 00:48:03 +00:00
2010-11-28 00:00:58 +00:00
toolbar = GTK_WIDGET ( g_object_get_data ( G_OBJECT ( airpcap_advanced_w ) , AIRPCAP_TOOLBAR_KEY ) ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
/* ... */
2010-11-28 00:00:58 +00:00
from_widget = ( gint * ) g_object_get_data ( G_OBJECT ( toolbar ) , AIRPCAP_ADVANCED_FROM_KEY ) ;
2007-01-26 06:34:05 +00:00
/* gray out the toolbar (if we came here from the toolbar advanced button)*/
if ( * from_widget = = AIRPCAP_ADVANCED_FROM_TOOLBAR )
gtk_widget_set_sensitive ( toolbar , TRUE ) ;
else
gtk_widget_set_sensitive ( toolbar , FALSE ) ;
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
g_free ( from_widget ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
/* reload the configuration!!! Configuration has not been saved but
the corresponding structure has been modified probably . . . */
if ( ! airpcap_if_selected - > saved )
{
airpcap_load_selected_if_configuration ( airpcap_if_selected ) ;
}
2006-10-19 00:48:03 +00:00
}
2006-08-16 18:01:25 +00:00
2006-10-19 00:48:03 +00:00
/*
* Callback for the ' Apply ' button .
*/
2007-06-27 21:03:25 +00:00
/*
* XXX - Pressing ' Apply ' has the same effect as pressing ' OK ' - - you
* can ' t revert back to the old set of keys by pressing ' Cancel ' . We
* either need to fix reversion or get rid of the ' Apply ' button .
*/
2011-02-07 20:24:42 +00:00
static void
2007-06-27 21:03:25 +00:00
on_key_management_apply_bt_clicked ( GtkWidget * button _U_ , gpointer data )
2006-10-19 00:48:03 +00:00
{
2007-01-26 06:34:05 +00:00
/* advenced window */
2010-11-28 00:00:58 +00:00
GtkWidget * key_management_w ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
/* widgets in the toolbar */
2009-05-13 16:14:28 +00:00
GtkWidget * toolbar_cb ;
GtkWidget * decryption_mode_cb ;
2006-08-16 18:01:25 +00:00
2011-02-07 20:24:42 +00:00
GtkListStore * key_list_store ;
2007-06-27 21:03:25 +00:00
module_t * wlan_module = prefs_find_module ( " wlan " ) ;
2009-05-13 16:14:28 +00:00
gchar * decryption_mode_string ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
/* retrieve main window */
key_management_w = GTK_WIDGET ( data ) ;
2009-05-13 16:14:28 +00:00
decryption_mode_cb = GTK_WIDGET ( g_object_get_data ( G_OBJECT ( key_management_w ) , AIRPCAP_ADVANCED_DECRYPTION_MODE_KEY ) ) ;
2011-02-07 20:24:42 +00:00
key_list_store = GTK_LIST_STORE ( g_object_get_data ( G_OBJECT ( key_management_w ) , AIRPCAP_ADVANCED_KEYLIST_KEY ) ) ;
2009-05-13 16:14:28 +00:00
toolbar_cb = GTK_WIDGET ( g_object_get_data ( G_OBJECT ( key_management_w ) , AIRPCAP_TOOLBAR_DECRYPTION_KEY ) ) ;
2006-08-16 18:01:25 +00:00
2008-10-15 23:17:40 +00:00
# define CANT_SAVE_ERR_STR "Cannot save configuration! Another application " \
2008-07-21 18:51:05 +00:00
" might be using AirPcap, or you might not have sufficient privileges. "
2007-01-26 06:34:05 +00:00
/* Set the Decryption Mode */
2009-05-13 16:14:28 +00:00
2011-07-24 16:50:55 +00:00
decryption_mode_string = gtk_combo_box_text_get_active_text ( GTK_COMBO_BOX_TEXT ( decryption_mode_cb ) ) ;
2009-05-13 16:14:28 +00:00
if ( g_ascii_strcasecmp ( decryption_mode_string , AIRPCAP_DECRYPTION_TYPE_STRING_WIRESHARK ) = = 0 )
2006-10-19 00:48:03 +00:00
{
2007-01-26 06:34:05 +00:00
set_wireshark_decryption ( TRUE ) ;
2008-07-21 18:51:05 +00:00
if ( ! set_airpcap_decryption ( FALSE ) ) g_warning ( CANT_SAVE_ERR_STR ) ;
2006-10-19 00:48:03 +00:00
}
2009-05-13 16:14:28 +00:00
else if ( g_ascii_strcasecmp ( decryption_mode_string , AIRPCAP_DECRYPTION_TYPE_STRING_AIRPCAP ) = = 0 )
2006-10-19 00:48:03 +00:00
{
2007-01-26 06:34:05 +00:00
set_wireshark_decryption ( FALSE ) ;
2008-07-21 18:51:05 +00:00
if ( ! set_airpcap_decryption ( TRUE ) ) g_warning ( CANT_SAVE_ERR_STR ) ;
2006-10-19 00:48:03 +00:00
}
2009-05-13 16:14:28 +00:00
else if ( g_ascii_strcasecmp ( decryption_mode_string , AIRPCAP_DECRYPTION_TYPE_STRING_NONE ) = = 0 )
2006-10-19 00:48:03 +00:00
{
2007-01-26 06:34:05 +00:00
set_wireshark_decryption ( FALSE ) ;
2008-07-21 18:51:05 +00:00
if ( ! set_airpcap_decryption ( FALSE ) ) g_warning ( CANT_SAVE_ERR_STR ) ;
2006-10-19 00:48:03 +00:00
}
2010-11-28 00:00:58 +00:00
g_free ( decryption_mode_string ) ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
/* Save the configuration */
2011-02-07 20:24:42 +00:00
airpcap_read_and_save_decryption_keys_from_list_store ( key_list_store , airpcap_if_selected , airpcap_if_list ) ; /* This will save the keys for every adapter */
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
/* The update will make redissect al the packets... no need to do it here again */
2009-05-13 16:14:28 +00:00
update_decryption_mode ( toolbar_cb ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
/* Redissect all the packets, and re-evaluate the display filter. */
2007-06-27 21:03:25 +00:00
prefs_apply ( wlan_module ) ;
2006-08-16 18:01:25 +00:00
}
/*
* Callback used to add a WEP key in the add new key box ;
*/
static void
2010-08-23 19:29:08 +00:00
on_add_key_ok_bt_clicked ( GtkWidget * widget _U_ , gpointer data )
2006-08-16 18:01:25 +00:00
{
2010-11-28 00:00:58 +00:00
GtkWidget * type_cb ,
* key_en ,
* ssid_en ;
2006-12-05 19:24:25 +00:00
2011-02-07 20:24:42 +00:00
GtkListStore * key_list_store ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
GString * new_type_string ,
2010-11-28 00:00:58 +00:00
* new_key_string ,
* new_ssid_string ;
2006-08-16 18:01:25 +00:00
2010-11-28 00:00:58 +00:00
gchar * type_entered = NULL ;
gchar * key_entered = NULL ;
gchar * ssid_entered = NULL ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
unsigned int i ;
2006-08-16 18:01:25 +00:00
2013-03-21 02:29:09 +00:00
key_list_store = ( GtkListStore * ) g_object_get_data ( G_OBJECT ( data ) , AIRPCAP_ADVANCED_ADD_KEY_LIST_KEY ) ;
type_cb = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( data ) , AIRPCAP_ADVANCED_ADD_KEY_TYPE_KEY ) ;
key_en = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( data ) , AIRPCAP_ADVANCED_ADD_KEY_KEY_KEY ) ;
ssid_en = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( data ) , AIRPCAP_ADVANCED_ADD_KEY_SSID_KEY ) ;
2006-08-16 18:01:25 +00:00
2011-07-24 15:22:21 +00:00
type_entered = gtk_combo_box_text_get_active_text ( GTK_COMBO_BOX_TEXT ( type_cb ) ) ;
2007-01-26 06:34:05 +00:00
key_entered = g_strdup ( gtk_entry_get_text ( GTK_ENTRY ( key_en ) ) ) ;
ssid_entered = g_strdup ( gtk_entry_get_text ( GTK_ENTRY ( ssid_en ) ) ) ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
/* Check if key is correct */
new_type_string = g_string_new ( type_entered ) ;
new_key_string = g_string_new ( key_entered ) ;
new_ssid_string = g_string_new ( ssid_entered ) ;
2006-10-19 00:48:03 +00:00
2009-07-01 15:56:12 +00:00
g_free ( type_entered ) ;
g_free ( key_entered ) ;
g_free ( ssid_entered ) ;
2011-02-07 20:24:42 +00:00
g_strstrip ( new_key_string - > str ) ;
g_strstrip ( new_ssid_string - > str ) ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
/* Check which type of key the user has entered */
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
if ( g_ascii_strcasecmp ( new_type_string - > str , AIRPCAP_WEP_KEY_STRING ) = = 0 ) /* WEP key */
2007-01-26 06:34:05 +00:00
{
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
if ( ( ( new_key_string - > len ) > WEP_KEY_MAX_CHAR_SIZE ) | | ( ( new_key_string - > len ) < WEP_KEY_MIN_CHAR_SIZE ) )
{
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " WEP key size out of range! \n Valid key size range is %d-%d characters (%d-%d bits). " , WEP_KEY_MIN_CHAR_SIZE , WEP_KEY_MAX_CHAR_SIZE , WEP_KEY_MIN_BIT_SIZE , WEP_KEY_MAX_BIT_SIZE ) ;
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
g_string_free ( new_type_string , TRUE ) ;
g_string_free ( new_key_string , TRUE ) ;
g_string_free ( new_ssid_string , TRUE ) ;
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
return ;
}
2006-10-02 23:44:10 +00:00
2007-01-26 06:34:05 +00:00
if ( ( new_key_string - > len % 2 ) ! = 0 )
{
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " Invalid WEP key! \n The number of characters must be even. " ) ;
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
g_string_free ( new_type_string , TRUE ) ;
g_string_free ( new_key_string , TRUE ) ;
g_string_free ( new_ssid_string , TRUE ) ;
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
return ;
}
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
for ( i = 0 ; i < new_key_string - > len ; i + + )
{
if ( ! g_ascii_isxdigit ( new_key_string - > str [ i ] ) )
{
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " Invalid WEP key! \n A WEP key must be a hexadecimal number. \n The valid characters are: 0123456789ABCDEF. " ) ;
g_string_free ( new_type_string , TRUE ) ;
g_string_free ( new_key_string , TRUE ) ;
g_string_free ( new_ssid_string , TRUE ) ;
return ;
}
}
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
/* If so... add key */
2011-02-07 20:24:42 +00:00
airpcap_add_key_to_list ( key_list_store , new_type_string - > str , new_key_string - > str , new_ssid_string - > str ) ;
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
if ( airpcap_if_selected ! = NULL ) airpcap_if_selected - > saved = FALSE ;
}
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
else if ( g_ascii_strcasecmp ( new_type_string - > str , AIRPCAP_WPA_PWD_KEY_STRING ) = = 0 ) /* WPA Key */
2007-01-26 06:34:05 +00:00
{
/* XXX - Perform some WPA related input fields check */
2008-10-15 23:17:40 +00:00
/* If everything is ok, modify the entry in the list */
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
if ( ( ( new_key_string - > len ) > WPA_KEY_MAX_CHAR_SIZE ) | | ( ( new_key_string - > len ) < WPA_KEY_MIN_CHAR_SIZE ) )
{
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " WPA key size out of range! \n Valid key size range is %d-%d ASCII characters (%d-%d bits). " , WPA_KEY_MIN_CHAR_SIZE , WPA_KEY_MAX_CHAR_SIZE , WPA_KEY_MIN_BIT_SIZE , WPA_KEY_MAX_BIT_SIZE ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
g_string_free ( new_type_string , TRUE ) ;
g_string_free ( new_key_string , TRUE ) ;
g_string_free ( new_ssid_string , TRUE ) ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
return ;
}
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
/*
2008-10-15 23:17:40 +00:00
* XXX - Maybe we need some check on the characters ? I ' m not sure if only standard ASCII are ok . . .
2007-01-26 06:34:05 +00:00
*/
2009-05-13 17:13:03 +00:00
if ( ( new_ssid_string - > len ) > WPA_SSID_MAX_CHAR_SIZE )
2007-01-26 06:34:05 +00:00
{
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " SSID key size out of range! \n Valid SSID size range is %d-%d ASCII characters (%d-%d bits). " , WPA_SSID_MIN_CHAR_SIZE , WPA_SSID_MAX_CHAR_SIZE , WPA_SSID_MIN_BIT_SIZE , WPA_SSID_MAX_BIT_SIZE ) ;
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
g_string_free ( new_type_string , TRUE ) ;
g_string_free ( new_key_string , TRUE ) ;
g_string_free ( new_ssid_string , TRUE ) ;
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
return ;
}
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
/* If so... add key */
2011-02-07 20:24:42 +00:00
airpcap_add_key_to_list ( key_list_store , new_type_string - > str , new_key_string - > str , new_ssid_string - > str ) ;
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
if ( airpcap_if_selected ! = NULL ) airpcap_if_selected - > saved = FALSE ;
}
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
else if ( g_ascii_strcasecmp ( new_type_string - > str , AIRPCAP_WPA_BIN_KEY_STRING ) = = 0 ) /* WPA_BIN Key */
2007-01-26 06:34:05 +00:00
{
/* XXX - Perform some WPA_BIN related input fields check */
/* If everything is ok, modify the entry int he list */
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
if ( ( ( new_key_string - > len ) ! = WPA_PSK_KEY_CHAR_SIZE ) )
{
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " WPA PSK/PMK key size is wrong! \n Valid key size is %d characters (%d bits). " , WPA_PSK_KEY_CHAR_SIZE , WPA_PSK_KEY_BIT_SIZE ) ;
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
g_string_free ( new_type_string , TRUE ) ;
g_string_free ( new_key_string , TRUE ) ;
g_string_free ( new_ssid_string , TRUE ) ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
return ;
}
for ( i = 0 ; i < new_key_string - > len ; i + + )
{
if ( ! g_ascii_isxdigit ( new_key_string - > str [ i ] ) )
{
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " Invalid WPA PSK/PMK key! \n Key must be an hexadecimal number. \n The valid characters are: 0123456789ABCDEF. " ) ;
g_string_free ( new_type_string , TRUE ) ;
g_string_free ( new_key_string , TRUE ) ;
g_string_free ( new_ssid_string , TRUE ) ;
return ;
}
}
/* If so... add key */
2011-02-07 20:24:42 +00:00
airpcap_add_key_to_list ( key_list_store , new_type_string - > str , new_key_string - > str , new_ssid_string - > str ) ;
2007-01-26 06:34:05 +00:00
if ( airpcap_if_selected ! = NULL ) airpcap_if_selected - > saved = FALSE ;
}
else /* Should never happen!!! */
{
2013-02-21 01:00:44 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " Unknown error in the key \" Type \" field. " ) ;
2007-01-26 06:34:05 +00:00
}
2006-12-05 19:24:25 +00:00
g_string_free ( new_type_string , TRUE ) ;
g_string_free ( new_key_string , TRUE ) ;
g_string_free ( new_ssid_string , TRUE ) ;
2007-01-26 06:34:05 +00:00
window_destroy ( GTK_WIDGET ( data ) ) ;
return ;
2006-08-16 18:01:25 +00:00
}
/*
2006-10-19 00:48:03 +00:00
* Callback used to edit a WEP key in the edit key box ;
2006-08-16 18:01:25 +00:00
*/
static void
2010-08-23 19:29:08 +00:00
on_edit_key_ok_bt_clicked ( GtkWidget * widget _U_ , gpointer data )
2006-08-16 18:01:25 +00:00
{
2010-11-28 00:00:58 +00:00
GtkWidget * type_cb ,
* key_en ,
* ssid_en ;
2006-12-05 19:24:25 +00:00
2011-02-07 20:24:42 +00:00
GtkListStore * key_list_store ;
GtkTreeSelection * selection ;
GtkTreeIter iter ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
GString * new_type_string ,
2010-11-28 00:00:58 +00:00
* new_key_string ,
* new_ssid_string ;
2006-08-16 18:01:25 +00:00
2010-11-28 00:00:58 +00:00
gchar * type_entered = NULL ;
gchar * key_entered = NULL ;
gchar * ssid_entered = NULL ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
unsigned int i ;
2006-08-16 18:01:25 +00:00
2013-03-21 02:29:09 +00:00
key_list_store = ( GtkListStore * ) g_object_get_data ( G_OBJECT ( data ) , AIRPCAP_ADVANCED_EDIT_KEY_LIST_KEY ) ;
selection = ( GtkTreeSelection * ) g_object_get_data ( G_OBJECT ( data ) , AIRPCAP_ADVANCED_EDIT_KEY_SELECTION_KEY ) ;
type_cb = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( data ) , AIRPCAP_ADVANCED_EDIT_KEY_TYPE_KEY ) ;
key_en = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( data ) , AIRPCAP_ADVANCED_EDIT_KEY_KEY_KEY ) ;
ssid_en = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( data ) , AIRPCAP_ADVANCED_EDIT_KEY_SSID_KEY ) ;
2006-10-19 00:48:03 +00:00
2011-02-07 20:24:42 +00:00
if ( ! gtk_tree_selection_get_selected ( selection , NULL , & iter ) )
return ;
2006-08-16 18:01:25 +00:00
2011-07-24 15:22:21 +00:00
type_entered = gtk_combo_box_text_get_active_text ( GTK_COMBO_BOX_TEXT ( type_cb ) ) ;
2007-01-26 06:34:05 +00:00
key_entered = g_strdup ( gtk_entry_get_text ( GTK_ENTRY ( key_en ) ) ) ;
ssid_entered = g_strdup ( gtk_entry_get_text ( GTK_ENTRY ( ssid_en ) ) ) ;
2006-08-16 18:01:25 +00:00
2011-02-07 20:24:42 +00:00
g_strstrip ( key_entered ) ;
g_strstrip ( ssid_entered ) ;
2007-01-26 06:34:05 +00:00
/* Check if key is correct */
new_type_string = g_string_new ( type_entered ) ;
new_key_string = g_string_new ( key_entered ) ;
new_ssid_string = g_string_new ( ssid_entered ) ;
2006-08-16 18:01:25 +00:00
2009-07-01 15:56:12 +00:00
g_free ( type_entered ) ;
g_free ( key_entered ) ;
g_free ( ssid_entered ) ;
2007-01-26 06:34:05 +00:00
/* Check which type of key the user has entered */
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
if ( g_ascii_strcasecmp ( new_type_string - > str , AIRPCAP_WEP_KEY_STRING ) = = 0 ) /* WEP key */
2007-01-26 06:34:05 +00:00
{
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
if ( ( ( new_key_string - > len ) > WEP_KEY_MAX_CHAR_SIZE ) | | ( ( new_key_string - > len ) < WEP_KEY_MIN_CHAR_SIZE ) )
{
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " WEP key size out of range! \n Valid key size range is %d-%d characters (%d-%d bits). " , WEP_KEY_MIN_CHAR_SIZE , WEP_KEY_MAX_CHAR_SIZE , WEP_KEY_MIN_BIT_SIZE , WEP_KEY_MAX_BIT_SIZE ) ;
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
g_string_free ( new_type_string , TRUE ) ;
g_string_free ( new_key_string , TRUE ) ;
g_string_free ( new_ssid_string , TRUE ) ;
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
return ;
}
2006-10-02 23:44:10 +00:00
2007-01-26 06:34:05 +00:00
if ( ( new_key_string - > len % 2 ) ! = 0 )
{
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " Invalid WEP key! \n The number of characters must be even. " ) ;
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
g_string_free ( new_type_string , TRUE ) ;
g_string_free ( new_key_string , TRUE ) ;
g_string_free ( new_ssid_string , TRUE ) ;
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
return ;
}
for ( i = 0 ; i < new_key_string - > len ; i + + )
{
if ( ! g_ascii_isxdigit ( new_key_string - > str [ i ] ) )
{
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " Invalid WEP key! \n A WEP key must be an hexadecimal number. \n The valid characters are: 0123456789ABCDEF. " ) ;
g_string_free ( new_type_string , TRUE ) ;
g_string_free ( new_key_string , TRUE ) ;
g_string_free ( new_ssid_string , TRUE ) ;
return ;
}
}
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
/* If so... Modify key */
2011-02-07 20:24:42 +00:00
gtk_list_store_set ( key_list_store , & iter ,
KL_COL_TYPE , new_type_string - > str ,
KL_COL_KEY , new_key_string - > str ,
KL_COL_SSID , new_ssid_string - > str ,
- 1 ) ;
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
if ( airpcap_if_selected ! = NULL ) airpcap_if_selected - > saved = FALSE ;
}
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
else if ( g_ascii_strcasecmp ( new_type_string - > str , AIRPCAP_WPA_PWD_KEY_STRING ) = = 0 ) /* WPA Key */
2007-01-26 06:34:05 +00:00
{
/* XXX - Perform some WPA related input fields check */
2008-10-15 23:17:40 +00:00
/* If everything is ok, modify the entry in the list */
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
if ( ( ( new_key_string - > len ) > WPA_KEY_MAX_CHAR_SIZE ) | | ( ( new_key_string - > len ) < WPA_KEY_MIN_CHAR_SIZE ) )
{
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " WPA key size out of range! \n Valid key size range is %d-%d ASCII characters (%d-%d bits). " , WPA_KEY_MIN_CHAR_SIZE , WPA_KEY_MAX_CHAR_SIZE , WPA_KEY_MIN_BIT_SIZE , WPA_KEY_MAX_BIT_SIZE ) ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
g_string_free ( new_type_string , TRUE ) ;
g_string_free ( new_key_string , TRUE ) ;
g_string_free ( new_ssid_string , TRUE ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
return ;
}
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
/*
2008-10-15 23:17:40 +00:00
* XXX - Maybe we need some check on the characters ? I ' m not sure if only standard ASCII are ok . . .
2007-01-26 06:34:05 +00:00
*/
2009-05-13 17:13:03 +00:00
if ( ( new_ssid_string - > len ) > WPA_SSID_MAX_CHAR_SIZE )
2007-01-26 06:34:05 +00:00
{
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " SSID key size out of range! \n Valid SSID size range is %d-%d ASCII characters (%d-%d bits). " , WPA_SSID_MIN_CHAR_SIZE , WPA_SSID_MAX_CHAR_SIZE , WPA_SSID_MIN_BIT_SIZE , WPA_SSID_MAX_BIT_SIZE ) ;
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
g_string_free ( new_type_string , TRUE ) ;
g_string_free ( new_key_string , TRUE ) ;
g_string_free ( new_ssid_string , TRUE ) ;
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
return ;
}
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
/* If so... Modify key */
2011-02-07 20:24:42 +00:00
gtk_list_store_set ( key_list_store , & iter ,
KL_COL_TYPE , new_type_string - > str ,
KL_COL_KEY , new_key_string - > str ,
KL_COL_SSID , new_ssid_string - > str ,
- 1 ) ;
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
if ( airpcap_if_selected ! = NULL ) airpcap_if_selected - > saved = FALSE ;
}
strcasecmp(), strncasecmp(), g_strcasecmp(), and g_strncasecmp() delenda
est. Use g_ascii_strcasecmp() and g_ascii_strncasecmp(), and supply our
own versions if they're missing from GLib (as is the case with GLib
1.x).
In the code to build the list of named fields for Diameter, don't use
g_strdown(); do our own g_ascii_-style upper-case to lower-case mapping
in the hash function and use g_ascii_strcasecmp() in the compare
function.
We do this because there is no guarantee that toupper(), tolower(), and
functions that use them will, for example, map between "I" and "i" in
all locales; in Turkish locales, for example, there are, in both
upper case and lower case, versions of "i" with and without a dot, and
the upper-case version of "i" is "I"-with-a-dot and the lower-case
version of "I" is "i"-without-a-dot. This causes strings that should
match not to match.
This finishes fixing bug 2010 - an earlier checkin prevented the crash
(as there are other ways to produce the same crash, e.g. a bogus
dictionary.xml file), but didn't fix the case-insensitive string matching.
svn path=/trunk/; revision=23623
2007-11-27 18:52:51 +00:00
else if ( g_ascii_strcasecmp ( new_type_string - > str , AIRPCAP_WPA_BIN_KEY_STRING ) = = 0 ) /* WPA_BIN Key */
2007-01-26 06:34:05 +00:00
{
/* XXX - Perform some WPA_BIN related input fields check */
2008-10-15 23:17:40 +00:00
/* If everything is ok, modify the entry in the list */
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
if ( ( ( new_key_string - > len ) ! = WPA_PSK_KEY_CHAR_SIZE ) )
{
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " WPA PSK/PMK key size is wrong! \n Valid key size is %d characters (%d bits). " , WPA_PSK_KEY_CHAR_SIZE , WPA_PSK_KEY_BIT_SIZE ) ;
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
g_string_free ( new_type_string , TRUE ) ;
g_string_free ( new_key_string , TRUE ) ;
g_string_free ( new_ssid_string , TRUE ) ;
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
return ;
}
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
for ( i = 0 ; i < new_key_string - > len ; i + + )
{
if ( ! g_ascii_isxdigit ( new_key_string - > str [ i ] ) )
{
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " Invalid WPA PSK/PMK key! \n Key must be an hexadecimal number. \n The valid characters are: 0123456789ABCDEF. " ) ;
g_string_free ( new_type_string , TRUE ) ;
g_string_free ( new_key_string , TRUE ) ;
g_string_free ( new_ssid_string , TRUE ) ;
return ;
}
}
/* If so... Modify key */
2011-02-07 20:24:42 +00:00
gtk_list_store_set ( key_list_store , & iter ,
KL_COL_TYPE , new_type_string - > str ,
KL_COL_KEY , new_key_string - > str ,
KL_COL_SSID , new_ssid_string - > str ,
- 1 ) ;
2007-01-26 06:34:05 +00:00
if ( airpcap_if_selected ! = NULL ) airpcap_if_selected - > saved = FALSE ;
}
else /* Should never happen!!! */
{
2013-02-21 01:00:44 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " Unknown error in the key \" Type \" field. " ) ;
2007-01-26 06:34:05 +00:00
}
2006-12-05 19:24:25 +00:00
g_string_free ( new_type_string , TRUE ) ;
g_string_free ( new_key_string , TRUE ) ;
g_string_free ( new_ssid_string , TRUE ) ;
2007-01-26 06:34:05 +00:00
window_destroy ( GTK_WIDGET ( data ) ) ;
return ;
2006-08-16 18:01:25 +00:00
}
2011-02-10 17:09:36 +00:00
/*
* Add key window destroy callback
*/
static void
on_add_key_w_destroy ( GtkWidget * button _U_ , gpointer data )
{
GtkWidget * airpcap_advanced_w ;
airpcap_advanced_w = GTK_WIDGET ( data ) ;
gtk_widget_set_sensitive ( GTK_WIDGET ( airpcap_advanced_w ) , TRUE ) ;
return ;
}
2006-08-16 18:01:25 +00:00
/*
* Callback for the ' Add Key ' button .
*/
2011-02-07 20:24:42 +00:00
static void
2010-08-23 19:29:08 +00:00
on_add_new_key_bt_clicked ( GtkWidget * button _U_ , gpointer data )
2006-08-16 18:01:25 +00:00
{
2007-01-26 06:34:05 +00:00
GtkWidget * add_key_window ;
GtkWidget * add_frame ;
GtkWidget * main_v_box ;
2012-11-04 17:00:01 +00:00
GtkWidget * add_grid ;
2007-01-26 06:34:05 +00:00
GtkWidget * add_frame_al ;
2009-05-13 16:14:28 +00:00
GtkWidget * add_type_cb ;
2007-01-26 06:34:05 +00:00
GtkWidget * add_key_te ;
GtkWidget * add_ssid_te ;
GtkWidget * add_type_lb ;
GtkWidget * add_key_lb ;
GtkWidget * add_ssid_lb ;
GtkWidget * low_h_button_box ;
GtkWidget * ok_bt ;
GtkWidget * cancel_bt ;
GtkWidget * add_frame_lb ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
GtkWidget * airpcap_advanced_w ;
2006-08-16 18:01:25 +00:00
2011-02-07 20:24:42 +00:00
GtkListStore * key_list_store ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
airpcap_advanced_w = GTK_WIDGET ( data ) ;
2006-08-16 18:01:25 +00:00
2013-03-21 02:29:09 +00:00
key_list_store = ( GtkListStore * ) g_object_get_data ( G_OBJECT ( airpcap_advanced_w ) , AIRPCAP_ADVANCED_KEYLIST_KEY ) ;
2006-10-19 00:48:03 +00:00
2011-02-07 20:24:42 +00:00
if ( gtk_tree_model_iter_n_children ( GTK_TREE_MODEL ( key_list_store ) , NULL ) > = MAX_ENCRYPTION_KEYS )
2007-01-26 06:34:05 +00:00
{
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " Maximum number (%d) of decryption keys reached! You cannot add another key! \n " , MAX_ENCRYPTION_KEYS ) ;
return ;
}
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
/* Gray out the Advanced Wireless Setting window */
gtk_widget_set_sensitive ( airpcap_advanced_w , FALSE ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
/* Pop-up a new window */
2011-02-07 20:24:42 +00:00
add_key_window = dlg_window_new ( " Add Decryption Key " ) ;
2013-03-22 17:31:06 +00:00
gtk_window_set_modal ( GTK_WINDOW ( add_key_window ) , TRUE ) ;
2013-03-22 17:30:55 +00:00
gtk_window_set_transient_for ( GTK_WINDOW ( add_key_window ) , GTK_WINDOW ( airpcap_advanced_w ) ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( add_key_window , " add_key_window " ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( add_key_window ) , 5 ) ;
gtk_window_set_resizable ( GTK_WINDOW ( add_key_window ) , FALSE ) ;
2006-10-19 00:48:03 +00:00
2012-06-02 23:53:04 +00:00
main_v_box = ws_gtk_box_new ( GTK_ORIENTATION_VERTICAL , 0 , FALSE ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( main_v_box , " main_v_box " ) ;
gtk_widget_show ( main_v_box ) ;
gtk_container_add ( GTK_CONTAINER ( add_key_window ) , main_v_box ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
add_frame = gtk_frame_new ( NULL ) ;
gtk_widget_set_name ( add_frame , " add_frame " ) ;
gtk_widget_show ( add_frame ) ;
gtk_box_pack_start ( GTK_BOX ( main_v_box ) , add_frame , TRUE , TRUE , 0 ) ;
2006-10-19 00:48:03 +00:00
2012-12-26 05:57:06 +00:00
add_frame_al = gtk_alignment_new ( 0.5f , 0.5f , 1 , 1 ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( add_frame_al , " add_frame_al " ) ;
gtk_widget_show ( add_frame_al ) ;
gtk_container_add ( GTK_CONTAINER ( add_frame ) , add_frame_al ) ;
gtk_alignment_set_padding ( GTK_ALIGNMENT ( add_frame_al ) , 0 , 0 , 12 , 0 ) ;
2006-08-16 18:01:25 +00:00
2013-01-09 21:35:18 +00:00
add_grid = ws_gtk_grid_new ( ) ;
2012-11-04 17:00:01 +00:00
gtk_widget_set_name ( add_grid , " add_tb " ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( add_grid ) , 5 ) ;
gtk_widget_show ( add_grid ) ;
gtk_container_add ( GTK_CONTAINER ( add_frame_al ) , add_grid ) ;
2007-01-26 06:34:05 +00:00
2012-11-04 16:05:28 +00:00
add_type_lb = gtk_label_new ( " Type " ) ;
gtk_widget_set_name ( add_type_lb , " add_type_lb " ) ;
gtk_widget_show ( add_type_lb ) ;
2013-01-09 21:35:18 +00:00
ws_gtk_grid_attach_defaults ( GTK_GRID ( add_grid ) , add_type_lb , 0 , 0 , 1 , 1 ) ;
2012-11-04 16:05:28 +00:00
gtk_label_set_justify ( GTK_LABEL ( add_type_lb ) , GTK_JUSTIFY_CENTER ) ;
add_key_lb = gtk_label_new ( " Key " ) ;
gtk_widget_set_name ( add_key_lb , " add_key_lb " ) ;
gtk_widget_show ( add_key_lb ) ;
2013-01-09 21:35:18 +00:00
ws_gtk_grid_attach_defaults ( GTK_GRID ( add_grid ) , add_key_lb , 1 , 0 , 1 , 1 ) ;
2012-11-04 16:05:28 +00:00
gtk_label_set_justify ( GTK_LABEL ( add_key_lb ) , GTK_JUSTIFY_CENTER ) ;
add_ssid_lb = gtk_label_new ( " " ) ;
gtk_widget_set_name ( add_ssid_lb , " add_ssid_lb " ) ;
/* XXX - Decomment only when WPA and WPA_BIN will be ready */
gtk_widget_show ( add_ssid_lb ) ;
2013-01-09 21:35:18 +00:00
ws_gtk_grid_attach_defaults ( GTK_GRID ( add_grid ) , add_ssid_lb , 2 , 0 , 1 , 1 ) ;
2012-11-04 16:05:28 +00:00
gtk_label_set_justify ( GTK_LABEL ( add_ssid_lb ) , GTK_JUSTIFY_CENTER ) ;
2011-07-24 15:22:21 +00:00
add_type_cb = gtk_combo_box_text_new ( ) ;
gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT ( add_type_cb ) , AIRPCAP_WEP_KEY_STRING ) ;
2006-10-19 00:48:03 +00:00
2011-07-24 15:22:21 +00:00
gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT ( add_type_cb ) , AIRPCAP_WPA_PWD_KEY_STRING ) ;
gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT ( add_type_cb ) , AIRPCAP_WPA_BIN_KEY_STRING ) ;
2009-05-13 16:14:28 +00:00
gtk_combo_box_set_active ( GTK_COMBO_BOX ( add_type_cb ) , 0 ) ;
gtk_widget_set_name ( add_type_cb , " add_type_cb " ) ;
gtk_widget_show ( add_type_cb ) ;
2013-01-09 21:35:18 +00:00
ws_gtk_grid_attach_defaults ( GTK_GRID ( add_grid ) , add_type_cb , 0 , 1 , 1 , 1 ) ;
2009-05-13 16:14:28 +00:00
gtk_widget_set_size_request ( add_type_cb , 83 , - 1 ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
add_key_te = gtk_entry_new ( ) ;
gtk_widget_set_name ( add_key_te , " add_key_te " ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
gtk_widget_show ( add_key_te ) ;
2013-01-09 21:35:18 +00:00
ws_gtk_grid_attach_defaults ( GTK_GRID ( add_grid ) , add_key_te , 1 , 1 , 1 , 1 ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_size_request ( add_key_te , 178 , - 1 ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
add_ssid_te = gtk_entry_new ( ) ;
gtk_widget_set_name ( add_ssid_te , " add_ssid_te " ) ;
gtk_widget_set_sensitive ( add_ssid_te , FALSE ) ;
/* XXX - Decomment only when WPA and WPA_BIN will be ready */
gtk_widget_show ( add_ssid_te ) ;
2013-01-09 21:35:18 +00:00
ws_gtk_grid_attach_defaults ( GTK_GRID ( add_grid ) , add_ssid_te , 2 , 1 , 1 , 1 ) ;
2012-06-02 23:53:04 +00:00
low_h_button_box = gtk_button_box_new ( GTK_ORIENTATION_HORIZONTAL ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( low_h_button_box , " low_h_button_box " ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( low_h_button_box ) , 5 ) ;
gtk_widget_show ( low_h_button_box ) ;
gtk_box_pack_end ( GTK_BOX ( main_v_box ) , low_h_button_box , FALSE , FALSE , 0 ) ;
gtk_button_box_set_layout ( GTK_BUTTON_BOX ( low_h_button_box ) ,
GTK_BUTTONBOX_END ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
ok_bt = gtk_button_new_with_mnemonic ( " OK " ) ;
gtk_widget_set_name ( ok_bt , " ok_bt " ) ;
gtk_widget_show ( ok_bt ) ;
gtk_container_add ( GTK_CONTAINER ( low_h_button_box ) , ok_bt ) ;
2011-07-14 00:04:37 +00:00
gtk_widget_set_can_default ( ok_bt , TRUE ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
cancel_bt = gtk_button_new_with_mnemonic ( " Cancel " ) ;
gtk_widget_set_name ( cancel_bt , " cancel_bt " ) ;
gtk_widget_show ( cancel_bt ) ;
gtk_container_add ( GTK_CONTAINER ( low_h_button_box ) , cancel_bt ) ;
2011-07-14 00:04:37 +00:00
gtk_widget_set_can_default ( cancel_bt , TRUE ) ;
2007-01-26 06:34:05 +00:00
add_frame_lb = gtk_label_new ( " <b>Modify Selected Key</b> " ) ;
gtk_widget_set_name ( add_frame_lb , " add_frame_lb " ) ;
gtk_widget_show ( add_frame_lb ) ;
gtk_frame_set_label_widget ( GTK_FRAME ( add_frame ) , add_frame_lb ) ;
gtk_label_set_use_markup ( GTK_LABEL ( add_frame_lb ) , TRUE ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
/* Add callbacks */
2008-04-09 05:37:53 +00:00
g_signal_connect ( ok_bt , " clicked " , G_CALLBACK ( on_add_key_ok_bt_clicked ) , add_key_window ) ;
g_signal_connect ( cancel_bt , " clicked " , G_CALLBACK ( window_cancel_button_cb ) , add_key_window ) ;
2009-05-13 16:14:28 +00:00
g_signal_connect ( add_type_cb , " changed " , G_CALLBACK ( on_add_type_cb_changed ) , add_key_window ) ;
2010-08-17 13:59:15 +00:00
g_signal_connect ( add_key_window , " delete_event " , G_CALLBACK ( window_delete_event_cb ) , NULL ) ;
2008-04-09 05:37:53 +00:00
g_signal_connect ( add_key_window , " destroy " , G_CALLBACK ( on_add_key_w_destroy ) , data ) ;
2007-01-26 06:34:05 +00:00
/* Add widget data */
2011-02-07 20:24:42 +00:00
g_object_set_data ( G_OBJECT ( add_key_window ) , AIRPCAP_ADVANCED_ADD_KEY_LIST_KEY , key_list_store ) ;
2009-05-13 16:14:28 +00:00
g_object_set_data ( G_OBJECT ( add_key_window ) , AIRPCAP_ADVANCED_ADD_KEY_TYPE_KEY , add_type_cb ) ;
2008-04-09 20:55:33 +00:00
g_object_set_data ( G_OBJECT ( add_key_window ) , AIRPCAP_ADVANCED_ADD_KEY_KEY_KEY , add_key_te ) ;
g_object_set_data ( G_OBJECT ( add_key_window ) , AIRPCAP_ADVANCED_ADD_KEY_SSID_KEY , add_ssid_te ) ;
g_object_set_data ( G_OBJECT ( add_key_window ) , AIRPCAP_ADVANCED_ADD_KEY_KEY_LABEL_KEY , add_key_lb ) ;
g_object_set_data ( G_OBJECT ( add_key_window ) , AIRPCAP_ADVANCED_ADD_KEY_SSID_LABEL_KEY , add_ssid_lb ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_show ( add_key_window ) ;
2006-08-16 18:01:25 +00:00
}
/*
* Edit key window destroy callback
*/
2011-02-07 20:24:42 +00:00
static void
2009-05-13 10:29:42 +00:00
on_edit_key_w_destroy ( GtkWidget * button _U_ , gpointer data )
2006-10-19 00:48:03 +00:00
{
2007-01-26 06:34:05 +00:00
GtkWidget * airpcap_advanced_w ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
airpcap_advanced_w = GTK_WIDGET ( data ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
gtk_widget_set_sensitive ( GTK_WIDGET ( airpcap_advanced_w ) , TRUE ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
return ;
2006-10-19 00:48:03 +00:00
}
2006-08-16 18:01:25 +00:00
/*
* Callback for the ' Remove Key ' button .
*/
2011-02-07 20:24:42 +00:00
static void
2009-05-13 10:29:42 +00:00
on_remove_key_bt_clicked ( GtkWidget * button _U_ , gpointer data )
2006-08-16 18:01:25 +00:00
{
2011-02-07 20:24:42 +00:00
GtkTreeModel * model ;
GtkTreeIter iter ;
GtkTreeSelection * selection ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
/* retrieve needed stuff */
2013-03-21 02:29:09 +00:00
selection = ( GtkTreeSelection * ) g_object_get_data ( G_OBJECT ( data ) , AIRPCAP_ADVANCED_EDIT_KEY_SELECTION_KEY ) ;
2006-10-19 00:48:03 +00:00
2011-02-07 20:24:42 +00:00
if ( ! gtk_tree_selection_get_selected ( selection , & model , & iter ) )
return ;
2006-10-19 00:48:03 +00:00
2008-10-15 23:17:40 +00:00
/* Remove selected key */
2011-02-07 20:24:42 +00:00
gtk_list_store_remove ( GTK_LIST_STORE ( model ) , & iter ) ;
gtk_tree_selection_select_iter ( selection , & iter ) ;
/* XXX - select the last item if needed? */
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
/* Need to save config... */
if ( airpcap_if_selected ! = NULL ) airpcap_if_selected - > saved = FALSE ;
2006-08-16 18:01:25 +00:00
}
/*
* Callback for the ' Edit Key ' button .
*/
2011-02-07 20:24:42 +00:00
static void
2009-05-13 10:29:42 +00:00
on_edit_key_bt_clicked ( GtkWidget * button _U_ , gpointer data )
2006-08-16 18:01:25 +00:00
{
2007-01-26 06:34:05 +00:00
GtkWidget * edit_key_window ;
GtkWidget * edit_frame ;
GtkWidget * main_v_box ;
2012-11-04 17:39:07 +00:00
GtkWidget * edit_grid ;
2007-01-26 06:34:05 +00:00
GtkWidget * edit_frame_al ;
2009-05-13 16:14:28 +00:00
GtkWidget * edit_type_cb ;
2007-01-26 06:34:05 +00:00
GtkWidget * edit_key_te ;
GtkWidget * edit_ssid_te ;
GtkWidget * edit_type_lb ;
GtkWidget * edit_key_lb ;
GtkWidget * edit_ssid_lb ;
GtkWidget * low_h_button_box ;
GtkWidget * ok_bt ;
GtkWidget * cancel_bt ;
GtkWidget * edit_frame_lb ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
GtkWidget * airpcap_advanced_w ;
2006-08-16 18:01:25 +00:00
2011-02-07 20:24:42 +00:00
GtkTreeModel * model ;
GtkTreeIter iter ;
GtkTreeSelection * selection ;
2006-08-16 18:01:25 +00:00
2011-02-07 20:24:42 +00:00
/* Key List Store */
GtkListStore * key_list_store ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
gchar * row_type ,
2010-11-28 00:00:58 +00:00
* row_key ,
2012-12-26 05:57:06 +00:00
* row_ssid = NULL ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
airpcap_advanced_w = GTK_WIDGET ( data ) ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
/* Retrieve the selected item... if no row is selected, this is null... */
2013-03-21 02:29:09 +00:00
selection = ( GtkTreeSelection * ) g_object_get_data ( G_OBJECT ( data ) , AIRPCAP_ADVANCED_EDIT_KEY_SELECTION_KEY ) ;
key_list_store = ( GtkListStore * ) g_object_get_data ( G_OBJECT ( data ) , AIRPCAP_ADVANCED_KEYLIST_KEY ) ;
2006-08-16 18:01:25 +00:00
2011-02-07 20:24:42 +00:00
if ( ! gtk_tree_selection_get_selected ( selection , & model , & iter ) )
return ;
2009-05-13 16:14:28 +00:00
2011-02-07 20:24:42 +00:00
gtk_tree_model_get ( model , & iter ,
KL_COL_TYPE , & row_type ,
KL_COL_KEY , & row_key ,
KL_COL_SSID , & row_ssid ,
- 1 ) ;
/* Gray out the Advanced Wireless Setting window */
gtk_widget_set_sensitive ( airpcap_advanced_w , FALSE ) ;
/* Pop-up a new window */
edit_key_window = dlg_window_new ( " Edit Decryption Key " ) ;
2013-03-22 17:31:06 +00:00
gtk_window_set_modal ( GTK_WINDOW ( edit_key_window ) , TRUE ) ;
2013-03-22 17:30:55 +00:00
gtk_window_set_transient_for ( GTK_WINDOW ( edit_key_window ) , GTK_WINDOW ( airpcap_advanced_w ) ) ;
2011-02-07 20:24:42 +00:00
gtk_widget_set_name ( edit_key_window , " edit_key_window " ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( edit_key_window ) , 5 ) ;
gtk_window_set_resizable ( GTK_WINDOW ( edit_key_window ) , FALSE ) ;
2012-06-02 23:53:04 +00:00
main_v_box = ws_gtk_box_new ( GTK_ORIENTATION_VERTICAL , 0 , FALSE ) ;
2011-02-07 20:24:42 +00:00
gtk_widget_set_name ( main_v_box , " main_v_box " ) ;
gtk_widget_show ( main_v_box ) ;
gtk_container_add ( GTK_CONTAINER ( edit_key_window ) , main_v_box ) ;
edit_frame = gtk_frame_new ( NULL ) ;
gtk_widget_set_name ( edit_frame , " edit_frame " ) ;
gtk_widget_show ( edit_frame ) ;
gtk_box_pack_start ( GTK_BOX ( main_v_box ) , edit_frame , TRUE , TRUE , 0 ) ;
2012-12-26 05:57:06 +00:00
edit_frame_al = gtk_alignment_new ( 0.5f , 0.5f , 1 , 1 ) ;
2011-02-07 20:24:42 +00:00
gtk_widget_set_name ( edit_frame_al , " edit_frame_al " ) ;
gtk_widget_show ( edit_frame_al ) ;
gtk_container_add ( GTK_CONTAINER ( edit_frame ) , edit_frame_al ) ;
gtk_alignment_set_padding ( GTK_ALIGNMENT ( edit_frame_al ) , 0 , 0 , 12 , 0 ) ;
2013-01-09 21:35:18 +00:00
edit_grid = ws_gtk_grid_new ( ) ;
2012-11-04 17:39:07 +00:00
gtk_widget_set_name ( edit_grid , " edit_tb " ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( edit_grid ) , 5 ) ;
gtk_widget_show ( edit_grid ) ;
gtk_container_add ( GTK_CONTAINER ( edit_frame_al ) , edit_grid ) ;
edit_type_lb = gtk_label_new ( " Type " ) ;
gtk_widget_set_name ( edit_type_lb , " edit_type_lb " ) ;
gtk_widget_show ( edit_type_lb ) ;
2013-01-09 21:35:18 +00:00
ws_gtk_grid_attach_defaults ( GTK_GRID ( edit_grid ) , edit_type_lb , 0 , 0 , 1 , 1 ) ;
2012-11-04 17:39:07 +00:00
gtk_label_set_justify ( GTK_LABEL ( edit_type_lb ) , GTK_JUSTIFY_CENTER ) ;
edit_key_lb = gtk_label_new ( " Key " ) ;
gtk_widget_set_name ( edit_key_lb , " edit_key_lb " ) ;
gtk_widget_show ( edit_key_lb ) ;
2013-01-09 21:35:18 +00:00
ws_gtk_grid_attach_defaults ( GTK_GRID ( edit_grid ) , edit_key_lb , 1 , 0 , 1 , 1 ) ;
2012-11-04 17:39:07 +00:00
gtk_label_set_justify ( GTK_LABEL ( edit_key_lb ) , GTK_JUSTIFY_CENTER ) ;
edit_ssid_lb = gtk_label_new ( " " ) ;
gtk_widget_set_name ( edit_ssid_lb , " edit_ssid_lb " ) ;
/* XXX - Decomment only when WPA and WPA_BIN will be ready */
gtk_widget_show ( edit_ssid_lb ) ;
2013-01-09 21:35:18 +00:00
ws_gtk_grid_attach_defaults ( GTK_GRID ( edit_grid ) , edit_ssid_lb , 2 , 0 , 1 , 1 ) ;
2012-11-04 17:39:07 +00:00
gtk_label_set_justify ( GTK_LABEL ( edit_ssid_lb ) , GTK_JUSTIFY_CENTER ) ;
2011-02-07 20:24:42 +00:00
2011-07-24 15:22:21 +00:00
edit_type_cb = gtk_combo_box_text_new ( ) ;
gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT ( edit_type_cb ) , AIRPCAP_WEP_KEY_STRING ) ;
2011-02-07 20:24:42 +00:00
2011-07-24 15:22:21 +00:00
gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT ( edit_type_cb ) , AIRPCAP_WPA_PWD_KEY_STRING ) ;
gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT ( edit_type_cb ) , AIRPCAP_WPA_BIN_KEY_STRING ) ;
2011-02-07 20:24:42 +00:00
/* Set current type */
gtk_combo_box_set_active ( GTK_COMBO_BOX ( edit_type_cb ) , 0 ) ;
if ( g_ascii_strcasecmp ( row_type , AIRPCAP_WPA_PWD_KEY_STRING ) = = 0 ) {
gtk_combo_box_set_active ( GTK_COMBO_BOX ( edit_type_cb ) , 1 ) ;
} else if ( g_ascii_strcasecmp ( row_type , AIRPCAP_WPA_BIN_KEY_STRING ) = = 0 ) {
gtk_combo_box_set_active ( GTK_COMBO_BOX ( edit_type_cb ) , 2 ) ;
}
gtk_widget_set_name ( edit_type_cb , " edit_type_cb " ) ;
gtk_widget_show ( edit_type_cb ) ;
2013-01-09 21:35:18 +00:00
ws_gtk_grid_attach_defaults ( GTK_GRID ( edit_grid ) , edit_type_cb , 0 , 1 , 1 , 1 ) ;
2011-02-07 20:24:42 +00:00
gtk_widget_set_size_request ( edit_type_cb , 83 , - 1 ) ;
edit_key_te = gtk_entry_new ( ) ;
gtk_widget_set_name ( edit_key_te , " edit_key_te " ) ;
/* Set current key */
gtk_entry_set_text ( GTK_ENTRY ( edit_key_te ) , row_key ) ;
gtk_widget_show ( edit_key_te ) ;
2013-01-09 21:35:18 +00:00
ws_gtk_grid_attach_defaults ( GTK_GRID ( edit_grid ) , edit_key_te , 1 , 1 , 1 , 1 ) ;
2011-02-07 20:24:42 +00:00
gtk_widget_set_size_request ( edit_key_te , 178 , - 1 ) ;
edit_ssid_te = gtk_entry_new ( ) ;
gtk_widget_set_name ( edit_ssid_te , " edit_ssid_te " ) ;
/* Set current ssid (if key type is not WEP!)*/
if ( g_ascii_strcasecmp ( row_type , AIRPCAP_WEP_KEY_STRING ) = = 0 )
{
gtk_widget_set_sensitive ( edit_ssid_te , FALSE ) ;
}
else
{
gtk_widget_set_sensitive ( edit_ssid_te , TRUE ) ;
2012-12-26 05:57:06 +00:00
gtk_entry_set_text ( GTK_ENTRY ( edit_ssid_te ) , row_ssid ? row_ssid : " " ) ;
2006-08-16 18:01:25 +00:00
}
2011-02-07 20:24:42 +00:00
/* XXX - Decomment only when WPA and WPA@ will be ready */
gtk_widget_show ( edit_ssid_te ) ;
2013-01-09 21:35:18 +00:00
ws_gtk_grid_attach_defaults ( GTK_GRID ( edit_grid ) , edit_ssid_te , 2 , 1 , 1 , 1 ) ;
2006-10-19 00:48:03 +00:00
2012-06-02 23:53:04 +00:00
low_h_button_box = gtk_button_box_new ( GTK_ORIENTATION_HORIZONTAL ) ;
2011-02-07 20:24:42 +00:00
gtk_widget_set_name ( low_h_button_box , " low_h_button_box " ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( low_h_button_box ) , 5 ) ;
gtk_widget_show ( low_h_button_box ) ;
gtk_box_pack_end ( GTK_BOX ( main_v_box ) , low_h_button_box , FALSE , FALSE , 0 ) ;
gtk_button_box_set_layout ( GTK_BUTTON_BOX ( low_h_button_box ) ,
GTK_BUTTONBOX_END ) ;
2006-10-19 00:48:03 +00:00
2011-02-07 20:24:42 +00:00
ok_bt = gtk_button_new_with_mnemonic ( " OK " ) ;
gtk_widget_set_name ( ok_bt , " ok_bt " ) ;
gtk_widget_show ( ok_bt ) ;
gtk_container_add ( GTK_CONTAINER ( low_h_button_box ) , ok_bt ) ;
2011-07-14 00:04:37 +00:00
gtk_widget_set_can_default ( ok_bt , TRUE ) ;
2006-10-19 00:48:03 +00:00
2011-02-07 20:24:42 +00:00
cancel_bt = gtk_button_new_with_mnemonic ( " Cancel " ) ;
gtk_widget_set_name ( cancel_bt , " cancel_bt " ) ;
gtk_widget_show ( cancel_bt ) ;
gtk_container_add ( GTK_CONTAINER ( low_h_button_box ) , cancel_bt ) ;
2011-07-14 00:04:37 +00:00
gtk_widget_set_can_default ( cancel_bt , TRUE ) ;
2006-10-19 00:48:03 +00:00
2011-02-07 20:24:42 +00:00
edit_frame_lb = gtk_label_new ( " <b>Modify Selected Key</b> " ) ;
gtk_widget_set_name ( edit_frame_lb , " edit_frame_lb " ) ;
gtk_widget_show ( edit_frame_lb ) ;
gtk_frame_set_label_widget ( GTK_FRAME ( edit_frame ) , edit_frame_lb ) ;
gtk_label_set_use_markup ( GTK_LABEL ( edit_frame_lb ) , TRUE ) ;
2006-10-19 00:48:03 +00:00
2011-02-07 20:24:42 +00:00
/* Add callbacks */
g_signal_connect ( ok_bt , " clicked " , G_CALLBACK ( on_edit_key_ok_bt_clicked ) , edit_key_window ) ;
g_signal_connect ( cancel_bt , " clicked " , G_CALLBACK ( window_cancel_button_cb ) , edit_key_window ) ;
g_signal_connect ( edit_type_cb , " changed " , G_CALLBACK ( on_edit_type_cb_changed ) , edit_key_window ) ;
g_signal_connect ( edit_key_window , " delete_event " , G_CALLBACK ( window_delete_event_cb ) , NULL ) ;
g_signal_connect ( edit_key_window , " destroy " , G_CALLBACK ( on_edit_key_w_destroy ) , data ) ;
2006-10-19 00:48:03 +00:00
2011-02-07 20:24:42 +00:00
/* Add widget data */
g_object_set_data ( G_OBJECT ( edit_key_window ) , AIRPCAP_ADVANCED_EDIT_KEY_LIST_KEY , key_list_store ) ;
g_object_set_data ( G_OBJECT ( edit_key_window ) , AIRPCAP_ADVANCED_EDIT_KEY_SELECTION_KEY , selection ) ;
g_object_set_data ( G_OBJECT ( edit_key_window ) , AIRPCAP_ADVANCED_EDIT_KEY_TYPE_KEY , edit_type_cb ) ;
g_object_set_data ( G_OBJECT ( edit_key_window ) , AIRPCAP_ADVANCED_EDIT_KEY_KEY_KEY , edit_key_te ) ;
g_object_set_data ( G_OBJECT ( edit_key_window ) , AIRPCAP_ADVANCED_EDIT_KEY_SSID_KEY , edit_ssid_te ) ;
g_object_set_data ( G_OBJECT ( edit_key_window ) , AIRPCAP_ADVANCED_EDIT_KEY_KEY_LABEL_KEY , edit_key_lb ) ;
g_object_set_data ( G_OBJECT ( edit_key_window ) , AIRPCAP_ADVANCED_EDIT_KEY_SSID_LABEL_KEY , edit_ssid_lb ) ;
2006-10-19 00:48:03 +00:00
2011-02-07 20:24:42 +00:00
g_free ( row_type ) ;
g_free ( row_key ) ;
g_free ( row_ssid ) ;
gtk_widget_show ( edit_key_window ) ;
}
2006-08-16 18:01:25 +00:00
2011-02-07 20:24:42 +00:00
/*
* Callback for the ' Move Key Up ' button .
*/
static void
on_move_key_up_bt_clicked ( GtkWidget * button _U_ , gpointer key_list )
{
tree_view_list_store_move_selection ( GTK_TREE_VIEW ( key_list ) , TRUE ) ;
2006-08-16 18:01:25 +00:00
}
/*
* Callback for the ' Move Key Down ' button .
*/
2011-02-10 17:09:36 +00:00
static void
2011-02-07 20:24:42 +00:00
on_move_key_down_bt_clicked ( GtkWidget * button _U_ , gpointer list_view )
2006-08-16 18:01:25 +00:00
{
2011-02-07 20:24:42 +00:00
tree_view_list_store_move_selection ( GTK_TREE_VIEW ( list_view ) , FALSE ) ;
2006-08-16 18:01:25 +00:00
}
/* Turns the decryption on or off */
2006-10-19 00:48:03 +00:00
void
2009-05-13 17:13:03 +00:00
on_decryption_mode_cb_changed ( GtkWidget * cb , gpointer data _U_ )
2006-08-16 18:01:25 +00:00
{
2009-05-13 16:14:28 +00:00
gint cur_active ;
2011-05-15 02:45:18 +00:00
2009-05-13 16:14:28 +00:00
if ( cb = = NULL ) {
2007-01-26 06:34:05 +00:00
return ;
2006-10-19 00:48:03 +00:00
}
2011-05-15 02:45:18 +00:00
2009-05-13 16:14:28 +00:00
cur_active = gtk_combo_box_get_active ( GTK_COMBO_BOX ( cb ) ) ;
2011-05-15 02:45:18 +00:00
2009-05-13 16:14:28 +00:00
if ( cur_active < 0 ) {
return ;
2006-10-19 00:48:03 +00:00
}
2011-05-15 02:45:18 +00:00
2009-05-13 16:14:28 +00:00
switch ( cur_active ) {
/* XXX - Don't use magic numbers here */
case 1 : /* Wireshark */
set_wireshark_decryption ( TRUE ) ;
if ( ! set_airpcap_decryption ( FALSE ) ) g_warning ( CANT_SAVE_ERR_STR ) ;
break ;
case 2 : /* Driver */
set_wireshark_decryption ( FALSE ) ;
if ( ! set_airpcap_decryption ( TRUE ) ) g_warning ( CANT_SAVE_ERR_STR ) ;
break ;
default :
set_wireshark_decryption ( FALSE ) ;
if ( ! set_airpcap_decryption ( FALSE ) ) g_warning ( CANT_SAVE_ERR_STR ) ;
break ;
2006-10-19 00:48:03 +00:00
}
2007-01-26 06:34:05 +00:00
/* Redissect all the packets, and re-evaluate the display filter. */
2009-05-04 21:13:14 +00:00
redissect_packets ( ) ;
2013-03-24 16:47:38 +00:00
redissect_all_packet_windows ( ) ;
2006-10-19 00:48:03 +00:00
}
/*
2009-05-13 16:14:28 +00:00
* Selects the current decryption mode string in the decryption mode combo box
2006-10-19 00:48:03 +00:00
*/
void
2009-05-13 16:14:28 +00:00
update_decryption_mode ( GtkWidget * cb )
2006-10-19 00:48:03 +00:00
{
2009-05-13 16:14:28 +00:00
if ( cb = = NULL ) {
return ;
}
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
/* Wireshark decryption is on */
if ( wireshark_decryption_on ( ) )
2006-10-19 00:48:03 +00:00
{
2009-05-13 16:14:28 +00:00
gtk_combo_box_set_active ( GTK_COMBO_BOX ( cb ) , 1 ) ;
2006-10-19 00:48:03 +00:00
}
2007-01-26 06:34:05 +00:00
/* AirPcap decryption is on */
else if ( airpcap_decryption_on ( ) )
2006-10-19 00:48:03 +00:00
{
2009-05-13 16:14:28 +00:00
gtk_combo_box_set_active ( GTK_COMBO_BOX ( cb ) , 2 ) ;
2006-10-19 00:48:03 +00:00
}
2007-01-26 06:34:05 +00:00
/* No decryption enabled */
else
2006-10-19 00:48:03 +00:00
{
2009-05-13 16:14:28 +00:00
gtk_combo_box_set_active ( GTK_COMBO_BOX ( cb ) , 0 ) ;
2006-10-19 00:48:03 +00:00
}
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
return ;
2006-08-16 18:01:25 +00:00
}
2006-12-05 19:24:25 +00:00
/*
* Creates the list of available decryption modes , depending on the adapters found
*/
void
2009-05-13 16:14:28 +00:00
update_decryption_mode_list ( GtkWidget * cb )
2006-12-05 19:24:25 +00:00
{
2009-05-13 16:14:28 +00:00
gchar * current_text ;
2006-12-05 19:24:25 +00:00
2009-05-13 16:14:28 +00:00
if ( cb = = NULL )
2007-01-26 06:34:05 +00:00
return ;
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
current_text = NULL ;
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
/*
* XXX - Retrieve the current ' decryption mode ' . It would be better just block the
2008-10-15 23:17:40 +00:00
* signal handler , but it doesn ' t work . . . one of these days I ' ll try to figure out why . . .
2007-01-26 06:34:05 +00:00
*/
2011-07-24 15:22:21 +00:00
current_text = gtk_combo_box_text_get_active_text ( GTK_COMBO_BOX_TEXT ( cb ) ) ;
2011-05-15 02:45:18 +00:00
2009-05-13 16:14:28 +00:00
while ( gtk_tree_model_iter_n_children ( gtk_combo_box_get_model ( GTK_COMBO_BOX ( cb ) ) , NULL ) > 0 ) {
2011-07-24 15:22:21 +00:00
gtk_combo_box_text_remove ( GTK_COMBO_BOX_TEXT ( cb ) , 0 ) ;
2009-05-13 16:14:28 +00:00
}
2006-12-05 19:24:25 +00:00
2011-07-24 15:22:21 +00:00
gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT ( cb ) , AIRPCAP_DECRYPTION_TYPE_STRING_NONE ) ;
gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT ( cb ) , AIRPCAP_DECRYPTION_TYPE_STRING_WIRESHARK ) ;
2011-05-15 02:45:18 +00:00
2007-05-18 21:06:20 +00:00
if ( airpcap_if_list ! = NULL & & g_list_length ( airpcap_if_list ) > 0 )
2007-01-26 06:34:05 +00:00
{
2011-07-24 15:22:21 +00:00
gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT ( cb ) , AIRPCAP_DECRYPTION_TYPE_STRING_AIRPCAP ) ;
2007-01-26 06:34:05 +00:00
}
else
{
/* The last decryption mode was 'Driver', but no more AirPcap adapter are found */
2011-05-15 02:45:18 +00:00
if ( current_text = = NULL | | g_ascii_strcasecmp ( current_text , AIRPCAP_DECRYPTION_TYPE_STRING_AIRPCAP ) = = 0 )
2007-01-26 06:34:05 +00:00
{
2009-05-13 16:14:28 +00:00
g_free ( current_text ) ;
2007-01-26 06:34:05 +00:00
current_text = g_strdup ( AIRPCAP_DECRYPTION_TYPE_STRING_NONE ) ;
}
}
2006-12-05 19:24:25 +00:00
2009-05-13 16:14:28 +00:00
if ( g_ascii_strcasecmp ( current_text , AIRPCAP_DECRYPTION_TYPE_STRING_WIRESHARK ) = = 0 ) {
gtk_combo_box_set_active ( GTK_COMBO_BOX ( cb ) , 1 ) ;
} else if ( g_ascii_strcasecmp ( current_text , AIRPCAP_DECRYPTION_TYPE_STRING_AIRPCAP ) = = 0 ) {
gtk_combo_box_set_active ( GTK_COMBO_BOX ( cb ) , 2 ) ;
} else { /* None / Invalid */
gtk_combo_box_set_active ( GTK_COMBO_BOX ( cb ) , 0 ) ;
}
2006-12-05 19:24:25 +00:00
2009-05-13 16:14:28 +00:00
g_free ( current_text ) ;
2006-12-05 19:24:25 +00:00
}
2011-02-10 17:09:36 +00:00
/*
* Callback for the Wireless Advanced Settings ' Apply ' button .
*/
static void
on_advanced_apply_bt_clicked ( GtkWidget * button _U_ , gpointer data )
{
/* advenced window */
GtkWidget * airpcap_advanced_w ;
GtkWidget * channel_cb , * channel_offset_cb ;
/* widgets in the toolbar */
GtkWidget * toolbar ,
* toolbar_if_lb ,
* toolbar_channel_cb ,
* toolbar_channel_offset_cb ,
* toolbar_fcs_filter_cb ;
/* retrieve main window */
airpcap_advanced_w = GTK_WIDGET ( data ) ;
2011-05-15 02:45:18 +00:00
2011-02-10 17:09:36 +00:00
/* Set the channel and offset */
channel_cb = GTK_WIDGET ( g_object_get_data ( G_OBJECT ( airpcap_advanced_w ) , AIRPCAP_ADVANCED_CHANNEL_KEY ) ) ;
channel_offset_cb = GTK_WIDGET ( g_object_get_data ( G_OBJECT ( airpcap_advanced_w ) , AIRPCAP_ADVANCED_CHANNEL_OFFSET_KEY ) ) ;
airpcap_channel_offset_changed_cb ( channel_offset_cb , NULL ) ;
airpcap_channel_changed_set_cb ( channel_cb , channel_offset_cb ) ;
toolbar = GTK_WIDGET ( g_object_get_data ( G_OBJECT ( airpcap_advanced_w ) , AIRPCAP_TOOLBAR_KEY ) ) ;
/* retrieve toolbar info */
toolbar_if_lb = GTK_WIDGET ( g_object_get_data ( G_OBJECT ( toolbar ) , AIRPCAP_TOOLBAR_INTERFACE_KEY ) ) ;
toolbar_channel_cb = GTK_WIDGET ( g_object_get_data ( G_OBJECT ( toolbar ) , AIRPCAP_TOOLBAR_CHANNEL_KEY ) ) ;
toolbar_channel_offset_cb = GTK_WIDGET ( g_object_get_data ( G_OBJECT ( toolbar ) , AIRPCAP_TOOLBAR_CHANNEL_OFFSET_KEY ) ) ;
toolbar_fcs_filter_cb = GTK_WIDGET ( g_object_get_data ( G_OBJECT ( toolbar ) , AIRPCAP_TOOLBAR_FCS_FILTER_KEY ) ) ;
/* Save the configuration (for all ) */
airpcap_save_selected_if_configuration ( airpcap_if_selected ) ;
/* Update toolbar (only if airpcap_if_selected is airpcap_if_active)*/
if ( g_ascii_strcasecmp ( airpcap_if_selected - > description , airpcap_if_active - > description ) = = 0 )
{
gtk_label_set_text ( GTK_LABEL ( toolbar_if_lb ) , g_strdup_printf ( " %s %s \t " , " Current Wireless Interface: # " , airpcap_get_if_string_number ( airpcap_if_selected ) ) ) ;
airpcap_update_channel_combo ( GTK_WIDGET ( toolbar_channel_cb ) , airpcap_if_selected ) ;
airpcap_update_channel_offset_combo ( airpcap_if_selected , airpcap_if_selected - > channelInfo . Frequency , toolbar_channel_offset_cb , TRUE ) ;
airpcap_validation_type_combo_set_by_type ( toolbar_fcs_filter_cb , airpcap_if_selected - > CrcValidationOn ) ;
}
}
/*
* Callback for the OK button ' clicked ' in the Advanced Wireless Settings window .
*/
static void
on_advanced_ok_bt_clicked ( GtkWidget * button _U_ , gpointer data )
{
PAirpcapHandle ad = NULL ;
gchar ebuf [ AIRPCAP_ERRBUF_SIZE ] ;
/* Retrieve object data */
GtkWidget * airpcap_advanced_w = GTK_WIDGET ( data ) ;
if ( airpcap_if_selected = = NULL ) { /* There's not much we can do. */
gtk_widget_destroy ( airpcap_advanced_w ) ;
return ;
}
on_advanced_apply_bt_clicked ( button , data ) ;
/* Stop blinking our LED */
ad = airpcap_if_open ( airpcap_if_selected - > name , ebuf ) ;
if ( ad )
{
g_source_remove ( airpcap_if_selected - > tag ) ;
airpcap_if_turn_led_on ( ad , 0 ) ;
airpcap_if_selected - > blinking = FALSE ;
airpcap_if_selected - > led = TRUE ;
airpcap_if_close ( ad ) ;
}
/* Remove GLIB timeout */
g_source_remove ( airpcap_if_selected - > tag ) ;
gtk_widget_destroy ( airpcap_advanced_w ) ;
}
/*
* Callback for the CANCEL button ' clicked ' in the Advanced Wireless Settings window .
*/
static void
on_advanced_cancel_bt_clicked ( GtkWidget * button _U_ , gpointer data )
{
PAirpcapHandle ad = NULL ;
gchar ebuf [ AIRPCAP_ERRBUF_SIZE ] ;
/* Retrieve object data */
GtkWidget * airpcap_advanced_w ;
/* Retrieve the GUI object pointers */
airpcap_advanced_w = GTK_WIDGET ( data ) ;
/* Stop blinking ALL leds (go through the airpcap_if_list) */
if ( airpcap_if_selected ! = NULL )
{
ad = airpcap_if_open ( airpcap_if_selected - > name , ebuf ) ;
if ( ad )
{
g_source_remove ( airpcap_if_selected - > tag ) ;
airpcap_if_turn_led_on ( ad , 0 ) ;
airpcap_if_selected - > blinking = FALSE ;
airpcap_if_selected - > led = TRUE ;
airpcap_if_close ( ad ) ;
}
2012-09-01 23:13:03 +00:00
/* reload the configuration!!! Configuration has not been saved but
the corresponding structure has been modified probably . . . */
if ( ! airpcap_if_selected - > saved )
{
airpcap_load_selected_if_configuration ( airpcap_if_selected ) ;
}
2011-02-10 17:09:36 +00:00
}
gtk_widget_destroy ( airpcap_advanced_w ) ;
}
2006-08-16 18:01:25 +00:00
/* Called to create the airpcap settings' window */
void
2009-05-13 10:29:42 +00:00
display_airpcap_advanced_cb ( GtkWidget * w _U_ , gpointer data )
2006-08-16 18:01:25 +00:00
{
2007-01-26 06:34:05 +00:00
GtkWidget * airpcap_advanced_w ;
GtkWidget * main_box ;
GtkWidget * settings_sub_box ;
GtkWidget * interface_fr ;
GtkWidget * interface_al ;
GtkWidget * interface_sub_h_box ;
GtkWidget * interface_name_lb ;
GtkWidget * blink_bt ;
GtkWidget * interface_frame_lb ;
GtkWidget * basic_parameters_fr ;
GtkWidget * basic_parameters_al ;
2013-01-09 19:10:47 +00:00
GtkWidget * basic_parameters_grid ;
2007-01-26 06:34:05 +00:00
GtkWidget * channel_lb ;
2007-05-18 21:06:20 +00:00
GtkWidget * channel_offset_lb ;
2007-01-26 06:34:05 +00:00
GtkWidget * capture_type_lb ;
2009-05-13 16:14:28 +00:00
GtkWidget * channel_cb ;
2007-05-18 21:06:20 +00:00
GtkWidget * channel_offset_cb ;
2009-05-13 16:14:28 +00:00
GtkWidget * capture_type_cb ;
2007-01-26 06:34:05 +00:00
GtkWidget * fcs_ck ;
GtkWidget * basic_parameters_fcs_h_box ;
GtkWidget * basic_parameters_fcs_filter_lb ;
2009-05-13 16:14:28 +00:00
GtkWidget * fcs_filter_cb ;
2007-01-26 06:34:05 +00:00
GtkWidget * basic_parameters_frame_lb ;
GtkWidget * low_buttons_h_box ;
GtkWidget * left_h_button_box ;
GtkWidget * right_h_button_box ;
GtkWidget * ok_bt ;
GtkWidget * apply_bt ;
GtkWidget * cancel_bt ;
/* widgets in the toolbar */
2012-03-30 01:46:42 +00:00
GtkWidget * toolbar ;
2007-01-26 06:34:05 +00:00
/* user data - RETRIEVE pointers of toolbar widgets */
2010-11-28 00:00:58 +00:00
toolbar = GTK_WIDGET ( data ) ;
2007-01-26 06:34:05 +00:00
/* gray out the toolbar */
gtk_widget_set_sensitive ( toolbar , FALSE ) ;
/* main window */
/* global */
/* the selected is the active, for now */
airpcap_if_selected = airpcap_if_active ;
/* Create the new window */
2010-11-28 00:00:58 +00:00
airpcap_advanced_w = dlg_window_new ( " Advanced Wireless Settings " ) ; /* transient_for top_level */
2013-03-22 17:31:15 +00:00
gtk_window_set_modal ( GTK_WINDOW ( airpcap_advanced_w ) , TRUE ) ;
gtk_window_set_transient_for ( GTK_WINDOW ( airpcap_advanced_w ) , GTK_WINDOW ( gtk_widget_get_toplevel ( w ) ) ) ;
2010-11-28 00:00:58 +00:00
gtk_window_set_destroy_with_parent ( GTK_WINDOW ( airpcap_advanced_w ) , TRUE ) ;
2007-01-26 06:34:05 +00:00
gtk_container_set_border_width ( GTK_CONTAINER ( airpcap_advanced_w ) , 5 ) ;
gtk_window_set_position ( GTK_WINDOW ( airpcap_advanced_w ) ,
GTK_WIN_POS_CENTER ) ;
gtk_window_set_resizable ( GTK_WINDOW ( airpcap_advanced_w ) , FALSE ) ;
gtk_window_set_type_hint ( GTK_WINDOW ( airpcap_advanced_w ) , GDK_WINDOW_TYPE_HINT_DIALOG ) ;
2006-12-05 19:24:25 +00:00
2012-06-02 23:53:04 +00:00
main_box = ws_gtk_box_new ( GTK_ORIENTATION_VERTICAL , 0 , FALSE ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( main_box , " main_box " ) ;
gtk_widget_show ( main_box ) ;
gtk_container_add ( GTK_CONTAINER ( airpcap_advanced_w ) , main_box ) ;
2012-06-02 23:53:04 +00:00
settings_sub_box = ws_gtk_box_new ( GTK_ORIENTATION_VERTICAL , 0 , FALSE ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( settings_sub_box , " settings_sub_box " ) ;
gtk_widget_show ( settings_sub_box ) ;
gtk_box_pack_start ( GTK_BOX ( main_box ) , settings_sub_box , FALSE , TRUE , 0 ) ;
interface_fr = gtk_frame_new ( NULL ) ;
gtk_widget_set_name ( interface_fr , " interface_fr " ) ;
gtk_widget_show ( interface_fr ) ;
gtk_box_pack_start ( GTK_BOX ( settings_sub_box ) , interface_fr , FALSE , FALSE ,
0 ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( interface_fr ) , 10 ) ;
2012-12-26 05:57:06 +00:00
interface_al = gtk_alignment_new ( 0.5f , 0.5f , 1 , 1 ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( interface_al , " interface_al " ) ;
gtk_widget_show ( interface_al ) ;
gtk_container_add ( GTK_CONTAINER ( interface_fr ) , interface_al ) ;
gtk_alignment_set_padding ( GTK_ALIGNMENT ( interface_al ) , 5 , 5 , 0 , 0 ) ;
2006-10-19 00:48:03 +00:00
2012-06-02 23:53:04 +00:00
interface_sub_h_box = ws_gtk_box_new ( GTK_ORIENTATION_HORIZONTAL , 0 , FALSE ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( interface_sub_h_box , " interface_sub_h_box " ) ;
gtk_widget_show ( interface_sub_h_box ) ;
gtk_container_add ( GTK_CONTAINER ( interface_al ) , interface_sub_h_box ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( interface_sub_h_box ) , 5 ) ;
/* Fill the interface_box */
if ( airpcap_if_active ! = NULL )
{
interface_name_lb = gtk_label_new ( airpcap_if_active - > description ) ;
}
else
{
2013-02-21 01:00:44 +00:00
interface_name_lb = gtk_label_new ( " Couldn't find an airpcap interface. " ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_sensitive ( main_box , FALSE ) ;
}
gtk_widget_set_name ( interface_name_lb , " interface_name_lb " ) ;
gtk_widget_show ( interface_name_lb ) ;
gtk_box_pack_start ( GTK_BOX ( interface_sub_h_box ) , interface_name_lb , TRUE ,
FALSE , 0 ) ;
/* If it is NOT the 'Any' Interface */
if ( ! airpcap_if_is_any ( airpcap_if_selected ) )
{
blink_bt = gtk_button_new_with_mnemonic ( " Blink Led " ) ;
}
else /* It is the any interface, so it doesn't make sense to have 'Blink' button... */
{
blink_bt = gtk_button_new_with_mnemonic ( " What's This? " ) ;
}
gtk_widget_set_name ( blink_bt , " blink_bt " ) ;
gtk_widget_show ( blink_bt ) ;
gtk_box_pack_end ( GTK_BOX ( interface_sub_h_box ) , blink_bt , FALSE , FALSE , 0 ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
interface_frame_lb = gtk_label_new ( " <b>Interface</b> " ) ;
gtk_widget_set_name ( interface_frame_lb , " interface_frame_lb " ) ;
gtk_widget_show ( interface_frame_lb ) ;
gtk_frame_set_label_widget ( GTK_FRAME ( interface_fr ) , interface_frame_lb ) ;
gtk_label_set_use_markup ( GTK_LABEL ( interface_frame_lb ) , TRUE ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
basic_parameters_fr = gtk_frame_new ( NULL ) ;
gtk_widget_set_name ( basic_parameters_fr , " basic_parameters_fr " ) ;
gtk_widget_show ( basic_parameters_fr ) ;
gtk_box_pack_start ( GTK_BOX ( settings_sub_box ) , basic_parameters_fr , TRUE , FALSE , 0 ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( basic_parameters_fr ) , 10 ) ;
2006-10-19 00:48:03 +00:00
2012-12-26 05:57:06 +00:00
basic_parameters_al = gtk_alignment_new ( 0.5f , 0.5f , 1 , 1 ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( basic_parameters_al , " basic_parameters_al " ) ;
gtk_widget_show ( basic_parameters_al ) ;
gtk_container_add ( GTK_CONTAINER ( basic_parameters_fr ) , basic_parameters_al ) ;
gtk_alignment_set_padding ( GTK_ALIGNMENT ( basic_parameters_al ) , 10 , 10 , 0 , 0 ) ;
2006-08-16 18:01:25 +00:00
2013-01-09 19:10:47 +00:00
basic_parameters_grid = ws_gtk_grid_new ( ) ;
gtk_widget_set_name ( basic_parameters_grid , " basic_parameters_grid " ) ;
gtk_widget_show ( basic_parameters_grid ) ;
2007-01-26 06:34:05 +00:00
gtk_container_add ( GTK_CONTAINER ( basic_parameters_al ) ,
2013-01-09 19:10:47 +00:00
basic_parameters_grid ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( basic_parameters_grid ) , 5 ) ;
2013-03-04 17:15:48 +00:00
ws_gtk_grid_set_column_spacing ( GTK_GRID ( basic_parameters_grid ) , 20 ) ;
2007-01-26 06:34:05 +00:00
channel_lb = gtk_label_new ( " Channel: " ) ;
gtk_widget_set_name ( channel_lb , " channel_lb " ) ;
gtk_widget_show ( channel_lb ) ;
2013-03-22 17:31:32 +00:00
ws_gtk_grid_attach_extended ( GTK_GRID ( basic_parameters_grid ) , channel_lb , 0 , 0 , 1 , 1 ,
2007-01-26 06:34:05 +00:00
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
2012-12-26 05:57:06 +00:00
gtk_misc_set_alignment ( GTK_MISC ( channel_lb ) , 0 , 0.5f ) ;
2007-01-26 06:34:05 +00:00
capture_type_lb = gtk_label_new ( " Capture Type: " ) ;
gtk_widget_set_name ( capture_type_lb , " capture_type_lb " ) ;
gtk_widget_show ( capture_type_lb ) ;
2013-03-22 17:31:32 +00:00
ws_gtk_grid_attach_extended ( GTK_GRID ( basic_parameters_grid ) , capture_type_lb , 0 , 2 , 1 ,
1 , ( GtkAttachOptions ) ( GTK_FILL ) , ( GtkAttachOptions ) ( 0 ) ,
2007-01-26 06:34:05 +00:00
0 , 0 ) ;
2012-12-26 05:57:06 +00:00
gtk_misc_set_alignment ( GTK_MISC ( capture_type_lb ) , 0 , 0.5f ) ;
2007-01-26 06:34:05 +00:00
2007-08-17 19:34:14 +00:00
/* Start: Channel offset label */
channel_offset_lb = gtk_label_new ( " Channel Offset: " ) ;
2007-05-18 21:06:20 +00:00
gtk_widget_set_name ( channel_offset_lb , " channel_offset_lb " ) ;
gtk_widget_show ( channel_offset_lb ) ;
2013-03-22 17:31:32 +00:00
ws_gtk_grid_attach_extended ( GTK_GRID ( basic_parameters_grid ) , channel_offset_lb , 0 , 1 , 1 , 1 ,
2007-05-18 21:06:20 +00:00
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
2012-12-26 05:57:06 +00:00
gtk_misc_set_alignment ( GTK_MISC ( channel_offset_lb ) , 0 , 0.5f ) ;
2007-08-17 19:34:14 +00:00
/* End: Channel offset label */
2007-05-18 21:06:20 +00:00
2007-08-17 19:34:14 +00:00
/* Start: Channel offset combo box */
2011-07-24 15:22:21 +00:00
channel_offset_cb = gtk_combo_box_text_new ( ) ;
2007-08-17 19:34:14 +00:00
gtk_widget_set_name ( channel_offset_cb , " channel_offset_cb " ) ;
2007-05-18 21:06:20 +00:00
2009-06-29 23:08:05 +00:00
airpcap_update_channel_offset_combo ( airpcap_if_selected , airpcap_if_selected - > channelInfo . Frequency , channel_offset_cb , FALSE ) ;
2007-05-18 21:06:20 +00:00
2007-08-17 19:34:14 +00:00
gtk_widget_show ( channel_offset_cb ) ;
2007-05-18 21:06:20 +00:00
2013-03-22 17:31:32 +00:00
ws_gtk_grid_attach_extended ( GTK_GRID ( basic_parameters_grid ) , channel_offset_cb , 1 , 1 , 1 , 1 ,
2007-08-17 19:34:14 +00:00
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
/* End: Channel offset combo box */
2007-05-18 21:06:20 +00:00
2011-07-24 15:22:21 +00:00
channel_cb = gtk_combo_box_text_new ( ) ;
2009-05-13 16:14:28 +00:00
gtk_widget_set_name ( channel_cb , " channel_cb " ) ;
gtk_widget_show ( channel_cb ) ;
2013-03-22 17:31:32 +00:00
ws_gtk_grid_attach_extended ( GTK_GRID ( basic_parameters_grid ) , channel_cb , 1 , 0 , 1 , 1 ,
2007-01-26 06:34:05 +00:00
( GtkAttachOptions ) ( GTK_EXPAND | GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
2007-05-18 21:06:20 +00:00
2009-05-13 16:14:28 +00:00
/* Select the current channel */
airpcap_update_channel_combo ( GTK_WIDGET ( channel_cb ) , airpcap_if_selected ) ;
2007-01-26 06:34:05 +00:00
2011-07-24 15:22:21 +00:00
capture_type_cb = gtk_combo_box_text_new ( ) ;
gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT ( capture_type_cb ) , AIRPCAP_LINK_TYPE_NAME_802_11_ONLY ) ;
gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT ( capture_type_cb ) , AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_RADIO ) ;
2009-05-13 16:14:28 +00:00
if ( airpcap_get_dll_state ( ) = = AIRPCAP_DLL_OK ) {
2011-07-24 15:22:21 +00:00
gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT ( capture_type_cb ) , AIRPCAP_LINK_TYPE_NAME_802_11_PLUS_PPI ) ;
2007-01-26 06:34:05 +00:00
}
2009-05-13 16:14:28 +00:00
gtk_widget_set_name ( capture_type_cb , " capture_type_cb " ) ;
gtk_widget_show ( capture_type_cb ) ;
2013-03-22 17:31:32 +00:00
ws_gtk_grid_attach_extended ( GTK_GRID ( basic_parameters_grid ) , capture_type_cb , 1 , 2 , 1 ,
1 , ( GtkAttachOptions ) ( GTK_EXPAND | GTK_FILL ) ,
2007-01-26 06:34:05 +00:00
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
/* Current interface value */
if ( airpcap_if_selected ! = NULL )
{
2010-11-28 00:00:58 +00:00
if ( airpcap_if_selected - > linkType = = AIRPCAP_LT_802_11_PLUS_RADIO ) {
2009-05-13 16:14:28 +00:00
gtk_combo_box_set_active ( GTK_COMBO_BOX ( capture_type_cb ) , AIRPCAP_LINK_TYPE_NUM_802_11_PLUS_RADIO ) ;
2010-11-28 00:00:58 +00:00
} else if ( airpcap_if_selected - > linkType = = AIRPCAP_LT_802_11_PLUS_PPI ) {
2009-05-13 16:14:28 +00:00
gtk_combo_box_set_active ( GTK_COMBO_BOX ( capture_type_cb ) , AIRPCAP_LINK_TYPE_NUM_802_11_PLUS_PPI ) ;
2010-11-28 00:00:58 +00:00
} else {
2009-05-13 16:14:28 +00:00
gtk_combo_box_set_active ( GTK_COMBO_BOX ( capture_type_cb ) , AIRPCAP_LINK_TYPE_NUM_802_11_ONLY ) ;
2010-11-28 00:00:58 +00:00
}
2007-01-26 06:34:05 +00:00
}
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
fcs_ck = gtk_check_button_new_with_label ( " Include 802.11 FCS in Frames " ) ;
2008-04-07 03:46:01 +00:00
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( fcs_ck , " fcs_ck " ) ;
/* Fcs Presence check box */
if ( airpcap_if_selected ! = NULL )
{
if ( airpcap_if_selected - > IsFcsPresent )
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( fcs_ck ) , TRUE ) ;
else
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( fcs_ck ) , FALSE ) ;
}
gtk_widget_show ( fcs_ck ) ;
2013-03-22 17:31:32 +00:00
ws_gtk_grid_attach_extended ( GTK_GRID ( basic_parameters_grid ) , fcs_ck , 3 , 0 , 2 , 1 ,
2007-01-26 06:34:05 +00:00
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
2012-06-02 23:53:04 +00:00
basic_parameters_fcs_h_box = ws_gtk_box_new ( GTK_ORIENTATION_HORIZONTAL , 1 , FALSE ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( basic_parameters_fcs_h_box ,
" basic_parameters_fcs_h_box " ) ;
gtk_widget_show ( basic_parameters_fcs_h_box ) ;
2013-01-09 19:10:47 +00:00
ws_gtk_grid_attach_extended ( GTK_GRID ( basic_parameters_grid ) ,
2013-03-22 17:31:32 +00:00
basic_parameters_fcs_h_box , 3 , 2 , 2 , 1 ,
2007-01-26 06:34:05 +00:00
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( GTK_FILL ) , 3 , 0 ) ;
basic_parameters_fcs_filter_lb = gtk_label_new ( " FCS Filter: " ) ;
gtk_widget_set_name ( basic_parameters_fcs_filter_lb ,
" basic_parameters_fcs_filter_lb " ) ;
gtk_widget_show ( basic_parameters_fcs_filter_lb ) ;
gtk_box_pack_start ( GTK_BOX ( basic_parameters_fcs_h_box ) ,
basic_parameters_fcs_filter_lb , FALSE , FALSE , 0 ) ;
2011-07-24 15:22:21 +00:00
fcs_filter_cb = gtk_combo_box_text_new ( ) ;
gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT ( fcs_filter_cb ) , airpcap_get_validation_name ( AIRPCAP_VT_ACCEPT_EVERYTHING ) ) ;
gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT ( fcs_filter_cb ) , airpcap_get_validation_name ( AIRPCAP_VT_ACCEPT_CORRECT_FRAMES ) ) ;
gtk_combo_box_text_append_text ( GTK_COMBO_BOX_TEXT ( fcs_filter_cb ) , airpcap_get_validation_name ( AIRPCAP_VT_ACCEPT_CORRUPT_FRAMES ) ) ;
2009-05-13 16:14:28 +00:00
gtk_combo_box_set_active ( GTK_COMBO_BOX ( fcs_filter_cb ) , 0 ) ;
gtk_widget_set_name ( fcs_filter_cb , " fcs_filter_cb " ) ;
gtk_widget_show ( fcs_filter_cb ) ;
gtk_box_pack_start ( GTK_BOX ( basic_parameters_fcs_h_box ) , fcs_filter_cb ,
2007-01-26 06:34:05 +00:00
FALSE , FALSE , 0 ) ;
2009-05-13 16:14:28 +00:00
gtk_widget_set_size_request ( fcs_filter_cb , 112 , - 1 ) ;
2007-01-26 06:34:05 +00:00
if ( airpcap_if_selected ! = NULL )
{
2009-05-13 16:14:28 +00:00
airpcap_validation_type_combo_set_by_type ( fcs_filter_cb , airpcap_if_selected - > CrcValidationOn ) ;
2007-01-26 06:34:05 +00:00
}
basic_parameters_frame_lb = gtk_label_new ( " <b>Basic Parameters</b> " ) ;
gtk_widget_set_name ( basic_parameters_frame_lb ,
" basic_parameters_frame_lb " ) ;
gtk_widget_show ( basic_parameters_frame_lb ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
gtk_frame_set_label_widget ( GTK_FRAME ( basic_parameters_fr ) , basic_parameters_frame_lb ) ;
gtk_label_set_use_markup ( GTK_LABEL ( basic_parameters_frame_lb ) , TRUE ) ;
2006-08-16 18:01:25 +00:00
2012-06-02 23:53:04 +00:00
low_buttons_h_box = ws_gtk_box_new ( GTK_ORIENTATION_HORIZONTAL , 0 , FALSE ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( low_buttons_h_box , " low_buttons_h_box " ) ;
gtk_widget_show ( low_buttons_h_box ) ;
gtk_box_pack_end ( GTK_BOX ( main_box ) , low_buttons_h_box , FALSE , FALSE , 0 ) ;
2006-10-19 00:48:03 +00:00
2012-06-02 23:53:04 +00:00
left_h_button_box = gtk_button_box_new ( GTK_ORIENTATION_HORIZONTAL ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( left_h_button_box , " left_h_button_box " ) ;
gtk_widget_show ( left_h_button_box ) ;
gtk_box_pack_start ( GTK_BOX ( low_buttons_h_box ) , left_h_button_box , FALSE ,
FALSE , 0 ) ;
2006-10-19 00:48:03 +00:00
2013-03-04 17:15:48 +00:00
/* dlg_button_row_new() returns an (h)box */
2007-01-26 06:34:05 +00:00
right_h_button_box = dlg_button_row_new ( GTK_STOCK_OK , GTK_STOCK_APPLY , GTK_STOCK_CANCEL , NULL ) ;
gtk_widget_show ( right_h_button_box ) ;
gtk_box_pack_end ( GTK_BOX ( low_buttons_h_box ) , right_h_button_box , FALSE ,
FALSE , 0 ) ;
2013-03-21 02:29:09 +00:00
ok_bt = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( right_h_button_box ) , GTK_STOCK_OK ) ;
apply_bt = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( right_h_button_box ) , GTK_STOCK_APPLY ) ;
cancel_bt = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( right_h_button_box ) , GTK_STOCK_CANCEL ) ;
2007-01-26 06:34:05 +00:00
/* Connect the callbacks */
2010-08-17 13:59:15 +00:00
g_signal_connect ( airpcap_advanced_w , " delete_event " , G_CALLBACK ( window_delete_event_cb ) , NULL ) ;
2008-04-09 05:37:53 +00:00
g_signal_connect ( airpcap_advanced_w , " destroy " , G_CALLBACK ( on_airpcap_advanced_destroy ) , airpcap_advanced_w ) ;
2007-01-26 06:34:05 +00:00
if ( ! airpcap_if_is_any ( airpcap_if_selected ) )
{
2010-08-23 19:29:08 +00:00
g_signal_connect ( blink_bt , " clicked " , G_CALLBACK ( on_blink_bt_clicked ) , NULL ) ;
2007-01-26 06:34:05 +00:00
}
else
{
2010-08-23 19:29:08 +00:00
g_signal_connect ( blink_bt , " clicked " , G_CALLBACK ( on_what_s_this_bt_clicked ) , NULL ) ;
2007-01-26 06:34:05 +00:00
}
2006-08-16 18:01:25 +00:00
2009-06-29 23:08:05 +00:00
g_signal_connect ( channel_cb , " changed " , G_CALLBACK ( airpcap_channel_changed_noset_cb ) , channel_offset_cb ) ;
/* We don't attach the channel offset combo because we don't want it changing anything yet. */
2010-08-23 19:29:08 +00:00
g_signal_connect ( capture_type_cb , " changed " , G_CALLBACK ( on_capture_type_cb_changed ) , NULL ) ;
g_signal_connect ( fcs_ck , " toggled " , G_CALLBACK ( on_fcs_ck_toggled ) , NULL ) ;
2009-05-13 16:14:28 +00:00
g_signal_connect ( fcs_filter_cb , " changed " , G_CALLBACK ( on_fcs_filter_cb_changed ) , NULL ) ;
2008-04-09 05:37:53 +00:00
g_signal_connect ( apply_bt , " clicked " , G_CALLBACK ( on_advanced_apply_bt_clicked ) , airpcap_advanced_w ) ;
g_signal_connect ( ok_bt , " clicked " , G_CALLBACK ( on_advanced_ok_bt_clicked ) , airpcap_advanced_w ) ;
g_signal_connect ( cancel_bt , " clicked " , G_CALLBACK ( on_advanced_cancel_bt_clicked ) , airpcap_advanced_w ) ;
2007-01-26 06:34:05 +00:00
/* Different because the window will be closed ... */
/*window_set_cancel_button(airpcap_advanced_w, ok_bt, window_cancel_button_cb);
window_set_cancel_button ( airpcap_advanced_w , cancel_bt , window_cancel_button_cb ) ; */
/* Store pointers to all widgets, for use by lookup_widget(). */
2008-04-09 20:55:33 +00:00
g_object_set_data ( G_OBJECT ( airpcap_advanced_w ) , AIRPCAP_ADVANCED_BLINK_KEY , blink_bt ) ;
2009-05-13 16:14:28 +00:00
g_object_set_data ( G_OBJECT ( airpcap_advanced_w ) , AIRPCAP_ADVANCED_CHANNEL_KEY , channel_cb ) ;
2009-06-29 23:08:05 +00:00
g_object_set_data ( G_OBJECT ( airpcap_advanced_w ) , AIRPCAP_ADVANCED_CHANNEL_OFFSET_KEY , channel_offset_cb ) ;
2009-05-13 16:14:28 +00:00
g_object_set_data ( G_OBJECT ( airpcap_advanced_w ) , AIRPCAP_ADVANCED_LINK_TYPE_KEY , capture_type_cb ) ;
2008-04-09 20:55:33 +00:00
g_object_set_data ( G_OBJECT ( airpcap_advanced_w ) , AIRPCAP_ADVANCED_FCS_CHECK_KEY , fcs_ck ) ;
2009-05-13 16:14:28 +00:00
g_object_set_data ( G_OBJECT ( airpcap_advanced_w ) , AIRPCAP_ADVANCED_FCS_FILTER_KEY , fcs_filter_cb ) ;
2008-04-09 20:55:33 +00:00
g_object_set_data ( G_OBJECT ( airpcap_advanced_w ) , AIRPCAP_ADVANCED_OK_KEY , ok_bt ) ;
g_object_set_data ( G_OBJECT ( airpcap_advanced_w ) , AIRPCAP_ADVANCED_CANCEL_KEY , cancel_bt ) ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
/*
* I will need the toolbar and the main widget in some callback ,
* so I will add the toolbar pointer to the airpcap_advanced_w
*/
2008-04-09 20:55:33 +00:00
g_object_set_data ( G_OBJECT ( airpcap_advanced_w ) , AIRPCAP_TOOLBAR_KEY , toolbar ) ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
/* At the end, so that it appears completely all together ... */
gtk_widget_show ( airpcap_advanced_w ) ;
2006-10-19 00:48:03 +00:00
}
2006-08-16 18:01:25 +00:00
2006-10-19 00:48:03 +00:00
/*
2011-02-10 17:09:36 +00:00
* Callback for the OK button ' clicked ' in the Decryption Key Management window .
2006-10-19 00:48:03 +00:00
*/
2011-02-07 20:24:42 +00:00
static void
2011-02-10 17:09:36 +00:00
on_key_management_ok_bt_clicked ( GtkWidget * button , gpointer data )
2006-10-19 00:48:03 +00:00
{
2011-02-10 17:09:36 +00:00
/* advanced window */
GtkWidget * key_management_w ;
2007-01-26 06:34:05 +00:00
2009-05-13 16:14:28 +00:00
/* retrieve main window */
2011-02-10 17:09:36 +00:00
key_management_w = GTK_WIDGET ( data ) ;
2007-01-26 06:34:05 +00:00
2011-02-10 17:09:36 +00:00
/* Apply the current decryption preferences */
on_key_management_apply_bt_clicked ( button , data ) ;
2009-05-13 16:14:28 +00:00
2011-02-10 17:09:36 +00:00
gtk_widget_destroy ( key_management_w ) ;
2009-05-13 16:14:28 +00:00
}
/*
2011-02-10 17:09:36 +00:00
* Callback for the CANCEL button ' clicked ' in the Decryption Key Management window .
2009-05-13 16:14:28 +00:00
*/
2011-02-07 20:24:42 +00:00
static void
2011-02-10 17:09:36 +00:00
on_key_management_cancel_bt_clicked ( GtkWidget * button _U_ , gpointer data )
2009-05-13 16:14:28 +00:00
{
/* Retrieve object data */
2011-02-10 17:09:36 +00:00
GtkWidget * key_management_w ;
2007-01-26 06:34:05 +00:00
/* Retrieve the GUI object pointers */
2011-02-10 17:09:36 +00:00
key_management_w = GTK_WIDGET ( data ) ;
2006-08-16 18:01:25 +00:00
2011-02-10 17:09:36 +00:00
gtk_widget_destroy ( key_management_w ) ;
2006-10-19 00:48:03 +00:00
}
2006-08-16 18:01:25 +00:00
2006-10-19 00:48:03 +00:00
/* Called to create the key management window */
void
2009-05-13 10:29:42 +00:00
display_airpcap_key_management_cb ( GtkWidget * w _U_ , gpointer data )
2006-10-19 00:48:03 +00:00
{
2007-01-26 06:34:05 +00:00
GtkWidget * key_management_w ;
GtkWidget * main_box ;
GtkWidget * keys_fr ;
GtkWidget * keys_al ;
GtkWidget * keys_h_sub_box ;
2013-01-09 21:35:18 +00:00
GtkWidget * decryption_mode_grid ;
2009-05-13 16:14:28 +00:00
GtkWidget * decryption_mode_lb ;
GtkWidget * decryption_mode_cb ;
2007-01-26 06:34:05 +00:00
GtkWidget * keys_v_sub_box ;
GtkWidget * keys_scrolled_w ;
2011-02-07 20:24:42 +00:00
GtkListStore * key_list_store ;
GtkWidget * key_list ;
2007-01-26 06:34:05 +00:00
GtkWidget * key_v_button_box ;
GtkWidget * add_new_key_bt ;
GtkWidget * remove_key_bt ;
GtkWidget * edit_key_bt ;
GtkWidget * move_key_up_bt ;
GtkWidget * move_key_down_bt ;
GtkWidget * keys_frame_lb ;
GtkWidget * low_buttons_h_box ;
GtkWidget * left_h_button_box ;
GtkWidget * right_h_button_box ;
GtkWidget * ok_bt ;
GtkWidget * apply_bt ;
GtkWidget * cancel_bt ;
/* widgets in the toolbar */
2010-11-28 00:00:58 +00:00
GtkWidget * toolbar ,
* toolbar_decryption_ck ;
2007-01-26 06:34:05 +00:00
2011-02-07 20:24:42 +00:00
/* key list */
GtkTreeViewColumn * column ;
GtkCellRenderer * renderer ;
GtkTreeSelection * selection ;
GtkTreeIter iter ;
2007-01-26 06:34:05 +00:00
/* user data - RETRIEVE pointers of toolbar widgets */
2010-11-28 00:00:58 +00:00
toolbar = GTK_WIDGET ( data ) ;
2008-04-09 20:55:33 +00:00
toolbar_decryption_ck = GTK_WIDGET ( g_object_get_data ( G_OBJECT ( toolbar ) , AIRPCAP_TOOLBAR_DECRYPTION_KEY ) ) ;
2007-01-26 06:34:05 +00:00
/* gray out the toolbar */
gtk_widget_set_sensitive ( toolbar , FALSE ) ;
/* main window */
/* global */
/* the selected is the active, for now */
airpcap_if_selected = airpcap_if_active ;
/* Create the new window */
2010-11-28 00:00:58 +00:00
key_management_w = dlg_window_new ( " Decryption Key Management " ) ; /* transient_for top_level */
2013-03-22 17:31:06 +00:00
gtk_window_set_destroy_with_parent ( GTK_WINDOW ( key_management_w ) , TRUE ) ;
gtk_window_set_modal ( GTK_WINDOW ( key_management_w ) , TRUE ) ;
2007-01-26 06:34:05 +00:00
gtk_container_set_border_width ( GTK_CONTAINER ( key_management_w ) , 5 ) ;
gtk_window_set_position ( GTK_WINDOW ( key_management_w ) ,
GTK_WIN_POS_CENTER ) ;
2006-12-05 19:24:25 +00:00
2007-01-26 06:34:05 +00:00
gtk_window_set_resizable ( GTK_WINDOW ( key_management_w ) , FALSE ) ;
gtk_window_set_type_hint ( GTK_WINDOW ( key_management_w ) , GDK_WINDOW_TYPE_HINT_DIALOG ) ;
2006-08-16 18:01:25 +00:00
2012-06-02 23:53:04 +00:00
main_box = ws_gtk_box_new ( GTK_ORIENTATION_VERTICAL , 0 , FALSE ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( main_box , " main_box " ) ;
gtk_widget_show ( main_box ) ;
gtk_container_add ( GTK_CONTAINER ( key_management_w ) , main_box ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
keys_fr = gtk_frame_new ( NULL ) ;
gtk_widget_set_name ( keys_fr , " keys_fr " ) ;
gtk_widget_show ( keys_fr ) ;
gtk_box_pack_start ( GTK_BOX ( main_box ) , keys_fr , FALSE , FALSE , 0 ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( keys_fr ) , 10 ) ;
2006-10-19 00:48:03 +00:00
2012-12-26 05:57:06 +00:00
keys_al = gtk_alignment_new ( 0.5f , 0.5f , 1 , 1 ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( keys_al , " keys_al " ) ;
gtk_widget_show ( keys_al ) ;
gtk_container_add ( GTK_CONTAINER ( keys_fr ) , keys_al ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( keys_al ) , 5 ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
gtk_alignment_set_padding ( GTK_ALIGNMENT ( keys_al ) , 0 , 0 , 12 , 0 ) ;
2006-08-16 18:01:25 +00:00
2012-06-02 23:53:04 +00:00
keys_h_sub_box = ws_gtk_box_new ( GTK_ORIENTATION_VERTICAL , 0 , FALSE ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( keys_h_sub_box , " keys_h_sub_box " ) ;
gtk_widget_show ( keys_h_sub_box ) ;
gtk_container_add ( GTK_CONTAINER ( keys_al ) , keys_h_sub_box ) ;
2013-01-09 21:35:18 +00:00
decryption_mode_grid = ws_gtk_grid_new ( ) ;
gtk_widget_set_name ( decryption_mode_grid , " decryption_mode_grid " ) ;
gtk_widget_show ( decryption_mode_grid ) ;
gtk_box_pack_start ( GTK_BOX ( keys_h_sub_box ) , decryption_mode_grid , FALSE ,
2007-01-26 06:34:05 +00:00
FALSE , 0 ) ;
2013-01-09 21:35:18 +00:00
ws_gtk_grid_set_row_spacing ( GTK_GRID ( decryption_mode_grid ) , 6 ) ;
2007-01-26 06:34:05 +00:00
2009-05-13 16:14:28 +00:00
decryption_mode_lb = gtk_label_new ( " Select Decryption Mode " ) ;
gtk_widget_set_name ( decryption_mode_lb , " decryption_mode_lb " ) ;
gtk_widget_show ( decryption_mode_lb ) ;
2013-01-09 21:35:18 +00:00
ws_gtk_grid_attach_extended ( GTK_GRID ( decryption_mode_grid ) , decryption_mode_lb , 1 ,
2013-03-04 17:15:58 +00:00
0 , 1 , 1 , ( GtkAttachOptions ) ( GTK_FILL ) ,
2007-01-26 06:34:05 +00:00
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
2012-12-26 05:57:06 +00:00
gtk_misc_set_alignment ( GTK_MISC ( decryption_mode_lb ) , 0 , 0.5f ) ;
2007-01-26 06:34:05 +00:00
2011-07-24 15:22:21 +00:00
decryption_mode_cb = gtk_combo_box_text_new ( ) ;
2009-05-13 16:14:28 +00:00
update_decryption_mode_list ( decryption_mode_cb ) ;
gtk_widget_set_name ( decryption_mode_cb , " decryption_mode_cb " ) ;
gtk_widget_show ( decryption_mode_cb ) ;
2013-01-09 21:35:18 +00:00
ws_gtk_grid_attach_extended ( GTK_GRID ( decryption_mode_grid ) , decryption_mode_cb , 0 ,
2013-03-04 17:15:58 +00:00
0 , 1 , 1 , ( GtkAttachOptions ) ( 0 ) , ( GtkAttachOptions ) ( 0 ) ,
2007-01-26 06:34:05 +00:00
0 , 0 ) ;
2009-05-13 16:14:28 +00:00
gtk_widget_set_size_request ( decryption_mode_cb , 83 , - 1 ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
/* Set correct decryption mode!!!! */
2009-05-13 16:14:28 +00:00
update_decryption_mode ( decryption_mode_cb ) ;
2006-10-19 00:48:03 +00:00
2012-06-02 23:53:04 +00:00
keys_v_sub_box = ws_gtk_box_new ( GTK_ORIENTATION_HORIZONTAL , 0 , FALSE ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( keys_v_sub_box , " keys_v_sub_box " ) ;
gtk_widget_show ( keys_v_sub_box ) ;
gtk_box_pack_start ( GTK_BOX ( keys_h_sub_box ) , keys_v_sub_box , TRUE , TRUE , 0 ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
keys_scrolled_w = gtk_scrolled_window_new ( NULL , NULL ) ;
gtk_widget_set_name ( keys_scrolled_w , " keys_scrolled_w " ) ;
gtk_widget_show ( keys_scrolled_w ) ;
gtk_box_pack_start ( GTK_BOX ( keys_v_sub_box ) , keys_scrolled_w , TRUE , TRUE ,
0 ) ;
gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW ( keys_scrolled_w ) , GTK_POLICY_NEVER , GTK_POLICY_AUTOMATIC ) ;
2006-10-19 00:48:03 +00:00
2011-02-07 20:24:42 +00:00
/* Create the store */
key_list_store = gtk_list_store_new ( KL_NUM_COLS ,
G_TYPE_STRING , /* Type */
G_TYPE_STRING /* Key */
, G_TYPE_STRING /* SSID */
) ;
2006-12-05 19:24:25 +00:00
2011-02-07 20:24:42 +00:00
/* Create a view */
key_list = gtk_tree_view_new_with_model ( GTK_TREE_MODEL ( key_list_store ) ) ;
2006-10-19 00:48:03 +00:00
2011-02-07 20:24:42 +00:00
/* Speed up the list display */
gtk_tree_view_set_fixed_height_mode ( GTK_TREE_VIEW ( key_list ) , TRUE ) ;
/* Setup the sortable columns */
gtk_tree_view_set_headers_clickable ( GTK_TREE_VIEW ( key_list ) , FALSE ) ;
/* The view now holds a reference. We can get rid of our own reference */
g_object_unref ( G_OBJECT ( key_list_store ) ) ;
/*
* Create the first column packet , 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 ( " Type " , renderer ,
" text " , KL_COL_TYPE , NULL ) ;
gtk_tree_view_column_set_sort_column_id ( column , KL_COL_TYPE ) ;
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 , 60 ) ;
gtk_tree_view_column_set_fixed_width ( column , 100 ) ;
/* Add the column to the view. */
gtk_tree_view_append_column ( GTK_TREE_VIEW ( key_list ) , column ) ;
/* Key */
renderer = gtk_cell_renderer_text_new ( ) ;
column = gtk_tree_view_column_new_with_attributes ( " Key " , renderer ,
" text " , KL_COL_KEY , NULL ) ;
gtk_tree_view_column_set_sort_column_id ( column , KL_COL_KEY ) ;
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 , 120 ) ;
gtk_tree_view_column_set_fixed_width ( column , 200 ) ;
gtk_tree_view_append_column ( GTK_TREE_VIEW ( key_list ) , column ) ;
2006-10-19 00:48:03 +00:00
2011-02-07 20:24:42 +00:00
/* SSID */
renderer = gtk_cell_renderer_text_new ( ) ;
column = gtk_tree_view_column_new_with_attributes ( " SSID " , renderer ,
" text " , KL_COL_SSID ,
NULL ) ;
gtk_tree_view_column_set_sort_column_id ( column , KL_COL_SSID ) ;
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 , 150 ) ;
gtk_tree_view_append_column ( GTK_TREE_VIEW ( key_list ) , column ) ;
2006-10-19 00:48:03 +00:00
2011-02-07 20:24:42 +00:00
/* Now enable the sorting of each column */
gtk_tree_view_set_rules_hint ( GTK_TREE_VIEW ( key_list ) , TRUE ) ;
gtk_tree_view_set_headers_clickable ( GTK_TREE_VIEW ( key_list ) , TRUE ) ;
/* Setup the selection handler */
selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW ( key_list ) ) ;
gtk_tree_selection_set_mode ( selection , GTK_SELECTION_SINGLE ) ;
gtk_widget_show ( key_list ) ;
gtk_container_add ( GTK_CONTAINER ( keys_scrolled_w ) , key_list ) ;
2006-10-19 00:48:03 +00:00
2012-06-02 23:53:04 +00:00
key_v_button_box = gtk_button_box_new ( GTK_ORIENTATION_VERTICAL ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( key_v_button_box , " key_v_button_box " ) ;
gtk_widget_show ( key_v_button_box ) ;
gtk_box_pack_start ( GTK_BOX ( keys_v_sub_box ) , key_v_button_box , FALSE , TRUE ,
0 ) ;
2008-04-09 05:37:53 +00:00
add_new_key_bt = gtk_button_new_from_stock ( GTK_STOCK_NEW ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( add_new_key_bt , " add_new_key_bt " ) ;
gtk_widget_show ( add_new_key_bt ) ;
gtk_container_add ( GTK_CONTAINER ( key_v_button_box ) , add_new_key_bt ) ;
2011-07-14 00:04:37 +00:00
gtk_widget_set_can_default ( add_new_key_bt , TRUE ) ;
2007-01-26 06:34:05 +00:00
2008-04-09 05:37:53 +00:00
edit_key_bt = gtk_button_new_from_stock ( WIRESHARK_STOCK_EDIT ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( edit_key_bt , " edit_key_bt " ) ;
gtk_widget_show ( edit_key_bt ) ;
gtk_container_add ( GTK_CONTAINER ( key_v_button_box ) , edit_key_bt ) ;
2011-07-14 00:04:37 +00:00
gtk_widget_set_can_default ( edit_key_bt , TRUE ) ;
2007-01-26 06:34:05 +00:00
2008-04-09 05:37:53 +00:00
remove_key_bt = gtk_button_new_from_stock ( GTK_STOCK_DELETE ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( remove_key_bt , " remove_key_bt " ) ;
gtk_widget_show ( remove_key_bt ) ;
gtk_container_add ( GTK_CONTAINER ( key_v_button_box ) , remove_key_bt ) ;
2011-07-14 00:04:37 +00:00
gtk_widget_set_can_default ( remove_key_bt , TRUE ) ;
2007-01-26 06:34:05 +00:00
2008-04-09 05:37:53 +00:00
move_key_up_bt = gtk_button_new_from_stock ( GTK_STOCK_GO_UP ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( move_key_up_bt , " move_key_up_bt " ) ;
gtk_widget_show ( move_key_up_bt ) ;
gtk_container_add ( GTK_CONTAINER ( key_v_button_box ) , move_key_up_bt ) ;
2011-07-14 00:04:37 +00:00
gtk_widget_set_can_default ( move_key_up_bt , TRUE ) ;
2007-01-26 06:34:05 +00:00
2008-04-09 05:37:53 +00:00
move_key_down_bt = gtk_button_new_from_stock ( GTK_STOCK_GO_DOWN ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( move_key_down_bt , " move_key_down_bt " ) ;
gtk_widget_show ( move_key_down_bt ) ;
gtk_container_add ( GTK_CONTAINER ( key_v_button_box ) , move_key_down_bt ) ;
2012-03-28 09:26:47 +00:00
gtk_widget_set_can_default ( move_key_down_bt , TRUE ) ;
2007-01-26 06:34:05 +00:00
keys_frame_lb = gtk_label_new ( " <b>Decryption Keys</b> " ) ;
gtk_widget_set_name ( keys_frame_lb , " keys_frame_lb " ) ;
gtk_widget_show ( keys_frame_lb ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
gtk_frame_set_label_widget ( GTK_FRAME ( keys_fr ) , keys_frame_lb ) ;
gtk_label_set_use_markup ( GTK_LABEL ( keys_frame_lb ) , TRUE ) ;
2006-08-16 18:01:25 +00:00
2012-06-02 23:53:04 +00:00
low_buttons_h_box = ws_gtk_box_new ( GTK_ORIENTATION_HORIZONTAL , 0 , FALSE ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( low_buttons_h_box , " low_buttons_h_box " ) ;
gtk_widget_show ( low_buttons_h_box ) ;
gtk_box_pack_end ( GTK_BOX ( main_box ) , low_buttons_h_box , FALSE , FALSE , 0 ) ;
2006-10-19 00:48:03 +00:00
2012-06-02 23:53:04 +00:00
left_h_button_box = gtk_button_box_new ( GTK_ORIENTATION_HORIZONTAL ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( left_h_button_box , " left_h_button_box " ) ;
gtk_widget_show ( left_h_button_box ) ;
gtk_box_pack_start ( GTK_BOX ( low_buttons_h_box ) , left_h_button_box , FALSE ,
FALSE , 0 ) ;
2006-10-19 00:48:03 +00:00
2013-03-04 17:15:48 +00:00
/* dlg_button_row_new() returns an (h)box */
2007-01-26 06:34:05 +00:00
right_h_button_box = dlg_button_row_new ( GTK_STOCK_OK , GTK_STOCK_APPLY , GTK_STOCK_CANCEL , NULL ) ;
gtk_widget_set_name ( right_h_button_box , " right_h_button_box " ) ;
gtk_widget_show ( right_h_button_box ) ;
gtk_box_pack_end ( GTK_BOX ( low_buttons_h_box ) , right_h_button_box , FALSE ,
FALSE , 0 ) ;
2013-03-21 02:29:09 +00:00
ok_bt = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( right_h_button_box ) , GTK_STOCK_OK ) ;
apply_bt = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( right_h_button_box ) , GTK_STOCK_APPLY ) ;
cancel_bt = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( right_h_button_box ) , GTK_STOCK_CANCEL ) ;
2007-01-26 06:34:05 +00:00
/* Connect the callbacks */
2010-08-17 13:59:15 +00:00
g_signal_connect ( key_management_w , " delete_event " , G_CALLBACK ( window_delete_event_cb ) , NULL ) ;
2008-04-09 05:37:53 +00:00
g_signal_connect ( key_management_w , " destroy " , G_CALLBACK ( on_key_management_destroy ) , key_management_w ) ;
g_signal_connect ( add_new_key_bt , " clicked " , G_CALLBACK ( on_add_new_key_bt_clicked ) , key_management_w ) ;
g_signal_connect ( remove_key_bt , " clicked " , G_CALLBACK ( on_remove_key_bt_clicked ) , key_management_w ) ;
g_signal_connect ( edit_key_bt , " clicked " , G_CALLBACK ( on_edit_key_bt_clicked ) , key_management_w ) ;
2011-02-07 20:24:42 +00:00
g_signal_connect ( move_key_up_bt , " clicked " , G_CALLBACK ( on_move_key_up_bt_clicked ) , key_list ) ;
g_signal_connect ( move_key_down_bt , " clicked " , G_CALLBACK ( on_move_key_down_bt_clicked ) , key_list ) ;
2008-04-09 05:37:53 +00:00
g_signal_connect ( apply_bt , " clicked " , G_CALLBACK ( on_key_management_apply_bt_clicked ) , key_management_w ) ;
g_signal_connect ( ok_bt , " clicked " , G_CALLBACK ( on_key_management_ok_bt_clicked ) , key_management_w ) ;
g_signal_connect ( cancel_bt , " clicked " , G_CALLBACK ( on_key_management_cancel_bt_clicked ) , key_management_w ) ;
2011-02-07 20:24:42 +00:00
g_signal_connect ( selection , " changed " , G_CALLBACK ( on_key_list_select_row ) , key_management_w ) ;
g_signal_connect ( key_list_store , " rows_reordered " , G_CALLBACK ( on_key_list_reorder ) , key_management_w ) ;
2007-01-26 06:34:05 +00:00
/* Different because the window will be closed ... */
/*window_set_cancel_button(key_management_w, ok_bt, window_cancel_button_cb);
window_set_cancel_button ( key_management_w , cancel_bt , window_cancel_button_cb ) ; */
2011-02-07 20:24:42 +00:00
g_object_set_data ( G_OBJECT ( key_management_w ) , AIRPCAP_ADVANCED_EDIT_KEY_SELECTION_KEY , selection ) ;
2007-01-26 06:34:05 +00:00
/* Store pointers to all widgets, for use by lookup_widget(). */
2009-05-13 16:14:28 +00:00
g_object_set_data ( G_OBJECT ( key_management_w ) , AIRPCAP_ADVANCED_DECRYPTION_MODE_KEY , decryption_mode_cb ) ;
2011-02-07 20:24:42 +00:00
g_object_set_data ( G_OBJECT ( key_management_w ) , AIRPCAP_ADVANCED_KEYLIST_KEY , key_list_store ) ;
2008-04-09 20:55:33 +00:00
g_object_set_data ( G_OBJECT ( key_management_w ) , AIRPCAP_ADVANCED_OK_KEY , ok_bt ) ;
g_object_set_data ( G_OBJECT ( key_management_w ) , AIRPCAP_ADVANCED_CANCEL_KEY , cancel_bt ) ;
2006-08-16 18:01:25 +00:00
2011-02-07 20:24:42 +00:00
/* Enable / disable buttons */
g_object_set_data ( G_OBJECT ( key_management_w ) , AIRPCAP_KEY_MGMT_NEW_KEY , add_new_key_bt ) ;
g_object_set_data ( G_OBJECT ( key_management_w ) , AIRPCAP_KEY_MGMT_EDIT_KEY , edit_key_bt ) ;
g_object_set_data ( G_OBJECT ( key_management_w ) , AIRPCAP_KEY_MGMT_DELETE_KEY , remove_key_bt ) ;
g_object_set_data ( G_OBJECT ( key_management_w ) , AIRPCAP_KEY_MGMT_UP_KEY , move_key_up_bt ) ;
g_object_set_data ( G_OBJECT ( key_management_w ) , AIRPCAP_KEY_MGMT_DOWN_KEY , move_key_down_bt ) ;
2007-01-26 06:34:05 +00:00
/*
* I will need the toolbar and the main widget in some callback ,
* so I will add the toolbar pointer to the key_management_w
*/
2008-04-09 20:55:33 +00:00
g_object_set_data ( G_OBJECT ( key_management_w ) , AIRPCAP_TOOLBAR_KEY , toolbar ) ;
g_object_set_data ( G_OBJECT ( key_management_w ) , AIRPCAP_TOOLBAR_DECRYPTION_KEY , toolbar_decryption_ck ) ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
/* FIRST OF ALL, CHECK THE KEY COLLECTIONS */
/*
* This will read the decryption keys from the preferences file , and will store
* them into the registry . . .
*/
if ( ! airpcap_check_decryption_keys ( airpcap_if_list ) )
2006-10-19 00:48:03 +00:00
{
2007-01-26 06:34:05 +00:00
/* Ask the user what to do ...*/
airpcap_keys_check_w ( key_management_w , NULL ) ;
2006-10-19 00:48:03 +00:00
}
2008-10-15 23:17:40 +00:00
else /* Keys from lists are equals, or Wireshark has got no keys */
2006-10-19 00:48:03 +00:00
{
2007-01-26 06:34:05 +00:00
airpcap_load_decryption_keys ( airpcap_if_list ) ;
2011-02-07 20:24:42 +00:00
airpcap_fill_key_list ( key_list_store ) ;
2007-01-26 06:34:05 +00:00
/* At the end, so that it appears completely all together ... */
gtk_widget_show ( key_management_w ) ;
}
2011-05-15 02:45:18 +00:00
2013-04-17 19:38:50 +00:00
if ( gtk_tree_model_get_iter_first ( GTK_TREE_MODEL ( key_list_store ) , & iter ) )
{
gtk_tree_selection_select_iter ( selection , & iter ) ;
}
2006-10-19 00:48:03 +00:00
}
2006-08-16 18:01:25 +00:00
2011-02-10 17:09:36 +00:00
2011-02-07 20:24:42 +00:00
static void
2011-02-10 17:09:36 +00:00
on_keys_check_cancel_bt_clicked ( GtkWidget * button _U_ , gpointer user_data )
2006-10-19 00:48:03 +00:00
{
2011-02-10 17:09:36 +00:00
GtkWidget * key_management_w ;
GtkWidget * keys_check_w ;
GtkListStore * key_list_store ;
2006-08-16 18:01:25 +00:00
2011-02-10 17:09:36 +00:00
keys_check_w = GTK_WIDGET ( user_data ) ;
2006-12-05 19:24:25 +00:00
2013-03-21 02:29:09 +00:00
key_management_w = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( keys_check_w ) , AIRPCAP_CHECK_WINDOW_KEY ) ;
2006-10-19 00:48:03 +00:00
2011-02-10 17:09:36 +00:00
/* w may be NULL if airpcap_keys_check_w() has been called while Wireshark was loading,
and is not NULL if it was called when the Key Management widget has been clicked */
if ( key_management_w ! = NULL )
{
/* ... */
2013-03-21 02:29:09 +00:00
key_list_store = ( GtkListStore * ) g_object_get_data ( G_OBJECT ( key_management_w ) , AIRPCAP_ADVANCED_KEYLIST_KEY ) ;
2011-02-10 17:09:36 +00:00
airpcap_fill_key_list ( key_list_store ) ;
gtk_widget_show ( key_management_w ) ;
}
2006-10-19 00:48:03 +00:00
2011-02-10 17:09:36 +00:00
gtk_widget_destroy ( keys_check_w ) ;
2006-10-19 00:48:03 +00:00
}
2006-08-16 18:01:25 +00:00
2011-02-07 20:24:42 +00:00
static void
2011-02-10 17:09:36 +00:00
on_merge_bt_clicked ( GtkWidget * button _U_ , gpointer user_data )
2006-10-19 00:48:03 +00:00
{
2007-01-26 06:34:05 +00:00
GtkWidget * key_management_w ;
2011-02-10 17:09:36 +00:00
GtkWidget * keys_check_w ;
2011-02-07 20:24:42 +00:00
GtkListStore * key_list_store ;
2006-08-16 18:01:25 +00:00
2011-02-10 17:09:36 +00:00
guint n_adapters = 0 ;
guint i = 0 ;
2006-12-05 19:24:25 +00:00
2011-02-10 17:09:36 +00:00
GList * wireshark_keys = NULL ;
GList * driver_keys = NULL ;
GList * current_adapter_keys = NULL ;
GList * merged_list = NULL ;
GList * merged_list_tmp = NULL ;
2006-08-16 18:01:25 +00:00
2011-02-10 17:09:36 +00:00
airpcap_if_info_t * curr_adapter ;
2006-08-16 18:01:25 +00:00
2011-02-10 17:09:36 +00:00
keys_check_w = GTK_WIDGET ( user_data ) ;
2006-08-16 18:01:25 +00:00
2013-03-21 02:29:09 +00:00
key_management_w = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( keys_check_w ) , AIRPCAP_CHECK_WINDOW_KEY ) ;
2006-08-16 18:01:25 +00:00
2011-02-10 17:09:36 +00:00
n_adapters = g_list_length ( airpcap_if_list ) ;
2011-02-07 20:24:42 +00:00
2011-02-10 17:09:36 +00:00
/* Retrieve Wireshark keys */
wireshark_keys = get_wireshark_keys ( ) ;
2011-02-07 20:24:42 +00:00
2011-02-10 17:09:36 +00:00
merged_list = merge_key_list ( wireshark_keys , NULL ) ;
2011-02-07 20:24:42 +00:00
2011-02-10 17:09:36 +00:00
/* Retrieve AirPcap driver's keys */
driver_keys = get_airpcap_driver_keys ( ) ;
merged_list = merge_key_list ( merged_list , driver_keys ) ;
/* NOW wireshark_keys and driver_keys ARE no more needed... at the end, we will have to free them! */
for ( i = 0 ; i < n_adapters ; i + + )
{
curr_adapter = ( airpcap_if_info_t * ) g_list_nth_data ( airpcap_if_list , i ) ;
current_adapter_keys = get_airpcap_device_keys ( curr_adapter ) ;
merged_list_tmp = merged_list ;
merged_list = merge_key_list ( merged_list_tmp , current_adapter_keys ) ;
free_key_list ( merged_list_tmp ) ;
}
/* Set up this new list as default for Wireshark and Adapters... */
airpcap_save_decryption_keys ( merged_list , airpcap_if_list ) ;
free_key_list ( wireshark_keys ) ;
free_key_list ( driver_keys ) ;
gtk_widget_destroy ( keys_check_w ) ;
2011-02-07 20:24:42 +00:00
/* w may be NULL if airpcap_keys_check_w() has been called while Wireshark was loading,
and is not NULL if it was called when the Key Management widget has been clicked */
if ( key_management_w ! = NULL )
{
/* ... */
2013-03-21 02:29:09 +00:00
key_list_store = ( GtkListStore * ) g_object_get_data ( G_OBJECT ( key_management_w ) , AIRPCAP_ADVANCED_KEYLIST_KEY ) ;
2011-02-07 20:24:42 +00:00
airpcap_fill_key_list ( key_list_store ) ;
gtk_widget_show ( key_management_w ) ;
}
}
static void
2011-02-10 17:09:36 +00:00
on_keep_bt_clicked ( GtkWidget * button _U_ , gpointer user_data )
2011-02-07 20:24:42 +00:00
{
GtkWidget * key_management_w ;
GtkWidget * keys_check_w ;
2011-02-10 17:09:36 +00:00
GtkListStore * key_list_store = NULL ;
2011-02-07 20:24:42 +00:00
2011-02-10 17:09:36 +00:00
GList * wireshark_keys = NULL ;
GList * merged_keys = NULL ;
2011-02-07 20:24:42 +00:00
keys_check_w = GTK_WIDGET ( user_data ) ;
2013-03-21 02:29:09 +00:00
key_management_w = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( keys_check_w ) , AIRPCAP_CHECK_WINDOW_KEY ) ;
2011-02-07 20:24:42 +00:00
2011-02-10 17:09:36 +00:00
/* Retrieve Wireshark keys */
wireshark_keys = get_wireshark_keys ( ) ;
2011-02-07 20:24:42 +00:00
2011-02-10 17:09:36 +00:00
merged_keys = merge_key_list ( wireshark_keys , NULL ) ;
/* Set up this new list as default for Wireshark and Adapters... */
airpcap_save_decryption_keys ( merged_keys , airpcap_if_list ) ;
/* Free the memory */
free_key_list ( wireshark_keys ) ;
/* Close the window */
gtk_widget_destroy ( keys_check_w ) ;
/* w may be NULL if airpcap_keys_check_w() has been called while Wireshark was loading,
and is not NULL if it was called when the Key Management widget has been clicked */
if ( key_management_w ! = NULL )
{
/* ... */
2013-03-21 02:29:09 +00:00
key_list_store = ( GtkListStore * ) g_object_get_data ( G_OBJECT ( key_management_w ) , AIRPCAP_ADVANCED_KEYLIST_KEY ) ;
2011-02-10 17:09:36 +00:00
airpcap_fill_key_list ( key_list_store ) ;
gtk_widget_show ( key_management_w ) ;
}
}
static void
on_import_bt_clicked ( GtkWidget * button _U_ , gpointer user_data )
{
GtkWidget * key_management_w ;
GtkWidget * keys_check_w ;
GtkListStore * key_list_store ;
guint n_adapters = 0 ;
guint i = 0 ;
GList * wireshark_keys = NULL ;
GList * driver_keys = NULL ;
GList * current_adapter_keys = NULL ;
GList * merged_list = NULL ;
GList * merged_list_tmp = NULL ;
airpcap_if_info_t * curr_adapter ;
keys_check_w = GTK_WIDGET ( user_data ) ;
2013-03-21 02:29:09 +00:00
key_management_w = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( keys_check_w ) , AIRPCAP_CHECK_WINDOW_KEY ) ;
2011-02-10 17:09:36 +00:00
n_adapters = g_list_length ( airpcap_if_list ) ;
wireshark_keys = get_wireshark_keys ( ) ;
/* Retrieve AirPcap driver's keys */
driver_keys = get_airpcap_driver_keys ( ) ;
merged_list = merge_key_list ( merged_list , driver_keys ) ;
/* NOW wireshark_keys IS no more needed... at the end, we will have to free it! */
for ( i = 0 ; i < n_adapters ; i + + )
{
curr_adapter = ( airpcap_if_info_t * ) g_list_nth_data ( airpcap_if_list , i ) ;
current_adapter_keys = get_airpcap_device_keys ( curr_adapter ) ;
merged_list_tmp = merged_list ;
merged_list = merge_key_list ( merged_list_tmp , current_adapter_keys ) ;
free_key_list ( merged_list_tmp ) ;
}
/* Set up this new list as default for Wireshark and Adapters... */
airpcap_save_decryption_keys ( merged_list , airpcap_if_list ) ;
free_key_list ( wireshark_keys ) ;
free_key_list ( driver_keys ) ;
gtk_widget_destroy ( keys_check_w ) ;
/* w may be NULL if airpcap_keys_check_w() has been called while Wireshark was loading,
and is not NULL if it was called when the Key Management widget has been clicked */
if ( key_management_w ! = NULL )
{
/* ... */
2013-03-21 02:29:09 +00:00
key_list_store = ( GtkListStore * ) g_object_get_data ( G_OBJECT ( key_management_w ) , AIRPCAP_ADVANCED_KEYLIST_KEY ) ;
2011-02-10 17:09:36 +00:00
airpcap_fill_key_list ( key_list_store ) ;
gtk_widget_show ( key_management_w ) ;
}
}
static void
on_ignore_bt_clicked ( GtkWidget * button _U_ , gpointer user_data )
{
GtkWidget * key_management_w ;
GtkWidget * keys_check_w ;
GtkListStore * key_list_store ;
keys_check_w = GTK_WIDGET ( user_data ) ;
2013-03-21 02:29:09 +00:00
key_management_w = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( keys_check_w ) , AIRPCAP_CHECK_WINDOW_KEY ) ;
2011-02-10 17:09:36 +00:00
/* w may be NULL if airpcap_keys_check_w() has been called while Wireshark was loading,
and is not NULL if it was called when the Key Management widget has been clicked */
if ( key_management_w ! = NULL )
{
/* ... */
2013-03-21 02:29:09 +00:00
key_list_store = ( GtkListStore * ) g_object_get_data ( G_OBJECT ( key_management_w ) , AIRPCAP_ADVANCED_KEYLIST_KEY ) ;
2011-02-10 17:09:36 +00:00
airpcap_fill_key_list ( key_list_store ) ;
gtk_widget_show ( key_management_w ) ;
}
gtk_widget_destroy ( keys_check_w ) ;
}
static void
on_keys_check_ok_bt_clicked ( GtkWidget * button _U_ , gpointer user_data )
{
GtkWidget * keys_check_w ;
GtkWidget * merge_rb ,
* keep_rb ,
* import_rb ,
* ignore_rb ;
keys_check_w = GTK_WIDGET ( user_data ) ;
2013-03-21 02:29:09 +00:00
merge_rb = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( keys_check_w ) , AIRPCAP_CHECK_WINDOW_RADIO_MERGE_KEY ) ;
keep_rb = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( keys_check_w ) , AIRPCAP_CHECK_WINDOW_RADIO_KEEP_KEY ) ;
import_rb = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( keys_check_w ) , AIRPCAP_CHECK_WINDOW_RADIO_IMPORT_KEY ) ;
ignore_rb = ( GtkWidget * ) g_object_get_data ( G_OBJECT ( keys_check_w ) , AIRPCAP_CHECK_WINDOW_RADIO_IGNORE_KEY ) ;
2011-02-10 17:09:36 +00:00
/* Find out which radio button is selected and call the correct function */
2011-07-29 10:11:24 +00:00
if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( merge_rb ) ) )
2011-09-21 17:32:35 +00:00
on_merge_bt_clicked ( merge_rb , keys_check_w ) ;
2012-03-30 01:46:42 +00:00
else if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( keep_rb ) ) )
2011-09-21 17:32:35 +00:00
on_keep_bt_clicked ( keep_rb , keys_check_w ) ;
2012-03-30 01:46:42 +00:00
else if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( import_rb ) ) )
2011-09-21 17:32:35 +00:00
on_import_bt_clicked ( import_rb , keys_check_w ) ;
2011-07-29 10:11:24 +00:00
else if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( ignore_rb ) ) )
2011-09-21 17:32:35 +00:00
on_ignore_bt_clicked ( ignore_rb , keys_check_w ) ;
2011-02-10 17:09:36 +00:00
else on_keys_check_cancel_bt_clicked ( NULL , keys_check_w ) ;
}
static void
on_keys_check_w_destroy ( GtkWidget * w _U_ , gpointer user_data )
{
gtk_widget_set_sensitive ( top_level , TRUE ) ;
gtk_widget_set_sensitive ( GTK_WIDGET ( user_data ) , TRUE ) ;
}
/*
* Dialog box that appears whenever keys are not consistent between Wireshark and AirPcap
*/
void
airpcap_keys_check_w ( GtkWidget * w , gpointer data _U_ )
{
GtkWidget * keys_check_w ;
GtkWidget * main_v_box ;
GtkWidget * warning_lb ;
2013-01-09 21:35:18 +00:00
GtkWidget * radio_grid ;
2011-02-10 17:09:36 +00:00
GtkWidget * keep_rb ;
GSList * radio_bt_group = NULL ;
2007-01-26 06:34:05 +00:00
GtkWidget * merge_rb ;
GtkWidget * import_rb ;
GtkWidget * ignore_rb ;
GtkWidget * keep_lb ;
GtkWidget * merge_lb ;
GtkWidget * import_lb ;
GtkWidget * ignore_lb ;
GtkWidget * low_h_button_box ;
GtkWidget * ok_bt ;
GtkWidget * cancel_bt ;
keys_check_w = window_new ( GTK_WINDOW_TOPLEVEL , " Decryption Key Warning " ) ;
gtk_widget_set_name ( keys_check_w , " keys_check_w " ) ;
gtk_window_set_resizable ( GTK_WINDOW ( keys_check_w ) , FALSE ) ;
2006-08-16 18:01:25 +00:00
2012-06-02 23:53:04 +00:00
main_v_box = ws_gtk_box_new ( GTK_ORIENTATION_VERTICAL , 0 , FALSE ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( main_v_box , " main_v_box " ) ;
gtk_widget_show ( main_v_box ) ;
gtk_container_add ( GTK_CONTAINER ( keys_check_w ) , main_v_box ) ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
warning_lb = gtk_label_new ( " <b>WARNING!</b> Decryption keys specified in Wireshark's preferences file differ from those specified for the AirPcap adapter(s). You can choose to: " ) ;
gtk_label_set_use_markup ( GTK_LABEL ( warning_lb ) , TRUE ) ;
gtk_widget_set_name ( warning_lb , " warning_lb " ) ;
gtk_widget_show ( warning_lb ) ;
gtk_box_pack_start ( GTK_BOX ( main_v_box ) , warning_lb , FALSE , FALSE , 0 ) ;
gtk_label_set_justify ( GTK_LABEL ( warning_lb ) , GTK_JUSTIFY_CENTER ) ;
gtk_label_set_line_wrap ( GTK_LABEL ( warning_lb ) , TRUE ) ;
2013-01-09 21:35:18 +00:00
radio_grid = ws_gtk_grid_new ( ) ;
gtk_widget_set_name ( radio_grid , " radio_grid " ) ;
gtk_widget_show ( radio_grid ) ;
gtk_box_pack_start ( GTK_BOX ( main_v_box ) , radio_grid , TRUE , FALSE , 0 ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( radio_grid ) , 5 ) ;
ws_gtk_grid_set_column_spacing ( GTK_GRID ( radio_grid ) , 8 ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
keep_rb = gtk_radio_button_new_with_mnemonic ( NULL , " Keep " ) ;
gtk_widget_set_name ( keep_rb , " keep_rb " ) ;
gtk_widget_show ( keep_rb ) ;
2013-03-22 17:37:25 +00:00
ws_gtk_grid_attach_extended ( GTK_GRID ( radio_grid ) , keep_rb , 0 , 0 , 1 , 1 ,
2007-01-26 06:34:05 +00:00
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_radio_button_set_group ( GTK_RADIO_BUTTON ( keep_rb ) , radio_bt_group ) ;
radio_bt_group = gtk_radio_button_get_group ( GTK_RADIO_BUTTON ( keep_rb ) ) ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
merge_rb = gtk_radio_button_new_with_mnemonic ( NULL , " Merge " ) ;
gtk_widget_set_name ( merge_rb , " merge_rb " ) ;
gtk_widget_show ( merge_rb ) ;
2013-03-22 17:37:25 +00:00
ws_gtk_grid_attach_extended ( GTK_GRID ( radio_grid ) , merge_rb , 0 , 1 , 1 , 1 ,
2007-01-26 06:34:05 +00:00
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_radio_button_set_group ( GTK_RADIO_BUTTON ( merge_rb ) , radio_bt_group ) ;
radio_bt_group = gtk_radio_button_get_group ( GTK_RADIO_BUTTON ( merge_rb ) ) ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
import_rb = gtk_radio_button_new_with_mnemonic ( NULL , " Import " ) ;
gtk_widget_set_name ( import_rb , " import_rb " ) ;
gtk_widget_show ( import_rb ) ;
2013-03-22 17:37:25 +00:00
ws_gtk_grid_attach_extended ( GTK_GRID ( radio_grid ) , import_rb , 0 , 2 , 1 , 1 ,
2007-01-26 06:34:05 +00:00
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_radio_button_set_group ( GTK_RADIO_BUTTON ( import_rb ) , radio_bt_group ) ;
radio_bt_group = gtk_radio_button_get_group ( GTK_RADIO_BUTTON ( import_rb ) ) ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
ignore_rb = gtk_radio_button_new_with_mnemonic ( NULL , " Ignore " ) ;
gtk_widget_set_name ( ignore_rb , " ignore_rb " ) ;
gtk_widget_show ( ignore_rb ) ;
2013-03-22 17:37:25 +00:00
ws_gtk_grid_attach_extended ( GTK_GRID ( radio_grid ) , ignore_rb , 0 , 3 , 1 , 1 ,
2007-01-26 06:34:05 +00:00
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_radio_button_set_group ( GTK_RADIO_BUTTON ( ignore_rb ) , radio_bt_group ) ;
radio_bt_group = gtk_radio_button_get_group ( GTK_RADIO_BUTTON ( ignore_rb ) ) ;
2006-08-16 18:01:25 +00:00
2007-01-26 06:34:05 +00:00
keep_lb =
gtk_label_new
( " Use Wireshark keys, thus overwriting AirPcap adapter(s) ones. " ) ;
gtk_widget_set_name ( keep_lb , " keep_lb " ) ;
gtk_widget_show ( keep_lb ) ;
2013-03-22 17:37:25 +00:00
ws_gtk_grid_attach_extended ( GTK_GRID ( radio_grid ) , keep_lb , 1 , 0 , 1 , 1 ,
2007-01-26 06:34:05 +00:00
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
2012-12-26 05:57:06 +00:00
gtk_misc_set_alignment ( GTK_MISC ( keep_lb ) , 0 , 0.5f ) ;
2007-01-26 06:34:05 +00:00
merge_lb = gtk_label_new ( " Merge Wireshark and AirPcap adapter(s) keys. " ) ;
gtk_widget_set_name ( merge_lb , " merge_lb " ) ;
gtk_widget_show ( merge_lb ) ;
2013-03-22 17:37:25 +00:00
ws_gtk_grid_attach_extended ( GTK_GRID ( radio_grid ) , merge_lb , 1 , 1 , 1 , 1 ,
2007-01-26 06:34:05 +00:00
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
2012-12-26 05:57:06 +00:00
gtk_misc_set_alignment ( GTK_MISC ( merge_lb ) , 0 , 0.5f ) ;
2007-01-26 06:34:05 +00:00
import_lb =
gtk_label_new
( " Use AirPcap adapter(s) keys, thus overwriting Wireshark ones. " ) ;
gtk_widget_set_name ( import_lb , " import_lb " ) ;
gtk_widget_show ( import_lb ) ;
2013-03-22 17:37:25 +00:00
ws_gtk_grid_attach_extended ( GTK_GRID ( radio_grid ) , import_lb , 1 , 2 , 1 , 1 ,
2007-01-26 06:34:05 +00:00
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
2012-12-26 05:57:06 +00:00
gtk_misc_set_alignment ( GTK_MISC ( import_lb ) , 0 , 0.5f ) ;
2007-01-26 06:34:05 +00:00
ignore_lb =
gtk_label_new
( " Keep using different set of keys. Remember that in this case, this dialog box will appear whenever you will attempt to modify/add/remove decryption keys. " ) ;
gtk_widget_set_name ( ignore_lb , " ignore_lb " ) ;
gtk_widget_show ( ignore_lb ) ;
2013-03-22 17:37:25 +00:00
ws_gtk_grid_attach_extended ( GTK_GRID ( radio_grid ) , ignore_lb , 1 , 3 , 1 , 1 ,
2007-01-26 06:34:05 +00:00
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_label_set_line_wrap ( GTK_LABEL ( ignore_lb ) , TRUE ) ;
2012-12-26 05:57:06 +00:00
gtk_misc_set_alignment ( GTK_MISC ( ignore_lb ) , 0 , 0.5f ) ;
2007-01-26 06:34:05 +00:00
2012-06-02 23:53:04 +00:00
low_h_button_box = gtk_button_box_new ( GTK_ORIENTATION_HORIZONTAL ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_name ( low_h_button_box , " low_h_button_box " ) ;
gtk_widget_show ( low_h_button_box ) ;
gtk_box_pack_start ( GTK_BOX ( main_v_box ) , low_h_button_box , FALSE , FALSE ,
0 ) ;
gtk_button_box_set_layout ( GTK_BUTTON_BOX ( low_h_button_box ) ,
GTK_BUTTONBOX_SPREAD ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
ok_bt = gtk_button_new_with_mnemonic ( " OK " ) ;
gtk_widget_set_name ( ok_bt , " ok_bt " ) ;
gtk_widget_show ( ok_bt ) ;
gtk_container_add ( GTK_CONTAINER ( low_h_button_box ) , ok_bt ) ;
2011-07-14 00:04:37 +00:00
gtk_widget_set_can_default ( ok_bt , TRUE ) ;
2006-10-19 00:48:03 +00:00
2007-01-26 06:34:05 +00:00
cancel_bt = gtk_button_new_with_mnemonic ( " Cancel " ) ;
gtk_widget_set_name ( cancel_bt , " cancel_bt " ) ;
gtk_widget_show ( cancel_bt ) ;
gtk_container_add ( GTK_CONTAINER ( low_h_button_box ) , cancel_bt ) ;
2011-07-14 00:04:37 +00:00
gtk_widget_set_can_default ( cancel_bt , TRUE ) ;
2007-01-26 06:34:05 +00:00
/* Store pointers to all widgets, for use by lookup_widget(). */
2008-04-09 05:37:53 +00:00
g_signal_connect ( ok_bt , " clicked " , G_CALLBACK ( on_keys_check_ok_bt_clicked ) , keys_check_w ) ;
g_signal_connect ( cancel_bt , " clicked " , G_CALLBACK ( on_keys_check_cancel_bt_clicked ) , keys_check_w ) ;
g_signal_connect ( keys_check_w , " destroy " , G_CALLBACK ( on_keys_check_w_destroy ) , keys_check_w ) ;
2007-01-26 06:34:05 +00:00
/* Store pointers to all widgets, for use by lookup_widget(). */
2008-04-09 20:55:33 +00:00
g_object_set_data ( G_OBJECT ( keys_check_w ) , AIRPCAP_CHECK_WINDOW_KEY , w ) ;
g_object_set_data ( G_OBJECT ( keys_check_w ) , AIRPCAP_CHECK_WINDOW_RADIO_MERGE_KEY , merge_rb ) ;
g_object_set_data ( G_OBJECT ( keys_check_w ) , AIRPCAP_CHECK_WINDOW_RADIO_KEEP_KEY , keep_rb ) ;
g_object_set_data ( G_OBJECT ( keys_check_w ) , AIRPCAP_CHECK_WINDOW_RADIO_IMPORT_KEY , import_rb ) ;
g_object_set_data ( G_OBJECT ( keys_check_w ) , AIRPCAP_CHECK_WINDOW_RADIO_IGNORE_KEY , ignore_rb ) ;
g_object_set_data ( G_OBJECT ( keys_check_w ) , AIRPCAP_CHECK_WINDOW_RADIO_GROUP_KEY , radio_bt_group ) ;
2007-01-26 06:34:05 +00:00
gtk_widget_set_sensitive ( top_level , FALSE ) ;
gtk_widget_show ( keys_check_w ) ;
2006-10-19 00:48:03 +00:00
}
2006-08-16 18:01:25 +00:00
2006-10-19 00:48:03 +00:00
2006-08-16 18:01:25 +00:00
# endif /* HAVE_AIRPCAP */
2008-10-17 23:48:33 +00:00
/*
* Editor modelines
*
* Local Variables :
* c - basic - offset : 4
2011-09-21 17:32:35 +00:00
* tab - width : 8
* indent - tabs - mode : nil
2008-10-17 23:48:33 +00:00
* End :
*
2011-09-21 17:32:35 +00:00
* ex : set shiftwidth = 4 tabstop = 8 expandtab :
* : indentSize = 4 : tabSize = 8 : noTabs = true :
2008-10-17 23:48:33 +00:00
*/