void ServiceResponseTimeDialog::fillTree()
{
    srt_data_t srt_data;
    srt_data.srt_array = g_array_new(FALSE, TRUE, sizeof(srt_stat_table*));
    srt_data.user_data = this;

    srt_table_dissector_init(srt_, srt_data.srt_array, NULL, NULL);

    QString display_filter = displayFilter();
    GString *error_string = register_tap_listener(get_srt_tap_listener_name(srt_),
                          &srt_data,
                          display_filter.toUtf8().constData(),
                          0,
                          tapReset,
                          get_srt_packet_func(srt_),
                          tapDraw);
    if (error_string) {
        QMessageBox::critical(this, tr("Failed to attach to tap \"%1\"").arg(get_srt_tap_listener_name(srt_)),
                             error_string->str);
        g_string_free(error_string, TRUE);
        g_array_free(srt_data.srt_array, TRUE);
        srt_data.srt_array = NULL;
        reject(); // XXX Stay open instead?
        return;
    }

    statsTreeWidget()->setSortingEnabled(false);

    cap_file_.retapPackets();

    // We only have one table. Move its tree items up one level.
    if (statsTreeWidget()->invisibleRootItem()->childCount() == 1) {
        statsTreeWidget()->setRootIndex(statsTreeWidget()->model()->index(0, 0));
    }

    tapDraw(&srt_data);

    statsTreeWidget()->sortItems(SRT_COLUMN_PROCEDURE, Qt::AscendingOrder);
    statsTreeWidget()->setSortingEnabled(true);

    remove_tap_listener(&srt_data);
    g_array_free(srt_data.srt_array, TRUE);
}
Пример #2
0
static void
init_srt_tables(register_srt_t* srt, const char *filter)
{
	srt_t *ui;
	GString *error_string;

	ui = g_new0(srt_t, 1);
	ui->type = proto_get_protocol_short_name(find_protocol_by_id(get_srt_proto_id(srt)));
	ui->filter = g_strdup(filter);
	ui->data.srt_array = global_srt_array;
	ui->data.user_data = ui;

	error_string = register_tap_listener(get_srt_tap_listener_name(srt), &ui->data, filter, 0, NULL, get_srt_packet_func(srt), srt_draw, NULL);
	if (error_string) {
		free_srt_table(srt, global_srt_array);
		g_free(ui);
		cmdarg_err("Couldn't register srt tap: %s", error_string->str);
		g_string_free(error_string, TRUE);
		exit(1);
	}
}