diff options
Diffstat (limited to 'ui/qt/utils')
-rw-r--r-- | ui/qt/utils/color_utils.cpp | 5 | ||||
-rw-r--r-- | ui/qt/utils/color_utils.h | 10 | ||||
-rw-r--r-- | ui/qt/utils/data_printer.cpp | 54 | ||||
-rw-r--r-- | ui/qt/utils/data_printer.h | 5 | ||||
-rw-r--r-- | ui/qt/utils/frame_information.cpp | 4 | ||||
-rw-r--r-- | ui/qt/utils/profile_switcher.cpp | 140 | ||||
-rw-r--r-- | ui/qt/utils/profile_switcher.h | 48 | ||||
-rw-r--r-- | ui/qt/utils/proto_node.cpp | 4 | ||||
-rw-r--r-- | ui/qt/utils/qt_ui_utils.cpp | 116 | ||||
-rw-r--r-- | ui/qt/utils/qt_ui_utils.h | 12 | ||||
-rw-r--r-- | ui/qt/utils/rtp_audio_file.cpp | 16 | ||||
-rw-r--r-- | ui/qt/utils/rtp_audio_file.h | 10 | ||||
-rw-r--r-- | ui/qt/utils/rtp_audio_routing_filter.cpp | 2 | ||||
-rw-r--r-- | ui/qt/utils/wireshark_zip_helper.cpp | 9 | ||||
-rw-r--r-- | ui/qt/utils/wireshark_zip_helper.h | 6 |
15 files changed, 350 insertions, 91 deletions
diff --git a/ui/qt/utils/color_utils.cpp b/ui/qt/utils/color_utils.cpp index e7e396d0..6024fdb8 100644 --- a/ui/qt/utils/color_utils.cpp +++ b/ui/qt/utils/color_utils.cpp @@ -222,3 +222,8 @@ const QColor ColorUtils::warningBackground() } return QColor(tango_butter_2); } + +const QColor ColorUtils::disabledForeground() +{ + return alphaBlend(QApplication::palette().windowText(), QApplication::palette().window(), 0.65); +} diff --git a/ui/qt/utils/color_utils.h b/ui/qt/utils/color_utils.h index a205cccc..ac5ed02e 100644 --- a/ui/qt/utils/color_utils.h +++ b/ui/qt/utils/color_utils.h @@ -12,8 +12,6 @@ #include <config.h> -#include <glib.h> - #include <epan/color_filters.h> #include <QBrush> @@ -82,11 +80,17 @@ public: */ static const QColor warningBackground(); + /** + * Returns an appropriate foreground color for disabled text. + * @return The foreground color. + */ + static const QColor disabledForeground(); + private: static QList<QRgb> graph_colors_; static QList<QRgb> sequence_colors_; }; -void color_filter_qt_add_cb(color_filter_t *colorf, gpointer user_data); +void color_filter_qt_add_cb(color_filter_t *colorf, void *user_data); #endif // COLOR_UTILS_H diff --git a/ui/qt/utils/data_printer.cpp b/ui/qt/utils/data_printer.cpp index 3c3e910a..f3635ee4 100644 --- a/ui/qt/utils/data_printer.cpp +++ b/ui/qt/utils/data_printer.cpp @@ -34,6 +34,22 @@ void DataPrinter::toClipboard(DataPrinter::DumpType type, IDataPrintable * print switch(type) { + case DP_GoLiteral: + clipboard_text += QString("[]byte{"); + for (int i = 0; i < printData.length(); i++) { + if (i>0) clipboard_text += ", "; + clipboard_text += QString("0x%1").arg((uint8_t) printData[i], 1, 16, QChar('0')); + } + clipboard_text += QString("}"); + break; + case DP_CArray: + clipboard_text += QString("unsigned char bytes[] = {"); + for (int i = 0; i < printData.length(); i++) { + if (i>0) clipboard_text += ", "; + clipboard_text += QString("0x%1").arg((uint8_t) printData[i], 1, 16, QChar('0')); + } + clipboard_text += QString("};"); + break; case DP_CString: // Beginning quote clipboard_text += QString("\""); @@ -86,12 +102,21 @@ void DataPrinter::toClipboard(DataPrinter::DumpType type, IDataPrintable * print for (int i = 0; i < printData.length(); i++) clipboard_text += QString("%1").arg((uint8_t) printData[i], 2, 16, QChar('0')); break; - case DP_PrintableText: + case DP_UTF8Text: + // This automatically compensates for invalid UTF-8 in the input +#if WS_IS_AT_LEAST_GNUC_VERSION(12,1) +DIAG_OFF(stringop-overread) +#endif + clipboard_text += QString::fromUtf8(printData); +#if WS_IS_AT_LEAST_GNUC_VERSION(12,1) +DIAG_ON(stringop-overread) +#endif + break; + case DP_ASCIIText: + // Copy valid 7-bit printable ASCII bytes, skip the rest for (int i = 0; i < printData.length(); i++) { QChar ch(printData[i]); - // This interprets ch as Latin-1. We might want to use ASCII - // printable only. - if (ch.isSpace() || ch.isPrint()) { + if (ch.isSpace() || (ch > (char)0x20 && ch < (char)0x7F)) { clipboard_text += ch; } } @@ -261,9 +286,14 @@ QActionGroup * DataPrinter::copyActions(QObject * copyClass, QObject * data) action->setProperty("printertype", DataPrinter::DP_HexOnly); connect(action, &QAction::triggered, dpi, &DataPrinter::copyIDataBytes); - action = new QAction(tr("…as Printable Text"), actions); - action->setToolTip(tr("Copy only the printable text in the packet.")); - action->setProperty("printertype", DataPrinter::DP_PrintableText); + action = new QAction(tr("…as UTF-8 Text"), actions); + action->setToolTip(tr("Copy packet bytes as text, treating as UTF-8.")); + action->setProperty("printertype", DataPrinter::DP_UTF8Text); + connect(action, &QAction::triggered, dpi, &DataPrinter::copyIDataBytes); + + action = new QAction(tr("…as ASCII Text"), actions); + action->setToolTip(tr("Copy packet bytes as text, treating as ASCII.")); + action->setProperty("printertype", DataPrinter::DP_ASCIIText); connect(action, &QAction::triggered, dpi, &DataPrinter::copyIDataBytes); action = new QAction(tr("…as a Hex Stream"), actions); @@ -286,6 +316,16 @@ QActionGroup * DataPrinter::copyActions(QObject * copyClass, QObject * data) action->setProperty("printertype", DataPrinter::DP_CString); connect(action, &QAction::triggered, dpi, &DataPrinter::copyIDataBytes); + action = new QAction(tr("…as Go literal"), actions); + action->setToolTip(tr("Copy packet bytes as Go literal.")); + action->setProperty("printertype", DataPrinter::DP_GoLiteral); + connect(action, &QAction::triggered, dpi, &DataPrinter::copyIDataBytes); + + action = new QAction(tr("…as C Array"), actions); + action->setToolTip(tr("Copy packet bytes as C Array.")); + action->setProperty("printertype", DataPrinter::DP_CArray); + connect(action, &QAction::triggered, dpi, &DataPrinter::copyIDataBytes); + return actions; } diff --git a/ui/qt/utils/data_printer.h b/ui/qt/utils/data_printer.h index 882b5752..52c259f8 100644 --- a/ui/qt/utils/data_printer.h +++ b/ui/qt/utils/data_printer.h @@ -30,8 +30,11 @@ public: DP_HexDump, DP_HexOnly, DP_HexStream, - DP_PrintableText, + DP_UTF8Text, + DP_ASCIIText, DP_CString, + DP_GoLiteral, + DP_CArray, DP_MimeData, DP_Base64 }; diff --git a/ui/qt/utils/frame_information.cpp b/ui/qt/utils/frame_information.cpp index d344bc04..facd368d 100644 --- a/ui/qt/utils/frame_information.cpp +++ b/ui/qt/utils/frame_information.cpp @@ -48,13 +48,13 @@ void FrameInformation::loadFrameTree() edt_ = g_new0(epan_dissect_t, 1); /* proto tree, visible. We need a proto tree if there's custom columns */ - epan_dissect_init(edt_, cap_file_->capFile()->epan, TRUE, TRUE); + epan_dissect_init(edt_, cap_file_->capFile()->epan, true, true); col_custom_prime_edt(edt_, &(cap_file_->capFile()->cinfo)); epan_dissect_run(edt_, cap_file_->capFile()->cd_t, &rec_, frame_tvbuff_new_buffer(&cap_file_->capFile()->provider, fi_, &buf_), fi_, &(cap_file_->capFile()->cinfo)); - epan_dissect_fill_in_columns(edt_, TRUE, TRUE); + epan_dissect_fill_in_columns(edt_, true, true); } FrameInformation::~FrameInformation() diff --git a/ui/qt/utils/profile_switcher.cpp b/ui/qt/utils/profile_switcher.cpp new file mode 100644 index 00000000..ded1b1f5 --- /dev/null +++ b/ui/qt/utils/profile_switcher.cpp @@ -0,0 +1,140 @@ +/* profile_switcher.cpp + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +// #include <capture_file.h> +#include <main_application.h> + +#include <ui/profile.h> +#include <ui/recent.h> + +#include <ui/qt/capture_file.h> +#include <ui/qt/models/packet_list_model.h> + +#include "profile_switcher.h" + +#include "file.h" + +#include <epan/epan.h> +#include <epan/epan_dissect.h> +#include <epan/prefs.h> +#include "frame_tvbuff.h" + +// Enable switching iff: +// - We're opening a new capture file via the UI. +// - We haven't changed our profile, either manually or automatically. + +ProfileSwitcher::ProfileSwitcher(QObject *parent) : + QObject(parent), + capture_file_changed_(true), + profile_changed_(false) +{ + if (g_list_length(current_profile_list()) == 0) { + init_profile_list(); + } + connect(mainApp, &MainApplication::profileChanging, this, &ProfileSwitcher::disableSwitching); +} + +void ProfileSwitcher::captureEventHandler(CaptureEvent ev) +{ + if (ev.captureContext() != CaptureEvent::File) { + return; + } + + CaptureFile *capture_file = qobject_cast<CaptureFile *>(sender()); + if (!capture_file) { + return; + } + + // CaptureEvent doesn't have a "this is the same file" flag, so + // track that via the filename. + switch (ev.eventType()) { + case CaptureEvent::Opened: + if (previous_cap_file_ != capture_file->filePath()) { + capture_file_changed_ = true; + profile_changed_ = false; + } + break; + case CaptureEvent::Closing: + previous_cap_file_ = capture_file->filePath(); + break; + default: + break; + } +} + +void ProfileSwitcher::checkPacket(capture_file *cap_file, frame_data *fdata, qsizetype row) +{ + if (profile_changed_ || !capture_file_changed_ || row >= recent.gui_profile_switch_check_count) { + return; + } + + if (row == 0) { + clearProfileFilters(); + for (GList *cur = current_profile_list() ; cur; cur = cur->next) { + profile_def *profile = static_cast<profile_def *>(cur->data); + if (!profile->auto_switch_filter) { + continue; + } + dfilter_t *dfcode; + if (dfilter_compile(profile->auto_switch_filter, &dfcode, NULL) && dfcode) { + profile_filters_.append({profile->name, dfcode}); + } + } + } + + if (profile_filters_.empty()) { + return; + } + + QString new_profile; + wtap_rec rec; + Buffer buf; + wtap_rec_init(&rec); + ws_buffer_init(&buf, 1514); + epan_dissect_t edt; + + for (auto &cur_filter : profile_filters_) { + if (!cf_read_record(cap_file, fdata, &rec, &buf)) { + continue; + } + epan_dissect_init(&edt, cap_file->epan, TRUE, FALSE); + epan_dissect_prime_with_dfilter(&edt, cur_filter.dfcode); + epan_dissect_run(&edt, cap_file->cd_t, &rec, + frame_tvbuff_new_buffer(&cap_file->provider, fdata, &buf), + fdata, NULL); + bool matched = dfilter_apply_edt(cur_filter.dfcode, &edt); + epan_dissect_cleanup(&edt); + if (matched) { + new_profile = cur_filter.name; + break; + } + } + + wtap_rec_cleanup(&rec); + ws_buffer_free(&buf); + + if (!new_profile.isEmpty()) { + clearProfileFilters(); + previous_cap_file_ = cap_file->filename; + mainApp->setConfigurationProfile(qUtf8Printable(new_profile), false); + } +} + +void ProfileSwitcher::clearProfileFilters() +{ + for (auto &cur_filter : profile_filters_) { + dfilter_free(cur_filter.dfcode); + } + profile_filters_.clear(); +} + +void ProfileSwitcher::disableSwitching() +{ + profile_changed_ = true; +} diff --git a/ui/qt/utils/profile_switcher.h b/ui/qt/utils/profile_switcher.h new file mode 100644 index 00000000..57dfd255 --- /dev/null +++ b/ui/qt/utils/profile_switcher.h @@ -0,0 +1,48 @@ +/** @file + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#pragma once + +#include <config.h> + +#include "capture_event.h" +#include "cfile.h" + +#include <QObject> +#include <QVector> + +struct profile_switch_filter { + QString name; + dfilter_t *dfcode; +}; + +class PacketListModel; + +class ProfileSwitcher : public QObject +{ + Q_OBJECT +public: + explicit ProfileSwitcher(QObject *parent = nullptr); + +public slots: + void captureEventHandler(CaptureEvent ev); + void checkPacket(capture_file *cap_file, frame_data *fdata, qsizetype row); + +private: + PacketListModel *packet_list_model_; + QVector<struct profile_switch_filter> profile_filters_; + bool capture_file_changed_; + bool profile_changed_; + QString previous_cap_file_; + + void clearProfileFilters(); + +private slots: + void disableSwitching(); +}; diff --git a/ui/qt/utils/proto_node.cpp b/ui/qt/utils/proto_node.cpp index 68d1f4c7..222b2d5e 100644 --- a/ui/qt/utils/proto_node.cpp +++ b/ui/qt/utils/proto_node.cpp @@ -12,6 +12,7 @@ #include <epan/prefs.h> +// NOLINTNEXTLINE(misc-no-recursion) ProtoNode::ProtoNode(proto_node *node, ProtoNode *parent) : node_(node), parent_(parent) { @@ -28,6 +29,7 @@ ProtoNode::ProtoNode(proto_node *node, ProtoNode *parent) : for (proto_node *child = node_->first_child; child; child = child->next) { if (!isHidden(child)) { + // We recurse here, but we're limited by tree depth checks in epan m_children.append(new ProtoNode(child, this)); } } @@ -70,7 +72,7 @@ QString ProtoNode::labelText() const label = fi->rep->representation; } else { /* no, make a generic label */ - gchar label_str[ITEM_LABEL_LENGTH]; + char label_str[ITEM_LABEL_LENGTH]; proto_item_fill_label(fi, label_str); label = label_str; } diff --git a/ui/qt/utils/qt_ui_utils.cpp b/ui/qt/utils/qt_ui_utils.cpp index 9dad9dd9..addfe208 100644 --- a/ui/qt/utils/qt_ui_utils.cpp +++ b/ui/qt/utils/qt_ui_utils.cpp @@ -17,15 +17,13 @@ #include <epan/range.h> #include <epan/to_str.h> #include <epan/value_string.h> -#include <epan/prefs.h> #include <ui/recent.h> #include <ui/util.h> #include "ui/ws_ui_util.h" #include <wsutil/str_util.h> - -#include <ui/qt/main_application.h> +#include <wsutil/file_util.h> #include <QAction> #include <QApplication> @@ -36,24 +34,31 @@ #include <QFontDatabase> #include <QProcess> #include <QUrl> -#include <QUuid> #include <QScreen> +#if defined(Q_OS_MAC) +#include <ui/macosx/cocoa_bridge.h> +#elif !defined(Q_OS_WIN) && defined(QT_DBUS_LIB) +#include <QtDBus/QDBusConnection> +#include <QtDBus/QDBusMessage> +#include <QtDBus/QDBusUnixFileDescriptor> +#endif + /* * We might want to create our own "wsstring" class with convenience * methods for handling g_malloc()ed strings, GStrings, and a shortcut * to .toUtf8().constData(). */ -gchar *qstring_strdup(QString q_string) { - return g_strdup(q_string.toUtf8().constData()); +char *qstring_strdup(QString q_string) { + return g_strdup(qUtf8Printable(q_string)); } -QString gchar_free_to_qstring(gchar *glib_string) { +QString gchar_free_to_qstring(char *glib_string) { return QString(gchar_free_to_qbytearray(glib_string)); } -QByteArray gchar_free_to_qbytearray(gchar *glib_string) +QByteArray gchar_free_to_qbytearray(char *glib_string) { QByteArray qt_bytearray(glib_string); g_free(glib_string); @@ -70,7 +75,7 @@ QByteArray gstring_free_to_qbytearray(GString *glib_gstring) QByteArray gbytearray_free_to_qbytearray(GByteArray *glib_array) { QByteArray qt_ba(reinterpret_cast<char *>(glib_array->data), glib_array->len); - g_byte_array_free(glib_array, TRUE); + g_byte_array_free(glib_array, true); return qt_ba; } @@ -101,7 +106,7 @@ const QString address_to_qstring(const _address *address, bool enclose) QString address_qstr = QString(); if (address) { if (enclose && address->type == AT_IPv6) address_qstr += "["; - gchar *address_gchar_p = address_to_str(NULL, address); + char *address_gchar_p = address_to_str(NULL, address); address_qstr += address_gchar_p; wmem_free(NULL, address_gchar_p); if (enclose && address->type == AT_IPv6) address_qstr += "]"; @@ -113,27 +118,27 @@ const QString address_to_display_qstring(const _address *address) { QString address_qstr = QString(); if (address) { - gchar *address_gchar_p = address_to_display(NULL, address); + char *address_gchar_p = address_to_display(NULL, address); address_qstr = address_gchar_p; wmem_free(NULL, address_gchar_p); } return address_qstr; } -const QString val_to_qstring(const guint32 val, const value_string *vs, const char *fmt) +const QString val_to_qstring(const uint32_t val, const value_string *vs, const char *fmt) { QString val_qstr; - gchar* gchar_p = val_to_str_wmem(NULL, val, vs, fmt); + char* gchar_p = val_to_str_wmem(NULL, val, vs, fmt); val_qstr = gchar_p; wmem_free(NULL, gchar_p); return val_qstr; } -const QString val_ext_to_qstring(const guint32 val, value_string_ext *vse, const char *fmt) +const QString val_ext_to_qstring(const uint32_t val, value_string_ext *vse, const char *fmt) { QString val_qstr; - gchar* gchar_p = val_to_str_ext_wmem(NULL, val, vse, fmt); + char* gchar_p = val_to_str_ext_wmem(NULL, val, vse, fmt); val_qstr = gchar_p; wmem_free(NULL, gchar_p); @@ -155,7 +160,7 @@ const QString bits_s_to_qstring(const double bits_s) format_size(bits_s, FORMAT_SIZE_UNIT_NONE, FORMAT_SIZE_PREFIX_SI)); } -const QString file_size_to_qstring(const gint64 size) +const QString file_size_to_qstring(const int64_t size) { return gchar_free_to_qstring( format_size(size, FORMAT_SIZE_UNIT_BYTES, FORMAT_SIZE_PREFIX_SI)); @@ -209,28 +214,55 @@ void desktop_show_in_folder(const QString file_path) // https://stackoverflow.com/questions/3490336/how-to-reveal-in-finder-or-show-in-explorer-with-qt #if defined(Q_OS_WIN) + // + // See + // + // https://stackoverflow.com/questions/13680415/how-to-open-explorer-with-a-specific-file-selected + // + // for a way to do this using Windows Shell APIs, rather than having + // to fire up a separate instance of Windows Explorer. + // QString command = "explorer.exe"; QStringList arguments; QString path = QDir::toNativeSeparators(file_path); arguments << "/select," << path + ""; success = QProcess::startDetached(command, arguments); #elif defined(Q_OS_MAC) - QStringList script_args; - QString escaped_path = file_path; - - escaped_path.replace('"', "\\\""); - script_args << "-e" - << QString("tell application \"Finder\" to reveal POSIX file \"%1\"") - .arg(escaped_path); - if (QProcess::execute("/usr/bin/osascript", script_args) == 0) { - success = true; - script_args.clear(); - script_args << "-e" - << "tell application \"Finder\" to activate"; - QProcess::execute("/usr/bin/osascript", script_args); + CocoaBridge::showInFinder(file_path.toUtf8()); + success = true; +#elif defined(QT_DBUS_LIB) + // First, try the FileManager1 DBus interface's "ShowItems" method. + // https://www.freedesktop.org/wiki/Specifications/file-manager-interface/ + QDBusMessage message = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.FileManager1"), + QLatin1String("/org/freedesktop/FileManager1"), + QLatin1String("org.freedesktop.FileManager1"), + QLatin1String("ShowItems")); + QStringList uris(QUrl::fromLocalFile(file_path).toString()); + message << uris << QString(); + + message = QDBusConnection::sessionBus().call(message); + success = message.type() == QDBusMessage::ReplyMessage; + + // If that failed, perhaps we are sandboxed. Try using Portal Services. + // https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.OpenURI.html + if (!success) { + const int fd = ws_open(QFile::encodeName(file_path), O_CLOEXEC | O_PATH, 0000); + if (fd != -1) { + QDBusUnixFileDescriptor descriptor; + descriptor.giveFileDescriptor(fd); + QDBusMessage message = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.portal.Desktop"), + QLatin1String("/org/freedesktop/portal/desktop"), + QLatin1String("org.freedesktop.portal.OpenURI"), + QLatin1String("OpenDirectory")); + message << QString() << QVariant::fromValue(descriptor) << QVariantMap(); + + message = QDBusConnection::sessionBus().call(message); + success = message.type() == QDBusMessage::ReplyMessage; + ws_close(fd); + } } #else - // Is there a way to highlight the file using xdg-open? + // Any other possibilities to highlight the file before falling back to showing the folder? #endif if (!success) { QFileInfo file_info(file_path); @@ -251,7 +283,7 @@ bool rect_on_screen(const QRect &rect) void set_action_shortcuts_visible_in_context_menu(QList<QAction *> actions) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) && QT_VERSION < QT_VERSION_CHECK(5, 13, 0) +#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) // For QT_VERSION >= 5.13.0 we call styleHints()->setShowShortcutsInContextMenus(true) // in WiresharkApplication. // QTBUG-71471 @@ -310,27 +342,7 @@ QString openDialogInitialDir() { QString result; - switch (prefs.gui_fileopen_style) { - - case FO_STYLE_LAST_OPENED: - /* The user has specified that we should start out in the last directory - we looked in. If we've already opened a file, use its containing - directory, if we could determine it, as the directory, otherwise - use the "last opened" directory saved in the preferences file if - there was one. */ - /* This is now the default behaviour in file_selection_new() */ - result = QString(get_open_dialog_initial_dir()); - break; - - case FO_STYLE_SPECIFIED: - /* The user has specified that we should always start out in a - specified directory; if they've specified that directory, - start out by showing the files in that dir. */ - if (prefs.gui_fileopen_dir[0] != '\0') - result = QString(prefs.gui_fileopen_dir); - break; - } - + result = QString(get_open_dialog_initial_dir()); QDir ld(result); if (ld.exists()) return result; diff --git a/ui/qt/utils/qt_ui_utils.h b/ui/qt/utils/qt_ui_utils.h index 60ccf31d..24888b03 100644 --- a/ui/qt/utils/qt_ui_utils.h +++ b/ui/qt/utils/qt_ui_utils.h @@ -61,7 +61,7 @@ struct epan_range; * * @return A copy of the QString. UTF-8 allocated with g_malloc(). */ -gchar *qstring_strdup(QString q_string); +char *qstring_strdup(QString q_string); /** Transfer ownership of a GLib character string to a newly constructed QString * @@ -70,7 +70,7 @@ gchar *qstring_strdup(QString q_string); * * @return A QString instance created from the input string. */ -QString gchar_free_to_qstring(gchar *glib_string); +QString gchar_free_to_qstring(char *glib_string); /** Transfer ownership of a GLib character string to a newly constructed QString * @@ -79,7 +79,7 @@ QString gchar_free_to_qstring(gchar *glib_string); * * @return A QByteArray instance created from the input string. */ -QByteArray gchar_free_to_qbytearray(gchar *glib_string); +QByteArray gchar_free_to_qbytearray(char *glib_string); /** Transfer ownership of a GLib character string to a newly constructed QByteArray * @@ -133,7 +133,7 @@ const QString address_to_display_qstring(const struct _address *address); * * @return A QString representation of the value_string. */ -const QString val_to_qstring(const guint32 val, const struct _value_string *vs, const char *fmt) +const QString val_to_qstring(const uint32_t val, const struct _value_string *vs, const char *fmt) G_GNUC_PRINTF(3, 0); /** Convert a value_string_ext to a QString using val_to_str_ext_wmem(). @@ -144,7 +144,7 @@ G_GNUC_PRINTF(3, 0); * * @return A QString representation of the value_string_ext. */ -const QString val_ext_to_qstring(const guint32 val, struct _value_string_ext *vse, const char *fmt) +const QString val_ext_to_qstring(const uint32_t val, struct _value_string_ext *vse, const char *fmt) G_GNUC_PRINTF(3, 0); /** Convert a range to a QString using range_convert_range(). @@ -169,7 +169,7 @@ const QString bits_s_to_qstring(const double bits_s); * * @return A QString representation of the file size in SI units. */ -const QString file_size_to_qstring(const gint64 size); +const QString file_size_to_qstring(const int64_t size); /** Convert a time_t value to a human-readable QString using QDateTime. * diff --git a/ui/qt/utils/rtp_audio_file.cpp b/ui/qt/utils/rtp_audio_file.cpp index 591a63bb..8b349182 100644 --- a/ui/qt/utils/rtp_audio_file.cpp +++ b/ui/qt/utils/rtp_audio_file.cpp @@ -14,7 +14,7 @@ * File uses Frame as piece of information. One Frame match audio of one * decoded packet or audio silence in between them. Frame holds information * about frame type (audio/silence), its length and realtime position and - * sample possition (where decoded audio is really stored, with gaps omitted). + * sample position (where decoded audio is really stored, with gaps omitted). * * There are three stages of the object use * - writing data by frames during decoding of the stream @@ -124,7 +124,7 @@ void RtpAudioFile::frameUpdateSampleCounters(qint64 written_bytes) sample_pos_ += written_bytes; } -qint64 RtpAudioFile::frameWriteFrame(guint32 frame_num, qint64 real_pos, qint64 sample_pos, qint64 len, rtp_frame_type type) +qint64 RtpAudioFile::frameWriteFrame(uint32_t frame_num, qint64 real_pos, qint64 sample_pos, qint64 len, rtp_frame_type type) { rtp_frame_info frame_info; @@ -137,7 +137,7 @@ qint64 RtpAudioFile::frameWriteFrame(guint32 frame_num, qint64 real_pos, qint64 return sample_file_frame_->write((char *)&frame_info, sizeof(frame_info)); } -void RtpAudioFile::frameWriteSilence(guint32 frame_num, qint64 samples) +void RtpAudioFile::frameWriteSilence(uint32_t frame_num, qint64 samples) { if (samples < 1) return; @@ -147,9 +147,9 @@ void RtpAudioFile::frameWriteSilence(guint32 frame_num, qint64 samples) frameUpdateRealCounters(silence_bytes); } -qint64 RtpAudioFile::frameWriteSamples(guint32 frame_num, const char *data, qint64 max_size) +qint64 RtpAudioFile::frameWriteSamples(uint32_t frame_num, const char *data, qint64 max_size) { - gint64 written; + int64_t written; written = sample_file_->write(data, max_size); @@ -170,15 +170,15 @@ void RtpAudioFile::setFrameReadStage(qint64 prepend_samples) { sample_file_frame_->seek(0); if (prepend_samples > 0) { - // Skip first frame which contains openning silence + // Skip first frame which contains opening silence sample_file_frame_->read((char *)&cur_frame_, sizeof(cur_frame_)); } } -bool RtpAudioFile::readFrameSamples(gint32 *read_buff_bytes, SAMPLE **read_buff, spx_uint32_t *read_len, guint32 *frame_num, rtp_frame_type *type) +bool RtpAudioFile::readFrameSamples(int32_t *read_buff_bytes, SAMPLE **read_buff, spx_uint32_t *read_len, uint32_t *frame_num, rtp_frame_type *type) { rtp_frame_info frame_info; - guint64 read_bytes = 0; + uint64_t read_bytes = 0; if (!sample_file_frame_->read((char *)&frame_info, sizeof(frame_info))) { // Can't read frame, some error occurred diff --git a/ui/qt/utils/rtp_audio_file.h b/ui/qt/utils/rtp_audio_file.h index addc3015..b8c53b30 100644 --- a/ui/qt/utils/rtp_audio_file.h +++ b/ui/qt/utils/rtp_audio_file.h @@ -33,7 +33,7 @@ typedef struct { qint64 real_pos; qint64 sample_pos; qint64 len; - guint32 frame_num; + uint32_t frame_num; rtp_frame_type type; } rtp_frame_info; @@ -46,12 +46,12 @@ public: // Functions for writing Frames void setFrameWriteStage(); - void frameWriteSilence(guint32 frame_num, qint64 samples); - qint64 frameWriteSamples(guint32 frame_num, const char *data, qint64 max_size); + void frameWriteSilence(uint32_t frame_num, qint64 samples); + qint64 frameWriteSamples(uint32_t frame_num, const char *data, qint64 max_size); // Functions for reading Frames void setFrameReadStage(qint64 prepend_samples); - bool readFrameSamples(gint32 *read_buff_bytes, SAMPLE **read_buff, spx_uint32_t *read_len, guint32 *frame_num, rtp_frame_type *type); + bool readFrameSamples(int32_t *read_buff_bytes, SAMPLE **read_buff, spx_uint32_t *read_len, uint32_t *frame_num, rtp_frame_type *type); // Functions for reading data during play void setDataReadStage(); @@ -80,7 +80,7 @@ private: rtp_frame_info cur_frame_; // Functions for writing Frames - qint64 frameWriteFrame(guint32 frame_num, qint64 real_pos, qint64 sample_pos, qint64 len, rtp_frame_type type); + qint64 frameWriteFrame(uint32_t frame_num, qint64 real_pos, qint64 sample_pos, qint64 len, rtp_frame_type type); void frameUpdateRealCounters(qint64 written_bytes); void frameUpdateSampleCounters(qint64 written_bytes); diff --git a/ui/qt/utils/rtp_audio_routing_filter.cpp b/ui/qt/utils/rtp_audio_routing_filter.cpp index 8362d3f9..fd2b48d7 100644 --- a/ui/qt/utils/rtp_audio_routing_filter.cpp +++ b/ui/qt/utils/rtp_audio_routing_filter.cpp @@ -64,7 +64,7 @@ qint64 AudioRoutingFilter::readData(char *data, qint64 maxSize) return input_->read(data, maxSize); } else { // For stereo - gint64 silence = 0; + int64_t silence = 0; // Read half of data qint64 readBytes = input_->read(data, maxSize/SAMPLE_BYTES); diff --git a/ui/qt/utils/wireshark_zip_helper.cpp b/ui/qt/utils/wireshark_zip_helper.cpp index 7bfa0101..bcf670ad 100644 --- a/ui/qt/utils/wireshark_zip_helper.cpp +++ b/ui/qt/utils/wireshark_zip_helper.cpp @@ -11,17 +11,18 @@ #include <ui/qt/utils/wireshark_zip_helper.h> -#ifdef HAVE_MINIZIP +#if defined(HAVE_MINIZIP) || defined(HAVE_MINIZIPNG) #include "config.h" -#include "glib.h" - #include <iosfwd> #include <iostream> #include <zlib.h> // For Z_DEFLATED, etc. +#ifdef HAVE_MINIZIP #include <minizip/unzip.h> #include <minizip/zip.h> - +#else +#include <minizip-ng/mz_compat.h> +#endif #include "epan/prefs.h" #include "wsutil/file_util.h" diff --git a/ui/qt/utils/wireshark_zip_helper.h b/ui/qt/utils/wireshark_zip_helper.h index 2f8e39f8..7845f70a 100644 --- a/ui/qt/utils/wireshark_zip_helper.h +++ b/ui/qt/utils/wireshark_zip_helper.h @@ -16,9 +16,13 @@ #include <QDir> -#ifdef HAVE_MINIZIP +#if defined(HAVE_MINIZIP) || defined(HAVE_MINIZIPNG) +#ifdef HAVE_MINIZIP #include "minizip/zip.h" +#else +#include "minizip-ng/mz_compat.h" +#endif class WiresharkZipHelper { |