From 2e9f247e292e1d0ebe088c2532479e721bdf0e9a Mon Sep 17 00:00:00 2001 From: Janek Bevendorff Date: Mon, 26 Feb 2018 00:26:28 +0100 Subject: [PATCH] Enable proper KeePassXC-Browser interaction for AppImage --- AppImage-Recipe.sh | 5 +++++ src/browser/BrowserOptionDialog.cpp | 6 ++++++ src/browser/HostInstaller.cpp | 11 +++++++++++ 3 files changed, 22 insertions(+) diff --git a/AppImage-Recipe.sh b/AppImage-Recipe.sh index 342dd0840..96e7b4099 100755 --- a/AppImage-Recipe.sh +++ b/AppImage-Recipe.sh @@ -88,6 +88,11 @@ unset XDG_DATA_DIRS if [ "\${1}" == "cli" ]; then shift exec keepassxc-cli "\$@" +elif [ "\${1}" == "proxy" ]; then + shift + exec keepassxc-proxy "\$@" +elif [ -v CHROME_WRAPPER ] || [ -v MOZ_LAUNCHED_CHILD ]; then + exec keepassxc-proxy "\$@" else exec keepassxc "\$@" fi diff --git a/src/browser/BrowserOptionDialog.cpp b/src/browser/BrowserOptionDialog.cpp index f6d634a82..39b514fde 100755 --- a/src/browser/BrowserOptionDialog.cpp +++ b/src/browser/BrowserOptionDialog.cpp @@ -19,6 +19,7 @@ #include "BrowserOptionDialog.h" #include "ui_BrowserOptionDialog.h" +#include "config-keepassx.h" #include "BrowserSettings.h" #include "core/FilePath.h" @@ -45,6 +46,11 @@ BrowserOptionDialog::BrowserOptionDialog(QWidget* parent) : connect(m_ui->useCustomProxy, SIGNAL(toggled(bool)), m_ui->customProxyLocation, SLOT(setEnabled(bool))); connect(m_ui->useCustomProxy, SIGNAL(toggled(bool)), m_ui->customProxyLocationBrowseButton, SLOT(setEnabled(bool))); connect(m_ui->customProxyLocationBrowseButton, SIGNAL(clicked()), this, SLOT(showProxyLocationFileDialog())); + +#ifdef KEEPASSXC_DIST_APPIMAGE + m_ui->supportBrowserProxy->setChecked(true); + m_ui->supportBrowserProxy->setEnabled(false); +#endif } BrowserOptionDialog::~BrowserOptionDialog() diff --git a/src/browser/HostInstaller.cpp b/src/browser/HostInstaller.cpp index 9271da69e..9b27ab1cf 100644 --- a/src/browser/HostInstaller.cpp +++ b/src/browser/HostInstaller.cpp @@ -17,12 +17,14 @@ */ #include "HostInstaller.h" +#include "config-keepassx.h" #include #include #include #include #include #include +#include #include const QString HostInstaller::HOST_NAME = "org.keepassxc.keepassxc_browser"; @@ -161,6 +163,13 @@ QString HostInstaller::getInstallDir(SupportedBrowsers browser) const QJsonObject HostInstaller::constructFile(SupportedBrowsers browser, const bool& proxy, const QString& location) { QString path; +#ifdef KEEPASSXC_DIST_APPIMAGE + if (proxy && !location.isEmpty()) { + path = location; + } else { + path = QProcessEnvironment::systemEnvironment().value("APPIMAGE"); + } +#else if (proxy) { if (!location.isEmpty()) { path = location; @@ -178,6 +187,8 @@ QJsonObject HostInstaller::constructFile(SupportedBrowsers browser, const bool& path.replace("/","\\"); #endif +#endif // #ifdef KEEPASSXC_DIST_APPIMAGE + QJsonObject script; script["name"] = HostInstaller::HOST_NAME; script["description"] = "KeePassXC integration with native messaging support";