mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-15 09:46:26 -04:00
Upstream Flathub patches (#7728)
This commit is contained in:
parent
31db3c325d
commit
7cd824ae1c
13 changed files with 169 additions and 20 deletions
|
@ -158,6 +158,18 @@ void BrowserSettingsWidget::loadSettings()
|
|||
m_ui->browserGlobalWarningWidget->setCloseButtonVisible(false);
|
||||
m_ui->browserGlobalWarningWidget->setAutoHideTimeout(-1);
|
||||
#endif
|
||||
#ifdef KEEPASSXC_DIST_FLATPAK
|
||||
// Guarantees proxy path works with different flatpak installations
|
||||
m_ui->updateBinaryPath->setChecked(true);
|
||||
m_ui->updateBinaryPath->setEnabled(false);
|
||||
// The sandbox makes custom proxy locations very unintuitive
|
||||
m_ui->useCustomProxy->setChecked(false);
|
||||
m_ui->useCustomProxy->setEnabled(false);
|
||||
m_ui->useCustomProxy->setVisible(false);
|
||||
m_ui->customProxyLocation->setVisible(false);
|
||||
// Won't work with xdg portals and executables that must be browser accessible
|
||||
m_ui->customProxyLocationBrowseButton->setVisible(false);
|
||||
#endif
|
||||
|
||||
const auto customBrowserSet = settings->customBrowserSupport();
|
||||
m_ui->customBrowserSupport->setChecked(customBrowserSet);
|
||||
|
|
|
@ -31,6 +31,9 @@ namespace BrowserShared
|
|||
const auto serverName = QStringLiteral("/org.keepassxc.KeePassXC.BrowserServer");
|
||||
#if defined(KEEPASSXC_DIST_SNAP)
|
||||
return QProcessEnvironment::systemEnvironment().value("SNAP_USER_COMMON") + serverName;
|
||||
#elif defined(KEEPASSXC_DIST_FLATPAK)
|
||||
return QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation) + "/app/" + "org.keepassxc.KeePassXC"
|
||||
+ serverName;
|
||||
#elif defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||
// Use XDG_RUNTIME_DIR instead of /tmp if it's available
|
||||
QString path = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <QJsonObject>
|
||||
#include <QMessageBox>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QRegularExpression>
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
|
||||
|
@ -214,12 +215,20 @@ QString NativeMessageInstaller::getNativeMessagePath(SupportedBrowsers browser)
|
|||
basePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
|
||||
}
|
||||
return QStringLiteral("%1/%2_%3.json").arg(basePath, HOST_NAME, getBrowserName(browser));
|
||||
#elif defined(KEEPASSXC_DIST_FLATPAK)
|
||||
// Flatpak sandboxes do not have access to the XDG_DATA_HOME and XDG_CONFIG_HOME variables
|
||||
// defined in the host, so we must hardcode them here.
|
||||
if (browser == SupportedBrowsers::TOR_BROWSER) {
|
||||
basePath = QDir::homePath() + "/.local/share";
|
||||
} else if (browser == SupportedBrowsers::FIREFOX) {
|
||||
basePath = QDir::homePath();
|
||||
} else {
|
||||
basePath = QDir::homePath() + "/.config";
|
||||
}
|
||||
#elif defined(Q_OS_LINUX)
|
||||
if (browser == SupportedBrowsers::TOR_BROWSER) {
|
||||
// Tor Browser launcher stores its config in ~/.local/share/...
|
||||
basePath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
|
||||
} else if (browser == SupportedBrowsers::FIREFOX) {
|
||||
// Firefox stores its config in ~/
|
||||
basePath = QDir::homePath();
|
||||
} else {
|
||||
basePath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
|
||||
|
@ -234,6 +243,34 @@ QString NativeMessageInstaller::getNativeMessagePath(SupportedBrowsers browser)
|
|||
return QStringLiteral("%1%2/%3.json").arg(basePath, getTargetPath(browser), HOST_NAME);
|
||||
}
|
||||
|
||||
#ifdef KEEPASSXC_DIST_FLATPAK
|
||||
/** Constructs a host accessible proxy path for use with flatpak
|
||||
*
|
||||
* @return path Path to host accessible wrapper script (org.keepassxc.KeePassXC)
|
||||
*/
|
||||
QString constructFlatpakPath()
|
||||
{
|
||||
// Find and extract the host flatpak data directory (in /var)
|
||||
QString path;
|
||||
QSettings settings("/.flatpak-info", QSettings::IniFormat);
|
||||
settings.beginGroup("Instance");
|
||||
QString appPath = settings.value("app-path").toString();
|
||||
|
||||
QRegularExpression re("^((?:/[\\.\\w-]*)+)+/app");
|
||||
QRegularExpressionMatch match = re.match(appPath);
|
||||
if (match.hasMatch()) {
|
||||
// Construct a proxy path that should work with all flatpak installations
|
||||
path = match.captured(1) + "/exports/bin/" + "org.keepassxc.KeePassXC";
|
||||
} else {
|
||||
// Fallback to the most common and default flatpak installation path
|
||||
path = "/var/lib/flatpak/exports/bin/org.keepassxc.KeePassXC";
|
||||
}
|
||||
settings.endGroup();
|
||||
|
||||
return path;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Gets the path to keepassxc-proxy binary
|
||||
*
|
||||
|
@ -247,8 +284,10 @@ QString NativeMessageInstaller::getProxyPath() const
|
|||
}
|
||||
|
||||
QString path;
|
||||
#ifdef KEEPASSXC_DIST_APPIMAGE
|
||||
#if defined(KEEPASSXC_DIST_APPIMAGE)
|
||||
path = QProcessEnvironment::systemEnvironment().value("APPIMAGE");
|
||||
#elif defined(KEEPASSXC_DIST_FLATPAK)
|
||||
path = constructFlatpakPath();
|
||||
#else
|
||||
path = QCoreApplication::applicationDirPath() + QStringLiteral("/keepassxc-proxy");
|
||||
#ifdef Q_OS_WIN
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue