Find Wireshark exe path when given .app path
Also change the default Wireshark path value to match what recent versions of Wireshark are using Fixes #288
This commit is contained in:
parent
3889780d79
commit
88ddb97a52
@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
#include <QXmlStreamReader>
|
||||||
|
|
||||||
#if defined(Q_OS_WIN32)
|
#if defined(Q_OS_WIN32)
|
||||||
QString kGzipPathDefaultValue;
|
QString kGzipPathDefaultValue;
|
||||||
@ -98,6 +99,31 @@ void Preferences::on_wiresharkPathButton_clicked()
|
|||||||
|
|
||||||
path = QFileDialog::getOpenFileName(0, "Locate Wireshark",
|
path = QFileDialog::getOpenFileName(0, "Locate Wireshark",
|
||||||
wiresharkPathEdit->text());
|
wiresharkPathEdit->text());
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
// Find executable inside app bundle using Info.plist
|
||||||
|
if (!path.isEmpty() && path.endsWith(".app")) {
|
||||||
|
QFile plist(path+"/Contents/Info.plist");
|
||||||
|
plist.open(QIODevice::ReadOnly);
|
||||||
|
QXmlStreamReader xml(&plist);
|
||||||
|
|
||||||
|
while (!xml.atEnd()) {
|
||||||
|
xml.readNext();
|
||||||
|
if (xml.isStartElement()
|
||||||
|
&& (xml.name() == "key")
|
||||||
|
&& (xml.readElementText() == "CFBundleExecutable")) {
|
||||||
|
xml.readNext(); // </key>
|
||||||
|
xml.readNext(); // <string>
|
||||||
|
if (xml.isStartElement() && (xml.name() == "string"))
|
||||||
|
path = path+"/Contents/MacOs/"+xml.readElementText();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (xml.hasError())
|
||||||
|
qDebug("%lld:%lld Error reading Info.plist: %s",
|
||||||
|
xml.lineNumber(), xml.columnNumber(),
|
||||||
|
qPrintable(xml.errorString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!path.isEmpty())
|
if (!path.isEmpty())
|
||||||
wiresharkPathEdit->setText(path);
|
wiresharkPathEdit->setText(path);
|
||||||
|
@ -31,7 +31,7 @@ const QString kWiresharkPathDefaultValue(
|
|||||||
"C:/Program Files/Wireshark/wireshark.exe");
|
"C:/Program Files/Wireshark/wireshark.exe");
|
||||||
#elif defined(Q_OS_MAC)
|
#elif defined(Q_OS_MAC)
|
||||||
const QString kWiresharkPathDefaultValue(
|
const QString kWiresharkPathDefaultValue(
|
||||||
"/Applications/Wireshark.app/Contents/Resources/bin/wireshark");
|
"/Applications/Wireshark.app/Contents/MacOS/Wireshark");
|
||||||
#else
|
#else
|
||||||
const QString kWiresharkPathDefaultValue("/usr/bin/wireshark");
|
const QString kWiresharkPathDefaultValue("/usr/bin/wireshark");
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user