2004-04-21 17:57:31 +00:00
|
|
|
/* mtp3_stat.c
|
|
|
|
*
|
|
|
|
* Copyright 2004, Michael Lum <mlum [AT] telostech.com>
|
|
|
|
* In association with Telos Technology Inc.
|
|
|
|
*
|
|
|
|
* Modified from gsm_map_stat.c
|
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
2004-04-21 17:57:31 +00:00
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2004-04-21 17:57:31 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This TAP provides statistics for MTP3:
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2008-04-13 03:32:24 +00:00
|
|
|
#include <string.h>
|
2004-04-21 17:57:31 +00:00
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "epan/packet_info.h"
|
|
|
|
#include "epan/epan.h"
|
|
|
|
#include "epan/value_string.h"
|
2005-08-20 20:06:05 +00:00
|
|
|
#include <epan/stat_cmd_args.h>
|
2004-09-29 00:06:36 +00:00
|
|
|
#include <epan/tap.h>
|
2005-08-20 01:24:23 +00:00
|
|
|
#include <epan/emem.h>
|
2008-04-13 03:32:24 +00:00
|
|
|
#include <epan/dissectors/packet-mtp3.h>
|
|
|
|
|
|
|
|
#include "../stat_menu.h"
|
|
|
|
#include "../simple_dialog.h"
|
2004-04-21 17:57:31 +00:00
|
|
|
|
2008-04-13 03:32:24 +00:00
|
|
|
#include "gtk/gui_stat_menu.h"
|
|
|
|
#include "gtk/dlg_utils.h"
|
|
|
|
#include "gtk/filter_dlg.h"
|
|
|
|
#include "gtk/gui_utils.h"
|
|
|
|
#include "gtk/mtp3_stat.h"
|
|
|
|
|
2011-07-21 20:12:08 +00:00
|
|
|
#include "gtk/old-gtk-compat.h"
|
2008-04-13 03:32:24 +00:00
|
|
|
|
2009-03-16 18:01:25 +00:00
|
|
|
enum
|
|
|
|
{
|
2010-07-26 16:22:33 +00:00
|
|
|
OPC_COLUMN,
|
|
|
|
DPC_COLUMN,
|
|
|
|
SI_COLUMN,
|
|
|
|
NUM_MSUS_COLUMN,
|
|
|
|
NUM_BYTES_COLUMN,
|
|
|
|
AVG_BYTES_COLUMN,
|
|
|
|
N_COLUMN /* The number of columns */
|
2004-04-21 17:57:31 +00:00
|
|
|
};
|
|
|
|
|
2009-03-16 18:01:25 +00:00
|
|
|
|
2004-04-21 17:57:31 +00:00
|
|
|
typedef struct _mtp3_stat_dlg_t {
|
2010-07-26 16:22:33 +00:00
|
|
|
GtkWidget *win;
|
|
|
|
GtkWidget *scrolled_win;
|
|
|
|
GtkWidget *table;
|
|
|
|
char *entries[N_COLUMN];
|
2004-04-21 17:57:31 +00:00
|
|
|
} mtp3_stat_dlg_t;
|
|
|
|
|
2010-07-26 16:22:33 +00:00
|
|
|
static mtp3_stat_dlg_t dlg;
|
2004-04-21 17:57:31 +00:00
|
|
|
|
2010-07-26 16:22:33 +00:00
|
|
|
mtp3_stat_t mtp3_stat[MTP3_MAX_NUM_OPC_DPC];
|
|
|
|
guint8 mtp3_num_used;
|
2004-04-21 17:57:31 +00:00
|
|
|
|
|
|
|
|
2009-03-16 18:01:25 +00:00
|
|
|
|
|
|
|
/* Create list */
|
|
|
|
static
|
2009-05-08 15:16:07 +00:00
|
|
|
GtkWidget* create_list(void)
|
2009-03-16 18:01:25 +00:00
|
|
|
{
|
|
|
|
|
2010-07-26 16:22:33 +00:00
|
|
|
GtkListStore *list_store;
|
|
|
|
GtkWidget *list;
|
2009-03-16 18:01:25 +00:00
|
|
|
GtkTreeViewColumn *column;
|
2010-07-26 16:22:33 +00:00
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
GtkTreeSortable *sortable;
|
|
|
|
GtkTreeView *list_view;
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
|
|
|
|
/* Create the store */
|
|
|
|
list_store = gtk_list_store_new(N_COLUMN, /* Total number of columns XXX*/
|
|
|
|
G_TYPE_STRING, /* OPC */
|
|
|
|
G_TYPE_STRING, /* DPC */
|
|
|
|
G_TYPE_STRING, /* SI */
|
|
|
|
G_TYPE_INT, /* Num MSUs */
|
|
|
|
G_TYPE_INT, /* Num Bytes */
|
|
|
|
G_TYPE_FLOAT); /* Avg Bytes */
|
2009-03-16 18:01:25 +00:00
|
|
|
|
|
|
|
/* Create a view */
|
|
|
|
list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));
|
|
|
|
|
2010-07-26 16:22:33 +00:00
|
|
|
list_view = GTK_TREE_VIEW(list);
|
|
|
|
sortable = GTK_TREE_SORTABLE(list_store);
|
2009-03-16 18:01:25 +00:00
|
|
|
|
2010-07-26 16:22:33 +00:00
|
|
|
/* Speed up the list display */
|
|
|
|
gtk_tree_view_set_fixed_height_mode(list_view, TRUE);
|
2009-03-16 18:01:25 +00:00
|
|
|
|
|
|
|
/* Setup the sortable columns */
|
|
|
|
gtk_tree_sortable_set_sort_column_id(sortable, OPC_COLUMN, GTK_SORT_ASCENDING);
|
|
|
|
gtk_tree_view_set_headers_clickable(list_view, FALSE);
|
|
|
|
|
|
|
|
/* The view now holds a reference. We can get rid of our own reference */
|
|
|
|
g_object_unref (G_OBJECT (list_store));
|
|
|
|
|
2010-08-30 16:10:01 +00:00
|
|
|
/*
|
2010-07-26 16:22:33 +00:00
|
|
|
* Create the first column packet, associating the "text" attribute of the
|
2010-08-30 16:10:01 +00:00
|
|
|
* cell_renderer to the first column of the model
|
2010-07-26 16:22:33 +00:00
|
|
|
*/
|
|
|
|
/* 1:st column */
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
2010-08-30 16:10:01 +00:00
|
|
|
column = gtk_tree_view_column_new_with_attributes ("OPC", renderer,
|
|
|
|
"text", OPC_COLUMN,
|
2010-07-26 16:22:33 +00:00
|
|
|
NULL);
|
2009-03-16 18:01:25 +00:00
|
|
|
|
2010-07-26 16:22:33 +00:00
|
|
|
gtk_tree_view_column_set_sort_column_id(column, OPC_COLUMN);
|
2009-03-16 18:01:25 +00:00
|
|
|
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);
|
|
|
|
|
2010-07-26 16:22:33 +00:00
|
|
|
/* Add the column to the view. */
|
2009-03-16 18:01:25 +00:00
|
|
|
gtk_tree_view_append_column (list_view, column);
|
|
|
|
|
|
|
|
/* 2:nd column... */
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
2010-08-30 16:10:01 +00:00
|
|
|
column = gtk_tree_view_column_new_with_attributes ("DPC", renderer,
|
2010-07-26 16:22:33 +00:00
|
|
|
"text", DPC_COLUMN,
|
|
|
|
NULL);
|
2009-03-16 18:01:25 +00:00
|
|
|
gtk_tree_view_column_set_sort_column_id(column, DPC_COLUMN);
|
|
|
|
gtk_tree_view_column_set_resizable(column, TRUE);
|
|
|
|
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
|
|
|
gtk_tree_view_column_set_min_width(column, 80);
|
|
|
|
gtk_tree_view_append_column (list_view, column);
|
|
|
|
|
2010-07-26 16:22:33 +00:00
|
|
|
/* 3:d column... */
|
2009-03-16 18:01:25 +00:00
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
2010-08-30 16:10:01 +00:00
|
|
|
column = gtk_tree_view_column_new_with_attributes ("SI", renderer,
|
2010-07-26 16:22:33 +00:00
|
|
|
"text", SI_COLUMN,
|
|
|
|
NULL);
|
2009-03-16 18:01:25 +00:00
|
|
|
gtk_tree_view_column_set_sort_column_id(column, SI_COLUMN);
|
|
|
|
gtk_tree_view_column_set_resizable(column, TRUE);
|
|
|
|
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
|
|
|
gtk_tree_view_column_set_min_width(column, 110);
|
|
|
|
gtk_tree_view_append_column (list_view, column);
|
|
|
|
|
|
|
|
/* 4:th column... */
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
2010-08-30 16:10:01 +00:00
|
|
|
column = gtk_tree_view_column_new_with_attributes ("Num MSUs", renderer,
|
|
|
|
"text", NUM_MSUS_COLUMN,
|
2010-07-26 16:22:33 +00:00
|
|
|
NULL);
|
2010-08-30 16:10:01 +00:00
|
|
|
|
2009-03-16 18:01:25 +00:00
|
|
|
|
|
|
|
gtk_tree_view_column_set_sort_column_id(column, NUM_MSUS_COLUMN);
|
|
|
|
gtk_tree_view_column_set_resizable(column, TRUE);
|
|
|
|
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
|
|
|
gtk_tree_view_column_set_min_width(column, 80);
|
|
|
|
gtk_tree_view_append_column (list_view, column);
|
|
|
|
|
|
|
|
/* 5:th column... */
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
2010-08-30 16:10:01 +00:00
|
|
|
column = gtk_tree_view_column_new_with_attributes ("Num Bytes", renderer,
|
|
|
|
"text", NUM_BYTES_COLUMN,
|
2010-07-26 16:22:33 +00:00
|
|
|
NULL);
|
2009-03-16 18:01:25 +00:00
|
|
|
|
|
|
|
gtk_tree_view_column_set_sort_column_id(column, NUM_BYTES_COLUMN);
|
|
|
|
gtk_tree_view_column_set_resizable(column, TRUE);
|
|
|
|
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
|
|
|
gtk_tree_view_column_set_min_width(column, 100);
|
|
|
|
gtk_tree_view_append_column (list_view, column);
|
|
|
|
|
|
|
|
/* 6:th column... */
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
2010-08-30 16:10:01 +00:00
|
|
|
column = gtk_tree_view_column_new_with_attributes ("Avg Bytes", renderer,
|
|
|
|
"text", AVG_BYTES_COLUMN,
|
2010-07-26 16:22:33 +00:00
|
|
|
NULL);
|
2010-08-30 16:10:01 +00:00
|
|
|
gtk_tree_view_column_set_cell_data_func(column, renderer, float_data_func,
|
2010-07-26 16:22:33 +00:00
|
|
|
GINT_TO_POINTER(AVG_BYTES_COLUMN), NULL);
|
2009-03-16 18:01:25 +00:00
|
|
|
|
|
|
|
gtk_tree_view_column_set_sort_column_id(column, AVG_BYTES_COLUMN);
|
|
|
|
gtk_tree_view_column_set_resizable(column, TRUE);
|
|
|
|
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
|
|
|
gtk_tree_view_column_set_min_width(column, 80);
|
|
|
|
gtk_tree_view_append_column (list_view, column);
|
|
|
|
|
2010-07-26 16:22:33 +00:00
|
|
|
/* Now enable the sorting of each column */
|
2009-03-16 18:01:25 +00:00
|
|
|
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(list_view), TRUE);
|
|
|
|
gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(list_view), TRUE);
|
|
|
|
|
2010-07-26 16:22:33 +00:00
|
|
|
/* Setup the selection handler */
|
|
|
|
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(list));
|
|
|
|
gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
|
2009-03-16 18:01:25 +00:00
|
|
|
|
2010-07-26 16:22:33 +00:00
|
|
|
return list;
|
2009-03-16 18:01:25 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-04-21 17:57:31 +00:00
|
|
|
static void
|
|
|
|
mtp3_stat_reset(
|
2010-07-26 16:22:33 +00:00
|
|
|
void *tapdata)
|
2004-04-21 17:57:31 +00:00
|
|
|
{
|
2010-07-26 16:22:33 +00:00
|
|
|
mtp3_stat_t (*stat_p)[MTP3_MAX_NUM_OPC_DPC] = tapdata;
|
2004-04-21 17:57:31 +00:00
|
|
|
|
|
|
|
mtp3_num_used = 0;
|
2005-01-01 02:57:02 +00:00
|
|
|
memset(stat_p, 0, MTP3_MAX_NUM_OPC_DPC * sizeof(mtp3_stat_t));
|
2004-04-21 17:57:31 +00:00
|
|
|
|
|
|
|
if (dlg.win != NULL)
|
|
|
|
{
|
2010-07-26 16:22:33 +00:00
|
|
|
gtk_list_store_clear(GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(dlg.table))));
|
2004-04-21 17:57:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-07-26 16:22:33 +00:00
|
|
|
static gboolean
|
2004-04-21 17:57:31 +00:00
|
|
|
mtp3_stat_packet(
|
2010-07-26 16:22:33 +00:00
|
|
|
void *tapdata,
|
|
|
|
packet_info *pinfo _U_,
|
|
|
|
epan_dissect_t *edt _U_,
|
|
|
|
const void *data)
|
2004-04-21 17:57:31 +00:00
|
|
|
{
|
2010-07-26 16:22:33 +00:00
|
|
|
mtp3_stat_t (*stat_p)[MTP3_MAX_NUM_OPC_DPC] = tapdata;
|
|
|
|
const mtp3_tap_rec_t *data_p = data;
|
|
|
|
int i;
|
2004-04-21 17:57:31 +00:00
|
|
|
|
|
|
|
if (data_p->si_code >= MTP3_NUM_SI_CODE)
|
|
|
|
{
|
2010-07-26 16:22:33 +00:00
|
|
|
/*
|
|
|
|
* we thought this si_code was not used ?
|
|
|
|
* is MTP3_NUM_SI_CODE out of date ?
|
|
|
|
*/
|
|
|
|
return(FALSE);
|
2004-04-21 17:57:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* look for opc/dpc pair
|
|
|
|
*/
|
|
|
|
i = 0;
|
|
|
|
while (i < mtp3_num_used)
|
|
|
|
{
|
2010-07-26 16:22:33 +00:00
|
|
|
if (memcmp(&data_p->addr_opc, &(*stat_p)[i].addr_opc, sizeof(mtp3_addr_pc_t)) == 0)
|
|
|
|
{
|
|
|
|
if (memcmp(&data_p->addr_dpc, &(*stat_p)[i].addr_dpc, sizeof(mtp3_addr_pc_t)) == 0)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
i++;
|
2004-04-21 17:57:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (i == mtp3_num_used)
|
|
|
|
{
|
2010-07-26 16:22:33 +00:00
|
|
|
if (mtp3_num_used == MTP3_MAX_NUM_OPC_DPC)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* too many
|
|
|
|
*/
|
|
|
|
return(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
mtp3_num_used++;
|
2004-04-21 17:57:31 +00:00
|
|
|
}
|
|
|
|
|
2005-01-01 02:57:02 +00:00
|
|
|
(*stat_p)[i].addr_opc = data_p->addr_opc;
|
|
|
|
(*stat_p)[i].addr_dpc = data_p->addr_dpc;
|
|
|
|
(*stat_p)[i].si_code[data_p->si_code].num_msus++;
|
|
|
|
(*stat_p)[i].si_code[data_p->si_code].size += data_p->size;
|
2004-04-21 17:57:31 +00:00
|
|
|
|
2010-07-26 16:22:33 +00:00
|
|
|
return(TRUE);
|
2004-04-21 17:57:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
mtp3_stat_draw(
|
2010-07-26 16:22:33 +00:00
|
|
|
void *tapdata)
|
2004-04-21 17:57:31 +00:00
|
|
|
{
|
2010-07-26 16:22:33 +00:00
|
|
|
mtp3_stat_t (*stat_p)[MTP3_MAX_NUM_OPC_DPC] = tapdata;
|
|
|
|
int i,j;
|
|
|
|
char *str;
|
|
|
|
float avg;
|
2009-03-16 18:01:25 +00:00
|
|
|
GtkListStore *list_store = NULL;
|
2010-07-26 16:22:33 +00:00
|
|
|
GtkTreeIter iter;
|
2004-04-21 17:57:31 +00:00
|
|
|
|
2005-01-14 20:27:34 +00:00
|
|
|
if (!dlg.win || !tapdata)
|
2004-04-21 17:57:31 +00:00
|
|
|
{
|
2010-07-26 16:22:33 +00:00
|
|
|
return;
|
2004-04-21 17:57:31 +00:00
|
|
|
}
|
|
|
|
|
2005-08-20 01:24:23 +00:00
|
|
|
str=ep_alloc(256);
|
2004-04-21 17:57:31 +00:00
|
|
|
i = 0;
|
|
|
|
|
2010-07-26 16:22:33 +00:00
|
|
|
list_store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (dlg.table))); /* Get store */
|
2004-04-21 17:57:31 +00:00
|
|
|
while (i < mtp3_num_used)
|
|
|
|
{
|
2010-07-26 16:22:33 +00:00
|
|
|
mtp3_addr_to_str_buf(&(*stat_p)[i].addr_opc, str, 256);
|
|
|
|
dlg.entries[0] = g_strdup(str);
|
2009-03-16 18:01:25 +00:00
|
|
|
|
2010-07-26 16:22:33 +00:00
|
|
|
mtp3_addr_to_str_buf(&(*stat_p)[i].addr_dpc, str, 256);
|
|
|
|
dlg.entries[1] = g_strdup(str);
|
2009-03-16 18:01:25 +00:00
|
|
|
|
2010-07-26 16:22:33 +00:00
|
|
|
for (j=0; j < MTP3_NUM_SI_CODE; j++){
|
2010-08-30 16:10:01 +00:00
|
|
|
/* Creates a new row at position. iter will be changed to point to this new row.
|
2010-07-26 16:22:33 +00:00
|
|
|
* If position is larger than the number of rows on the list, then the new row will be appended to the list.
|
|
|
|
* The row will be filled with the values given to this function.
|
|
|
|
* :
|
|
|
|
* should generally be preferred when inserting rows in a sorted list store.
|
|
|
|
*/
|
|
|
|
avg = 0.0f;
|
|
|
|
if ((*stat_p)[i].si_code[j].num_msus !=0){
|
|
|
|
avg = (float)(*stat_p)[i].si_code[j].size/(float)(*stat_p)[i].si_code[j].num_msus;
|
|
|
|
}
|
2009-03-16 18:01:25 +00:00
|
|
|
|
|
|
|
|
2010-07-26 16:22:33 +00:00
|
|
|
gtk_list_store_insert_with_values( list_store , &iter, G_MAXINT,
|
|
|
|
OPC_COLUMN, dlg.entries[0],
|
|
|
|
DPC_COLUMN, dlg.entries[1],
|
|
|
|
SI_COLUMN, mtp3_service_indicator_code_short_vals[j].strptr,
|
|
|
|
NUM_MSUS_COLUMN, (*stat_p)[i].si_code[j].num_msus,
|
|
|
|
NUM_BYTES_COLUMN, (*stat_p)[i].si_code[j].size,
|
|
|
|
AVG_BYTES_COLUMN, avg,
|
|
|
|
-1);
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
2004-04-21 17:57:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
mtp3_stat_gtk_win_destroy_cb(
|
2010-07-26 16:22:33 +00:00
|
|
|
GtkWindow *win _U_,
|
2010-08-23 19:29:08 +00:00
|
|
|
gpointer user_data)
|
2004-04-21 17:57:31 +00:00
|
|
|
{
|
|
|
|
memset((void *) user_data, 0, sizeof(mtp3_stat_dlg_t));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
mtp3_stat_gtk_win_create(
|
2010-07-26 16:22:33 +00:00
|
|
|
mtp3_stat_dlg_t *dlg_p,
|
|
|
|
const char *title)
|
2004-04-21 17:57:31 +00:00
|
|
|
{
|
2010-07-26 16:22:33 +00:00
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *bt_close;
|
|
|
|
GtkWidget *bbox;
|
2004-04-21 17:57:31 +00:00
|
|
|
|
|
|
|
|
2010-07-26 16:22:33 +00:00
|
|
|
dlg_p->win = dlg_window_new(title); /* transient_for top_level */
|
|
|
|
gtk_window_set_destroy_with_parent (GTK_WINDOW(dlg_p->win), TRUE);
|
2009-06-22 15:22:37 +00:00
|
|
|
|
2004-04-21 17:57:31 +00:00
|
|
|
gtk_window_set_default_size(GTK_WINDOW(dlg_p->win), 640, 390);
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new(FALSE, 3);
|
2010-07-26 16:22:33 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(dlg_p->win), vbox);
|
2004-04-21 17:57:31 +00:00
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
|
|
|
|
|
|
|
|
dlg_p->scrolled_win = scrolled_window_new(NULL, NULL);
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), dlg_p->scrolled_win, TRUE, TRUE, 0);
|
|
|
|
|
2009-03-16 18:01:25 +00:00
|
|
|
dlg_p->table = create_list();
|
2011-07-11 18:18:35 +00:00
|
|
|
|
2011-04-19 19:52:50 +00:00
|
|
|
gtk_widget_show(dlg_p->table);
|
2004-04-21 17:57:31 +00:00
|
|
|
|
2011-04-19 19:52:50 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(dlg_p->scrolled_win), dlg_p->table);
|
2004-04-21 17:57:31 +00:00
|
|
|
|
|
|
|
/* Button row. */
|
|
|
|
bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
|
2008-04-11 17:14:11 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
|
2004-04-21 17:57:31 +00:00
|
|
|
|
2008-04-11 17:14:11 +00:00
|
|
|
bt_close = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
|
2004-05-23 23:24:07 +00:00
|
|
|
window_set_cancel_button(dlg_p->win, bt_close, window_cancel_button_cb);
|
2004-04-21 17:57:31 +00:00
|
|
|
|
2008-04-11 23:16:06 +00:00
|
|
|
g_signal_connect(dlg_p->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
|
|
|
g_signal_connect(dlg_p->win, "destroy", G_CALLBACK(mtp3_stat_gtk_win_destroy_cb), dlg_p);
|
2004-04-21 17:57:31 +00:00
|
|
|
|
|
|
|
gtk_widget_show_all(dlg_p->win);
|
2004-05-23 23:24:07 +00:00
|
|
|
window_present(dlg_p->win);
|
2004-04-21 17:57:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
mtp3_stat_gtk_cb(
|
2010-07-26 16:22:33 +00:00
|
|
|
GtkWidget *w _U_,
|
|
|
|
gpointer d _U_)
|
2004-04-21 17:57:31 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
|
|
|
* if the window is already open, bring it to front
|
|
|
|
*/
|
|
|
|
if (dlg.win)
|
|
|
|
{
|
2011-07-21 20:12:08 +00:00
|
|
|
gdk_window_raise(gtk_widget_get_window(dlg.win));
|
2010-07-26 16:22:33 +00:00
|
|
|
return;
|
2004-04-21 17:57:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mtp3_stat_gtk_win_create(&dlg, "MTP3 Statistics");
|
|
|
|
|
2007-03-17 08:56:11 +00:00
|
|
|
mtp3_stat_draw(&mtp3_stat);
|
2004-04-21 17:57:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-08-20 22:28:49 +00:00
|
|
|
static void
|
2006-02-11 13:05:24 +00:00
|
|
|
mtp3_stat_gtk_init( const char *optarg _U_, void* userdata _U_)
|
2005-08-20 22:28:49 +00:00
|
|
|
{
|
|
|
|
mtp3_stat_gtk_cb(NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-04-21 17:57:31 +00:00
|
|
|
void
|
|
|
|
register_tap_listener_gtkmtp3_stat(void)
|
|
|
|
{
|
2010-07-26 16:22:33 +00:00
|
|
|
GString *err_p;
|
2004-04-21 17:57:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
memset((void *) &mtp3_stat, 0, sizeof(mtp3_stat_t));
|
|
|
|
|
|
|
|
err_p =
|
2010-07-26 16:22:33 +00:00
|
|
|
register_tap_listener("mtp3", &mtp3_stat, NULL, 0,
|
|
|
|
mtp3_stat_reset,
|
|
|
|
mtp3_stat_packet,
|
|
|
|
mtp3_stat_draw);
|
2004-04-21 17:57:31 +00:00
|
|
|
|
|
|
|
if (err_p != NULL)
|
|
|
|
{
|
2010-07-26 16:22:33 +00:00
|
|
|
simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, "%s", err_p->str);
|
|
|
|
g_string_free(err_p, TRUE);
|
2004-04-21 17:57:31 +00:00
|
|
|
|
2010-07-26 16:22:33 +00:00
|
|
|
exit(1);
|
2004-04-21 17:57:31 +00:00
|
|
|
}
|
|
|
|
|
2009-07-08 18:36:31 +00:00
|
|
|
register_stat_menu_item("_MTP3/MSUs", REGISTER_STAT_GROUP_TELEPHONY,
|
2004-04-21 17:57:31 +00:00
|
|
|
mtp3_stat_gtk_cb, NULL, NULL, NULL);
|
2006-02-11 13:05:24 +00:00
|
|
|
register_stat_cmd_arg("mtp3,msus", mtp3_stat_gtk_init,NULL);
|
2004-04-21 17:57:31 +00:00
|
|
|
}
|