Qt: add ability to save raw output to follow window
Bug: 11118 Change-Id: Idd383c16453c06d95bd9cec3f8e9be8daee49f5e Reviewed-on: https://code.wireshark.org/review/11047 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
969c307820
commit
3946005c65
|
@ -61,7 +61,8 @@ typedef enum {
|
|||
SHOW_HEXDUMP,
|
||||
SHOW_CARRAY,
|
||||
SHOW_RAW,
|
||||
SHOW_YAML
|
||||
SHOW_YAML,
|
||||
SHOW_UTF8
|
||||
} show_type_t;
|
||||
|
||||
typedef enum {
|
||||
|
|
|
@ -1027,6 +1027,7 @@ follow_show(follow_info_t *follow_info,
|
|||
break;
|
||||
|
||||
case SHOW_YAML:
|
||||
case SHOW_UTF8:
|
||||
g_assert_not_reached();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -92,8 +92,9 @@ FollowStreamDialog::FollowStreamDialog(QWidget &parent, CaptureFile &cf, follow_
|
|||
cbcs->addItem(tr("C Arrays"), SHOW_CARRAY);
|
||||
cbcs->addItem(tr("EBCDIC"), SHOW_EBCDIC);
|
||||
cbcs->addItem(tr("Hex Dump"), SHOW_HEXDUMP);
|
||||
cbcs->addItem(tr("UTF-8"), SHOW_RAW);
|
||||
cbcs->addItem(tr("UTF-8"), SHOW_UTF8);
|
||||
cbcs->addItem(tr("YAML"), SHOW_YAML);
|
||||
cbcs->addItem(tr("Raw"), SHOW_RAW);
|
||||
cbcs->blockSignals(false);
|
||||
|
||||
b_filter_out_ = ui->buttonBox->addButton(tr("Hide this stream"), QDialogButtonBox::ActionRole);
|
||||
|
@ -226,7 +227,7 @@ void FollowStreamDialog::saveAs()
|
|||
|
||||
readStream();
|
||||
|
||||
if (follow_info_.show_type != SHOW_RAW)
|
||||
if ((follow_info_.show_type != SHOW_RAW) && (follow_info_.show_type != SHOW_UTF8))
|
||||
{
|
||||
out << ui->teStreamContent->toPlainText();
|
||||
}
|
||||
|
@ -541,7 +542,12 @@ void FollowStreamDialog::addText(QString text, gboolean is_from_server, guint32
|
|||
size_t nwritten;
|
||||
int FileDescriptor = file_.handle();
|
||||
FILE* fh = fdopen(dup(FileDescriptor), "wb");
|
||||
nwritten = fwrite(text.toUtf8().constData(), text.length(), 1, fh);
|
||||
if (follow_info_.show_type == SHOW_RAW) {
|
||||
QByteArray binstream = QByteArray::fromHex(text.toUtf8());
|
||||
nwritten = fwrite(binstream.constData(), binstream.length(), 1, fh);
|
||||
} else {
|
||||
nwritten = fwrite(text.toUtf8().constData(), text.length(), 1, fh);
|
||||
}
|
||||
fclose(fh);
|
||||
if ((int)nwritten != text.length()) {
|
||||
#if 0
|
||||
|
@ -681,7 +687,7 @@ FollowStreamDialog::showBuffer(char *buffer, size_t nchars, gboolean is_from_ser
|
|||
break;
|
||||
}
|
||||
|
||||
case SHOW_RAW: // UTF-8
|
||||
case SHOW_UTF8: // UTF-8
|
||||
{
|
||||
// The QString docs say that invalid characters will be replaced with
|
||||
// replacement characters or removed. It would be nice if we could
|
||||
|
@ -807,6 +813,14 @@ FollowStreamDialog::showBuffer(char *buffer, size_t nchars, gboolean is_from_ser
|
|||
addText(yaml_text, is_from_server, packet_num);
|
||||
break;
|
||||
}
|
||||
|
||||
case SHOW_RAW:
|
||||
{
|
||||
QByteArray ba = QByteArray(buffer, (int)nchars).toHex();
|
||||
ba += '\n';
|
||||
addText(ba, is_from_server, packet_num);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (last_packet_ == 0) {
|
||||
|
|
Loading…
Reference in New Issue