Exemplo n.º 1
0
void SequenceDialog::fillDiagram()
{
    if (!sainfo_ || file_closed_) return;

    QCustomPlot *sp = ui->sequencePlot;

    if (sainfo_->type == SEQ_ANALYSIS_VOIP) {
        seq_diagram_->setData(sainfo_);
    } else {
        seq_diagram_->clearData();
        sequence_analysis_list_free(sainfo_);
        sequence_analysis_list_get(cap_file_.capFile(), sainfo_);
        num_items_ = sequence_analysis_get_nodes(sainfo_);
        seq_diagram_->setData(sainfo_);
    }

    QFontMetrics vfm = QFontMetrics(sp->xAxis2->labelFont());
    char* addr_str;
    node_label_w_ = 0;
    for (guint i = 0; i < sainfo_->num_nodes; i++) {
        addr_str = (char*)address_to_display(NULL, &(sainfo_->nodes[i]));
        int label_w = vfm.width(addr_str);
        if (node_label_w_ < label_w) {
            node_label_w_ = label_w;
        }
        wmem_free(NULL, addr_str);
    }
    node_label_w_ = (node_label_w_ * 3 / 4) + one_em_;

    mouseMoved(NULL);
    resetAxes();

    // XXX QCustomPlot doesn't seem to draw any sort of focus indicator.
    sp->setFocus();
}
Exemplo n.º 2
0
void SequenceDialog::fillDiagram()
{
    QCustomPlot *sp = ui->sequencePlot;
    seq_analysis_info_t new_sa;

    new_sa = seq_analysis_;
    new_sa.list = NULL;
    new_sa.ht = NULL;
    new_sa.num_nodes = 0;
    sequence_analysis_list_get(cap_file_, &new_sa);
    num_items_ = sequence_analysis_get_nodes(&new_sa);
    seq_diagram_->setData(&new_sa);
    sequence_analysis_list_free(&seq_analysis_);
    seq_analysis_ = new_sa;

    QFontMetrics vfm = QFontMetrics(sp->xAxis2->labelFont());
    node_label_w_ = 0;
    for (guint i = 0; i < seq_analysis_.num_nodes; i++) {
        int label_w = vfm.width(ep_address_to_display(&(seq_analysis_.nodes[i])));
        if (node_label_w_ < label_w) {
            node_label_w_ = label_w;
        }
    }
    node_label_w_ = (node_label_w_ * 3 / 4) + one_em_;

    mouseMoved(NULL);
    resetAxes();

    // XXX QCustomPlot doesn't seem to draw any sort of focus indicator.
    sp->setFocus();
}
Exemplo n.º 3
0
void LBMUIMFlowDialog::fillDiagram(void)
{
    QCustomPlot * sp = m_ui->sequencePlot;
    seq_analysis_info_t new_sa;

    new_sa = m_sequence_analysis;
    new_sa.items = g_queue_new();
    new_sa.ht = NULL;
    new_sa.num_nodes = 0;
    lbm_uimflow_get_analysis(m_capture_file, &new_sa);
    m_num_items = sequence_analysis_get_nodes(&new_sa);
    m_sequence_diagram->setData(&new_sa);
    sequence_analysis_list_free(&m_sequence_analysis);
    m_sequence_analysis = new_sa;

    QFontMetrics vfm = QFontMetrics(sp->xAxis2->labelFont());
    m_node_label_width = 0;
    for (guint i = 0; i < m_sequence_analysis.num_nodes; i++)
    {
        QString addr_str = address_to_display_qstring(&(m_sequence_analysis.nodes[i]));
        int label_w = vfm.width(addr_str);
        if (m_node_label_width < label_w)
        {
            m_node_label_width = label_w;
        }
    }
    m_node_label_width = (m_node_label_width * 3 / 4) + m_one_em;

    mouseMoved(NULL);
    resetAxes();

    // XXX QCustomPlot doesn't seem to draw any sort of focus indicator.
    sp->setFocus();
}
Exemplo n.º 4
0
void SequenceDialog::fillDiagram()
{
    if (!info_->sainfo() || file_closed_) return;

    QCustomPlot *sp = ui->sequencePlot;

    if (info_->sainfo()->type == SEQ_ANALYSIS_VOIP) {
        seq_diagram_->setData(info_->sainfo());
    } else {
        seq_diagram_->clearData();
        sequence_analysis_list_free(info_->sainfo());
        sequence_analysis_list_get(cap_file_.capFile(), info_->sainfo());
        num_items_ = sequence_analysis_get_nodes(info_->sainfo());
        seq_diagram_->setData(info_->sainfo());
    }

    sequence_w_ = one_em_ * 15 ; // Arbitrary

    mouseMoved(NULL);
    resetAxes();

    // XXX QCustomPlot doesn't seem to draw any sort of focus indicator.
    sp->setFocus();
}
Exemplo n.º 5
0
SequenceDialog::SequenceDialog(QWidget &parent, CaptureFile &cf, seq_analysis_info_t *sainfo) :
    WiresharkDialog(parent, cf),
    ui(new Ui::SequenceDialog),
    sainfo_(sainfo),
    num_items_(0),
    packet_num_(0),
    node_label_w_(20)
{
    ui->setupUi(this);
    QCustomPlot *sp = ui->sequencePlot;
    setWindowSubtitle(sainfo ? tr("Call Flow") : tr("Flow"));

    if (!sainfo_) {
        sainfo_ = sequence_analysis_info_new();
        sainfo_->type = SEQ_ANALYSIS_ANY;
        sainfo_->all_packets = TRUE;
    } else {
        num_items_ = sequence_analysis_get_nodes(sainfo_);
    }

    seq_diagram_ = new SequenceDiagram(sp->yAxis, sp->xAxis2, sp->yAxis2);
    sp->addPlottable(seq_diagram_);
    sp->axisRect()->setRangeDragAxes(sp->xAxis2, sp->yAxis);

    sp->xAxis->setVisible(false);
    sp->xAxis->setPadding(0);
    sp->xAxis->setLabelPadding(0);
    sp->xAxis->setTickLabelPadding(0);
    sp->xAxis2->setVisible(true);
    sp->yAxis2->setVisible(true);

    one_em_ = QFontMetrics(sp->yAxis->labelFont()).height();
    ui->horizontalScrollBar->setSingleStep(100 / one_em_);
    ui->verticalScrollBar->setSingleStep(100 / one_em_);

    sp->setInteractions(QCP::iRangeDrag);

    ui->gridLayout->setSpacing(0);
    connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), sp->yAxis2, SLOT(setRange(QCPRange)));

    ctx_menu_.addAction(ui->actionReset);
    ctx_menu_.addSeparator();
    ctx_menu_.addAction(ui->actionMoveRight10);
    ctx_menu_.addAction(ui->actionMoveLeft10);
    ctx_menu_.addAction(ui->actionMoveUp10);
    ctx_menu_.addAction(ui->actionMoveDown10);
    ctx_menu_.addAction(ui->actionMoveRight1);
    ctx_menu_.addAction(ui->actionMoveLeft1);
    ctx_menu_.addAction(ui->actionMoveUp1);
    ctx_menu_.addAction(ui->actionMoveDown1);
    ctx_menu_.addSeparator();
    ctx_menu_.addAction(ui->actionGoToPacket);

    ui->showComboBox->blockSignals(true);
    ui->showComboBox->setCurrentIndex(0);
    ui->showComboBox->blockSignals(false);
    ui->addressComboBox->blockSignals(true);
    ui->addressComboBox->setCurrentIndex(0);
    ui->addressComboBox->blockSignals(false);

    QComboBox *fcb = ui->flowComboBox;
    fcb->addItem(ui->actionFlowAny->text(), SEQ_ANALYSIS_ANY);
    fcb->addItem(ui->actionFlowTcp->text(), SEQ_ANALYSIS_TCP);

    ui->flowComboBox->blockSignals(true);
    ui->flowComboBox->setCurrentIndex(sainfo_->type);

    if (sainfo_->type == SEQ_ANALYSIS_VOIP) {
        ui->controlFrame->hide();
    } else {
        ui->flowComboBox->blockSignals(false);
    }

    QPushButton *save_bt = ui->buttonBox->button(QDialogButtonBox::Save);
    save_bt->setText(tr("Save As" UTF8_HORIZONTAL_ELLIPSIS));

    // XXX Use recent settings instead
    resize(parent.width(), parent.height() * 4 / 5);

    connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(hScrollBarChanged(int)));
    connect(ui->verticalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(vScrollBarChanged(int)));
    connect(sp->xAxis2, SIGNAL(rangeChanged(QCPRange)), this, SLOT(xAxisChanged(QCPRange)));
    connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(yAxisChanged(QCPRange)));
    connect(sp, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(diagramClicked(QMouseEvent*)));
    connect(sp, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoved(QMouseEvent*)));
    connect(sp, SIGNAL(mouseRelease(QMouseEvent*)), this, SLOT(mouseReleased(QMouseEvent*)));
    connect(this, SIGNAL(goToPacket(int)), seq_diagram_, SLOT(setSelectedPacket(int)));

    disconnect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));

    fillDiagram();
}
Exemplo n.º 6
0
SequenceDialog::SequenceDialog(QWidget &parent, CaptureFile &cf, SequenceInfo *info) :
    WiresharkDialog(parent, cf),
    ui(new Ui::SequenceDialog),
    info_(info),
    num_items_(0),
    packet_num_(0),
    sequence_w_(1)
{
    ui->setupUi(this);
    loadGeometry(parent.width(), parent.height() * 4 / 5);

    QCustomPlot *sp = ui->sequencePlot;
    setWindowSubtitle(info_ ? tr("Call Flow") : tr("Flow"));

    if (!info_) {
        info_ = new SequenceInfo(sequence_analysis_info_new());
        info_->sainfo()->type = SEQ_ANALYSIS_ANY;
        info_->sainfo()->all_packets = TRUE;
    } else {
        info_->ref();
        num_items_ = sequence_analysis_get_nodes(info_->sainfo());
    }

    seq_diagram_ = new SequenceDiagram(sp->yAxis, sp->xAxis2, sp->yAxis2);
    sp->addPlottable(seq_diagram_);

    // When dragging is enabled it's easy to drag past the lower and upper
    // bounds of each axis. Disable it for now.
    //sp->axisRect()->setRangeDragAxes(sp->xAxis2, sp->yAxis);
    //sp->setInteractions(QCP::iRangeDrag);

    sp->xAxis->setVisible(false);
    sp->xAxis->setPadding(0);
    sp->xAxis->setLabelPadding(0);
    sp->xAxis->setTickLabelPadding(0);

    QPen base_pen(ColorUtils::alphaBlend(palette().text(), palette().base(), 0.25));
    base_pen.setWidthF(0.5);
    sp->xAxis2->setBasePen(base_pen);
    sp->yAxis->setBasePen(base_pen);
    sp->yAxis2->setBasePen(base_pen);

    sp->xAxis2->setVisible(true);
    sp->yAxis2->setVisible(true);

    key_text_ = new QCPItemText(sp);
    key_text_->setText(tr("Time"));
    sp->addItem(key_text_);

    key_text_->setPositionAlignment(Qt::AlignRight | Qt::AlignVCenter);
    key_text_->position->setType(QCPItemPosition::ptAbsolute);
    key_text_->setClipToAxisRect(false);

    comment_text_ = new QCPItemText(sp);
    comment_text_->setText(tr("Comment"));
    sp->addItem(comment_text_);

    comment_text_->setPositionAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    comment_text_->position->setType(QCPItemPosition::ptAbsolute);
    comment_text_->setClipToAxisRect(false);

    one_em_ = QFontMetrics(sp->yAxis->labelFont()).height();
    ui->horizontalScrollBar->setSingleStep(100 / one_em_);
    ui->verticalScrollBar->setSingleStep(100 / one_em_);

    ui->gridLayout->setSpacing(0);
    connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), sp->yAxis2, SLOT(setRange(QCPRange)));

    ctx_menu_.addAction(ui->actionReset);
    ctx_menu_.addSeparator();
    ctx_menu_.addAction(ui->actionMoveRight10);
    ctx_menu_.addAction(ui->actionMoveLeft10);
    ctx_menu_.addAction(ui->actionMoveUp10);
    ctx_menu_.addAction(ui->actionMoveDown10);
    ctx_menu_.addAction(ui->actionMoveRight1);
    ctx_menu_.addAction(ui->actionMoveLeft1);
    ctx_menu_.addAction(ui->actionMoveUp1);
    ctx_menu_.addAction(ui->actionMoveDown1);
    ctx_menu_.addSeparator();
    ctx_menu_.addAction(ui->actionGoToPacket);
    ctx_menu_.addAction(ui->actionGoToNextPacket);
    ctx_menu_.addAction(ui->actionGoToPreviousPacket);

    ui->showComboBox->setCurrentIndex(0);
    ui->addressComboBox->setCurrentIndex(0);

    QComboBox *fcb = ui->flowComboBox;
    fcb->addItem(ui->actionFlowAny->text(), SEQ_ANALYSIS_ANY);
    fcb->addItem(ui->actionFlowTcp->text(), SEQ_ANALYSIS_TCP);

    ui->flowComboBox->setCurrentIndex(info_->sainfo()->type);

    if (info_->sainfo()->type == SEQ_ANALYSIS_VOIP) {
        ui->flowComboBox->blockSignals(true);
        ui->controlFrame->hide();
    }

    QPushButton *save_bt = ui->buttonBox->button(QDialogButtonBox::Save);
    save_bt->setText(tr("Save As" UTF8_HORIZONTAL_ELLIPSIS));

    ProgressFrame::addToButtonBox(ui->buttonBox, &parent);

    connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(hScrollBarChanged(int)));
    connect(ui->verticalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(vScrollBarChanged(int)));
    connect(sp->xAxis2, SIGNAL(rangeChanged(QCPRange)), this, SLOT(xAxisChanged(QCPRange)));
    connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(yAxisChanged(QCPRange)));
    connect(sp, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(diagramClicked(QMouseEvent*)));
    connect(sp, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoved(QMouseEvent*)));
    connect(sp, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheeled(QWheelEvent*)));
    connect(this, SIGNAL(goToPacket(int)), seq_diagram_, SLOT(setSelectedPacket(int)));

    disconnect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
}