diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/follow.h | 3 | ||||
-rw-r--r-- | ui/gtk/follow_stream.c | 1 | ||||
-rw-r--r-- | ui/qt/follow_stream_dialog.cpp | 22 |
3 files changed, 21 insertions, 5 deletions
diff --git a/ui/follow.h b/ui/follow.h index 496873d818..1ece30ebf1 100644 --- a/ui/follow.h +++ b/ui/follow.h @@ -61,7 +61,8 @@ typedef enum { SHOW_HEXDUMP, SHOW_CARRAY, SHOW_RAW, - SHOW_YAML + SHOW_YAML, + SHOW_UTF8 } show_type_t; typedef enum { diff --git a/ui/gtk/follow_stream.c b/ui/gtk/follow_stream.c index 656f622c99..29445fc93c 100644 --- a/ui/gtk/follow_stream.c +++ b/ui/gtk/follow_stream.c @@ -1027,6 +1027,7 @@ follow_show(follow_info_t *follow_info, break; case SHOW_YAML: + case SHOW_UTF8: g_assert_not_reached(); break; } 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) { |