diff options
author | Pascal Quantin <pascal.quantin@gmail.com> | 2015-10-14 23:33:27 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2015-10-16 06:23:52 +0000 |
commit | 3946005c6588c500e25f85a6a0dbb822851f67cc (patch) | |
tree | 2232fc1e3b4413cd745bd20e5c30708157c87f21 /ui/qt/follow_stream_dialog.cpp | |
parent | 969c307820f03a98f3fe1980e0903cb8e2b6e6b0 (diff) |
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>
Diffstat (limited to 'ui/qt/follow_stream_dialog.cpp')
-rw-r--r-- | ui/qt/follow_stream_dialog.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/ui/qt/follow_stream_dialog.cpp b/ui/qt/follow_stream_dialog.cpp index e4b8d3a36b..cbba065bdd 100644 --- a/ui/qt/follow_stream_dialog.cpp +++ b/ui/qt/follow_stream_dialog.cpp @@ -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) { |