2012-01-04 22:13:01 +00:00
|
|
|
/* qt_ui_utils.cpp
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-04-30 07:47:58 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2015-02-12 23:35:59 +00:00
|
|
|
#include <stdio.h>
|
2012-01-04 22:13:01 +00:00
|
|
|
#include <stdlib.h>
|
2015-02-12 23:35:59 +00:00
|
|
|
#include <string.h>
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2017-07-25 14:15:18 +00:00
|
|
|
#include <ui/qt/utils/qt_ui_utils.h>
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2015-01-29 21:55:18 +00:00
|
|
|
#include <epan/addr_resolv.h>
|
2015-06-01 23:29:17 +00:00
|
|
|
#include <epan/range.h>
|
2015-01-29 21:55:18 +00:00
|
|
|
#include <epan/to_str.h>
|
2015-02-12 23:35:59 +00:00
|
|
|
#include <epan/value_string.h>
|
|
|
|
|
|
|
|
#include <ui/recent.h>
|
Work around macOS running applications in /.
If an application is launched from the Finder, it appears to get / as
its current directory. This causes Wireshark open/save dialogs to open
up / if the user hasn't already opened a file in another directory, so
that there's no "last open directory" in the recent file.
Have get_persdatafile_dir(), on UN*X, cache the personal data directory
just as it does on Windows and, if nothing's been cached, have it fetch
the current directory and, if that succeeds *and* it's not the root
directory, use that. Otherwise, use the user's home directory.
Fixes #9862.
In addition, separate the notion of "last open directory" and "open
dialog initial directory", where the latter is the last open directory
*if* a file has been opened in this session or the recent file has the
last open directory from a previous session, otherwise it's the user's
personal data directory.
Use the latter notion in file open/save dialogs; use the former notion
when reading from and writing to the recent file.
This means we don't need to set the "last open directory" at startup
time. That way, running Wireshark without opening a file won't cause
the "last open directory" to be set, so that if a user runs it from a
directory, the "open dialog initial directory" won't be the last
directory from which Wireshark was run.
2023-11-10 08:08:48 +00:00
|
|
|
#include <ui/util.h>
|
2017-10-14 20:14:14 +00:00
|
|
|
#include "ui/ws_ui_util.h"
|
2015-01-29 21:55:18 +00:00
|
|
|
|
2012-10-19 19:04:21 +00:00
|
|
|
#include <wsutil/str_util.h>
|
2024-02-08 23:05:37 +00:00
|
|
|
#include <wsutil/file_util.h>
|
2012-01-04 22:13:01 +00:00
|
|
|
|
2015-06-05 20:17:13 +00:00
|
|
|
#include <QAction>
|
2015-11-06 16:18:05 +00:00
|
|
|
#include <QApplication>
|
2015-08-05 00:42:53 +00:00
|
|
|
#include <QDateTime>
|
2015-10-09 20:56:27 +00:00
|
|
|
#include <QDesktopServices>
|
|
|
|
#include <QDir>
|
|
|
|
#include <QFileInfo>
|
2013-10-27 22:23:27 +00:00
|
|
|
#include <QFontDatabase>
|
2015-10-09 20:56:27 +00:00
|
|
|
#include <QProcess>
|
|
|
|
#include <QUrl>
|
2019-06-29 15:02:59 +00:00
|
|
|
#include <QScreen>
|
2013-10-27 22:23:27 +00:00
|
|
|
|
2024-02-08 23:05:37 +00:00
|
|
|
#if !defined(Q_OS_WIN) && !defined(Q_OS_MAC) && defined(QT_DBUS_LIB)
|
|
|
|
#include <QtDBus/QDBusConnection>
|
|
|
|
#include <QtDBus/QDBusMessage>
|
|
|
|
#include <QtDBus/QDBusUnixFileDescriptor>
|
|
|
|
#endif
|
|
|
|
|
2013-01-18 00:50:14 +00:00
|
|
|
/*
|
|
|
|
* 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().
|
|
|
|
*/
|
2013-02-06 18:22:54 +00:00
|
|
|
|
|
|
|
gchar *qstring_strdup(QString q_string) {
|
2023-11-14 19:02:21 +00:00
|
|
|
return g_strdup(qUtf8Printable(q_string));
|
2013-02-06 18:22:54 +00:00
|
|
|
}
|
|
|
|
|
2013-01-14 22:21:11 +00:00
|
|
|
QString gchar_free_to_qstring(gchar *glib_string) {
|
2016-03-18 17:34:41 +00:00
|
|
|
return QString(gchar_free_to_qbytearray(glib_string));
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray gchar_free_to_qbytearray(gchar *glib_string)
|
|
|
|
{
|
|
|
|
QByteArray qt_bytearray(glib_string);
|
2013-01-14 22:21:11 +00:00
|
|
|
g_free(glib_string);
|
2016-03-18 17:34:41 +00:00
|
|
|
return qt_bytearray;
|
2013-01-14 22:21:11 +00:00
|
|
|
}
|
|
|
|
|
2015-06-08 18:33:16 +00:00
|
|
|
QByteArray gstring_free_to_qbytearray(GString *glib_gstring)
|
|
|
|
{
|
|
|
|
QByteArray qt_ba(glib_gstring->str);
|
|
|
|
g_string_free(glib_gstring, TRUE);
|
|
|
|
return qt_ba;
|
|
|
|
}
|
|
|
|
|
2023-08-03 11:57:43 +00:00
|
|
|
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);
|
|
|
|
return qt_ba;
|
|
|
|
}
|
|
|
|
|
2015-08-06 15:39:22 +00:00
|
|
|
const QString int_to_qstring(qint64 value, int field_width, int base)
|
2015-08-06 00:03:03 +00:00
|
|
|
{
|
|
|
|
// Qt deprecated QString::sprintf in Qt 5.0, then added ::asprintf in
|
|
|
|
// Qt 5.5. Rather than navigate a maze of QT_VERSION_CHECKs, just use
|
|
|
|
// QString::arg.
|
|
|
|
QString int_qstr;
|
|
|
|
|
|
|
|
switch (base) {
|
|
|
|
case 8:
|
|
|
|
int_qstr = "0";
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
int_qstr = "0x";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
int_qstr += QString("%1").arg(value, field_width, base, QChar('0'));
|
|
|
|
return int_qstr;
|
|
|
|
}
|
|
|
|
|
2015-02-02 17:01:29 +00:00
|
|
|
const QString address_to_qstring(const _address *address, bool enclose)
|
2015-01-29 21:55:18 +00:00
|
|
|
{
|
|
|
|
QString address_qstr = QString();
|
|
|
|
if (address) {
|
2015-02-02 17:01:29 +00:00
|
|
|
if (enclose && address->type == AT_IPv6) address_qstr += "[";
|
2015-01-29 21:55:18 +00:00
|
|
|
gchar *address_gchar_p = address_to_str(NULL, address);
|
2015-02-02 17:01:29 +00:00
|
|
|
address_qstr += address_gchar_p;
|
2015-01-29 21:55:18 +00:00
|
|
|
wmem_free(NULL, address_gchar_p);
|
2015-02-02 17:01:29 +00:00
|
|
|
if (enclose && address->type == AT_IPv6) address_qstr += "]";
|
2015-01-29 21:55:18 +00:00
|
|
|
}
|
|
|
|
return address_qstr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString address_to_display_qstring(const _address *address)
|
|
|
|
{
|
|
|
|
QString address_qstr = QString();
|
|
|
|
if (address) {
|
2016-01-20 11:59:42 +00:00
|
|
|
gchar *address_gchar_p = address_to_display(NULL, address);
|
2015-01-29 21:55:18 +00:00
|
|
|
address_qstr = address_gchar_p;
|
2016-01-20 11:59:42 +00:00
|
|
|
wmem_free(NULL, address_gchar_p);
|
2015-01-29 21:55:18 +00:00
|
|
|
}
|
|
|
|
return address_qstr;
|
|
|
|
}
|
|
|
|
|
2015-02-03 00:58:29 +00:00
|
|
|
const QString val_to_qstring(const guint32 val, const value_string *vs, const char *fmt)
|
|
|
|
{
|
2018-05-16 06:44:12 +00:00
|
|
|
QString val_qstr;
|
2015-02-03 00:58:29 +00:00
|
|
|
gchar* 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)
|
|
|
|
{
|
2018-05-16 06:44:12 +00:00
|
|
|
QString val_qstr;
|
2015-02-03 00:58:29 +00:00
|
|
|
gchar* gchar_p = val_to_str_ext_wmem(NULL, val, vse, fmt);
|
|
|
|
val_qstr = gchar_p;
|
|
|
|
wmem_free(NULL, gchar_p);
|
|
|
|
|
|
|
|
return val_qstr;
|
|
|
|
}
|
|
|
|
|
2022-01-05 12:13:42 +00:00
|
|
|
const QString range_to_qstring(const range_string *range)
|
2015-06-01 23:29:17 +00:00
|
|
|
{
|
|
|
|
QString range_qstr = QString();
|
|
|
|
if (range) {
|
2022-01-05 12:13:42 +00:00
|
|
|
range_qstr += QString("%1-%2").arg(range->value_min).arg(range->value_max);
|
2015-06-01 23:29:17 +00:00
|
|
|
}
|
|
|
|
return range_qstr;
|
|
|
|
}
|
|
|
|
|
2015-03-04 16:12:58 +00:00
|
|
|
const QString bits_s_to_qstring(const double bits_s)
|
2015-02-03 16:39:14 +00:00
|
|
|
{
|
|
|
|
return gchar_free_to_qstring(
|
2021-11-29 19:29:55 +00:00
|
|
|
format_size(bits_s, FORMAT_SIZE_UNIT_NONE, FORMAT_SIZE_PREFIX_SI));
|
2015-03-04 16:12:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const QString file_size_to_qstring(const gint64 size)
|
|
|
|
{
|
|
|
|
return gchar_free_to_qstring(
|
2021-11-29 19:29:55 +00:00
|
|
|
format_size(size, FORMAT_SIZE_UNIT_BYTES, FORMAT_SIZE_PREFIX_SI));
|
2015-02-03 16:39:14 +00:00
|
|
|
}
|
|
|
|
|
2015-08-05 00:42:53 +00:00
|
|
|
const QString time_t_to_qstring(time_t ti_time)
|
|
|
|
{
|
2021-02-14 13:47:23 +00:00
|
|
|
QDateTime date_time = QDateTime::fromSecsSinceEpoch(qint64(ti_time));
|
2015-08-05 00:42:53 +00:00
|
|
|
QString time_str = date_time.toLocalTime().toString("yyyy-MM-dd hh:mm:ss");
|
|
|
|
return time_str;
|
|
|
|
}
|
|
|
|
|
2016-09-29 18:25:52 +00:00
|
|
|
QString html_escape(const QString plain_string) {
|
|
|
|
return plain_string.toHtmlEscaped();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-27 22:23:27 +00:00
|
|
|
void smooth_font_size(QFont &font) {
|
2022-03-25 19:22:08 +00:00
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
|
|
|
|
QList<int> size_list = QFontDatabase::smoothSizes(font.family(), font.styleName());
|
|
|
|
#else
|
2013-10-27 22:23:27 +00:00
|
|
|
QFontDatabase fdb;
|
2013-10-28 01:39:20 +00:00
|
|
|
QList<int> size_list = fdb.smoothSizes(font.family(), font.styleName());
|
2022-03-25 19:22:08 +00:00
|
|
|
#endif
|
2013-10-28 01:39:20 +00:00
|
|
|
|
|
|
|
if (size_list.size() < 2) return;
|
|
|
|
|
|
|
|
int last_size = size_list.takeFirst();
|
|
|
|
foreach (int cur_size, size_list) {
|
2013-10-27 22:23:27 +00:00
|
|
|
if (font.pointSize() > last_size && font.pointSize() <= cur_size) {
|
|
|
|
font.setPointSize(cur_size);
|
2013-10-28 01:39:20 +00:00
|
|
|
return;
|
2013-10-27 22:23:27 +00:00
|
|
|
}
|
|
|
|
last_size = cur_size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-05 20:17:13 +00:00
|
|
|
bool qActionLessThan(const QAction * a1, const QAction * a2) {
|
|
|
|
return a1->text().compare(a2->text()) < 0;
|
|
|
|
}
|
|
|
|
|
Add DCE-RPC and ONC-RPC service response time dialogs.
Add RpcServiceResponseTimeDialog, which handles DCE-RPC and ONC-RPC
service response time statistics. Try to make it as lightweight as
possible, since we might want to pull this into the RPC dissectors
similar to the other SRT statistics.
Allow program names on the command line in place of numbers or UUIDs. Make
matches case-insensitive. E.g. the following are equivalent:
-z rpc,srt,100003,3
-z rpc,srt,nfs,3
-z rpc,srt,NFS,3
as are the following:
-z dcerpc,srt,f5cc5a18-4264-101a-8c59-08002b2f8426,56
-z dcerpc,srt,nspi,56
-z dcerpc,srt,NSPI,56
Change-Id: Ie451c64bf6fbc776f27d81e3bc248435c5cbc9e4
Reviewed-on: https://code.wireshark.org/review/9981
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2015-08-11 18:48:07 +00:00
|
|
|
bool qStringCaseLessThan(const QString &s1, const QString &s2)
|
|
|
|
{
|
|
|
|
return s1.compare(s2, Qt::CaseInsensitive) < 0;
|
|
|
|
}
|
|
|
|
|
2015-10-09 20:56:27 +00:00
|
|
|
void desktop_show_in_folder(const QString file_path)
|
|
|
|
{
|
|
|
|
bool success = false;
|
|
|
|
|
2022-02-14 09:24:02 +00:00
|
|
|
// https://stackoverflow.com/questions/3490336/how-to-reveal-in-finder-or-show-in-explorer-with-qt
|
2022-02-07 15:54:07 +00:00
|
|
|
|
2022-02-14 09:24:02 +00:00
|
|
|
#if defined(Q_OS_WIN)
|
2024-02-10 02:38:42 +00:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
2022-02-14 09:24:02 +00:00
|
|
|
QString command = "explorer.exe";
|
|
|
|
QStringList arguments;
|
2022-02-07 15:54:07 +00:00
|
|
|
QString path = QDir::toNativeSeparators(file_path);
|
2022-02-14 09:24:02 +00:00
|
|
|
arguments << "/select," << path + "";
|
|
|
|
success = QProcess::startDetached(command, arguments);
|
2022-02-07 15:54:07 +00:00
|
|
|
#elif defined(Q_OS_MAC)
|
2024-02-10 02:38:42 +00:00
|
|
|
//
|
|
|
|
// See
|
|
|
|
//
|
|
|
|
// https://stackoverflow.com/questions/10722740/implementing-show-in-finder-button-in-objective-c
|
|
|
|
//
|
|
|
|
// and
|
|
|
|
//
|
|
|
|
// https://stackoverflow.com/questions/7652928/launch-finder-window-with-specific-files-selected
|
|
|
|
//
|
|
|
|
// for a way to do this using Cocoa APIs, rather than running the
|
|
|
|
// osascript program to get it to do this with AppleScript.
|
|
|
|
//
|
2015-10-09 20:56:27 +00:00
|
|
|
QStringList script_args;
|
2015-10-13 19:01:25 +00:00
|
|
|
QString escaped_path = file_path;
|
2015-10-09 20:56:27 +00:00
|
|
|
|
2015-10-13 19:01:25 +00:00
|
|
|
escaped_path.replace('"', "\\\"");
|
2015-10-09 20:56:27 +00:00
|
|
|
script_args << "-e"
|
|
|
|
<< QString("tell application \"Finder\" to reveal POSIX file \"%1\"")
|
2015-10-13 19:01:25 +00:00
|
|
|
.arg(escaped_path);
|
2015-10-09 20:56:27 +00:00
|
|
|
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);
|
|
|
|
}
|
2024-02-08 23:05:37 +00:00
|
|
|
#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);
|
|
|
|
}
|
|
|
|
}
|
2015-10-09 20:56:27 +00:00
|
|
|
#else
|
2024-02-08 23:05:37 +00:00
|
|
|
// Any other possibilities to highlight the file before falling back to showing the folder?
|
2015-10-09 20:56:27 +00:00
|
|
|
#endif
|
2022-02-07 09:53:49 +00:00
|
|
|
if (!success) {
|
2021-11-28 11:43:27 +00:00
|
|
|
QFileInfo file_info(file_path);
|
2015-10-09 20:56:27 +00:00
|
|
|
QDesktopServices::openUrl(QUrl::fromLocalFile(file_info.dir().absolutePath()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-05 22:30:53 +00:00
|
|
|
bool rect_on_screen(const QRect &rect)
|
|
|
|
{
|
2019-06-29 15:02:59 +00:00
|
|
|
foreach (QScreen *screen, qApp->screens()) {
|
|
|
|
if (screen->availableGeometry().contains(rect)) {
|
2015-11-05 22:30:53 +00:00
|
|
|
return true;
|
2019-06-29 15:02:59 +00:00
|
|
|
}
|
2015-11-05 22:30:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-01-12 19:31:47 +00:00
|
|
|
void set_action_shortcuts_visible_in_context_menu(QList<QAction *> actions)
|
|
|
|
{
|
2023-02-05 15:12:36 +00:00
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
|
2020-01-12 19:31:47 +00:00
|
|
|
// For QT_VERSION >= 5.13.0 we call styleHints()->setShowShortcutsInContextMenus(true)
|
|
|
|
// in WiresharkApplication.
|
|
|
|
// QTBUG-71471
|
|
|
|
// QTBUG-61181
|
|
|
|
foreach (QAction *action, actions) {
|
|
|
|
action->setShortcutVisibleInContextMenu(true);
|
|
|
|
}
|
2020-01-14 03:50:11 +00:00
|
|
|
#else
|
|
|
|
Q_UNUSED(actions)
|
2020-01-12 19:31:47 +00:00
|
|
|
#endif
|
|
|
|
}
|
2021-04-14 13:47:07 +00:00
|
|
|
|
2021-04-19 13:54:58 +00:00
|
|
|
QVector<rtpstream_id_t *>qvector_rtpstream_ids_copy(QVector<rtpstream_id_t *> stream_ids)
|
|
|
|
{
|
|
|
|
QVector<rtpstream_id_t *>new_ids;
|
|
|
|
|
|
|
|
foreach(rtpstream_id_t *id, stream_ids) {
|
|
|
|
rtpstream_id_t *new_id = g_new0(rtpstream_id_t, 1);
|
|
|
|
rtpstream_id_copy(id, new_id);
|
|
|
|
new_ids << new_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
return new_ids;
|
|
|
|
}
|
|
|
|
|
|
|
|
void qvector_rtpstream_ids_free(QVector<rtpstream_id_t *> stream_ids)
|
|
|
|
{
|
|
|
|
foreach(rtpstream_id_t *id, stream_ids) {
|
|
|
|
rtpstream_id_free(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QString make_filter_based_on_rtpstream_id(QVector<rtpstream_id_t *> stream_ids)
|
2021-04-14 13:47:07 +00:00
|
|
|
{
|
|
|
|
QStringList stream_filters;
|
|
|
|
QString filter;
|
|
|
|
|
2021-04-19 13:54:58 +00:00
|
|
|
foreach(rtpstream_id_t *id, stream_ids) {
|
2021-04-14 13:47:07 +00:00
|
|
|
QString ip_proto = id->src_addr.type == AT_IPv6 ? "ipv6" : "ip";
|
|
|
|
stream_filters << QString("(%1.src==%2 && udp.srcport==%3 && %1.dst==%4 && udp.dstport==%5 && rtp.ssrc==0x%6)")
|
|
|
|
.arg(ip_proto) // %1
|
|
|
|
.arg(address_to_qstring(&id->src_addr)) // %2
|
|
|
|
.arg(id->src_port) // %3
|
|
|
|
.arg(address_to_qstring(&id->dst_addr)) // %4
|
|
|
|
.arg(id->dst_port) // %5
|
|
|
|
.arg(id->ssrc, 0, 16);
|
|
|
|
}
|
|
|
|
if (stream_filters.length() > 0) {
|
|
|
|
filter = stream_filters.join(" || ");
|
|
|
|
}
|
|
|
|
|
|
|
|
return filter;
|
|
|
|
}
|
|
|
|
|
Work around macOS running applications in /.
If an application is launched from the Finder, it appears to get / as
its current directory. This causes Wireshark open/save dialogs to open
up / if the user hasn't already opened a file in another directory, so
that there's no "last open directory" in the recent file.
Have get_persdatafile_dir(), on UN*X, cache the personal data directory
just as it does on Windows and, if nothing's been cached, have it fetch
the current directory and, if that succeeds *and* it's not the root
directory, use that. Otherwise, use the user's home directory.
Fixes #9862.
In addition, separate the notion of "last open directory" and "open
dialog initial directory", where the latter is the last open directory
*if* a file has been opened in this session or the recent file has the
last open directory from a previous session, otherwise it's the user's
personal data directory.
Use the latter notion in file open/save dialogs; use the former notion
when reading from and writing to the recent file.
This means we don't need to set the "last open directory" at startup
time. That way, running Wireshark without opening a file won't cause
the "last open directory" to be set, so that if a user runs it from a
directory, the "open dialog initial directory" won't be the last
directory from which Wireshark was run.
2023-11-10 08:08:48 +00:00
|
|
|
QString openDialogInitialDir()
|
2022-11-01 17:40:49 +00:00
|
|
|
{
|
|
|
|
QString result;
|
|
|
|
|
2023-11-13 21:12:37 +00:00
|
|
|
result = QString(get_open_dialog_initial_dir());
|
2022-11-01 17:40:49 +00:00
|
|
|
QDir ld(result);
|
|
|
|
if (ld.exists())
|
|
|
|
return result;
|
|
|
|
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
|
|
|
void storeLastDir(QString dir)
|
|
|
|
{
|
Work around macOS running applications in /.
If an application is launched from the Finder, it appears to get / as
its current directory. This causes Wireshark open/save dialogs to open
up / if the user hasn't already opened a file in another directory, so
that there's no "last open directory" in the recent file.
Have get_persdatafile_dir(), on UN*X, cache the personal data directory
just as it does on Windows and, if nothing's been cached, have it fetch
the current directory and, if that succeeds *and* it's not the root
directory, use that. Otherwise, use the user's home directory.
Fixes #9862.
In addition, separate the notion of "last open directory" and "open
dialog initial directory", where the latter is the last open directory
*if* a file has been opened in this session or the recent file has the
last open directory from a previous session, otherwise it's the user's
personal data directory.
Use the latter notion in file open/save dialogs; use the former notion
when reading from and writing to the recent file.
This means we don't need to set the "last open directory" at startup
time. That way, running Wireshark without opening a file won't cause
the "last open directory" to be set, so that if a user runs it from a
directory, the "open dialog initial directory" won't be the last
directory from which Wireshark was run.
2023-11-10 08:08:48 +00:00
|
|
|
/* XXX - printable? */
|
|
|
|
if (dir.length() > 0)
|
|
|
|
set_last_open_dir(qUtf8Printable(dir));
|
2022-11-01 17:40:49 +00:00
|
|
|
}
|
|
|
|
|