From 8d793e9a8316dbc09bcab23013916f78e4ca50c3 Mon Sep 17 00:00:00 2001 From: cd2357 Date: Sun, 13 Sep 2020 12:19:44 +0200 Subject: [PATCH] Show info popup if Bisq started under Qubes OS Show popup informing the user about the OS-specific setup guide. --- .../src/main/java/bisq/common/util/Utilities.java | 13 +++++++++++++ .../main/java/bisq/core/app/BisqHeadlessApp.java | 1 + core/src/main/java/bisq/core/app/BisqSetup.java | 15 +++++++++++++++ .../main/resources/i18n/displayStrings.properties | 3 +++ .../java/bisq/desktop/main/MainViewModel.java | 9 +++++++++ 5 files changed, 41 insertions(+) diff --git a/common/src/main/java/bisq/common/util/Utilities.java b/common/src/main/java/bisq/common/util/Utilities.java index 291baa6843d..d12c2d0a593 100644 --- a/common/src/main/java/bisq/common/util/Utilities.java +++ b/common/src/main/java/bisq/common/util/Utilities.java @@ -161,6 +161,19 @@ public static boolean isWindows() { return getOSName().contains("win"); } + /** + * @return True, if Bisq is running on a virtualized OS within Qubes, false otherwise + */ + public static boolean isQubesOS() { + // For Linux qubes, "os.version" looks like "4.19.132-1.pvops.qubes.x86_64" + // The presence of the "qubes" substring indicates this Linux is running as a qube + // This is the case for all 3 virtualization modes (PV, PVH, HVM) + // In addition, this works for both simple AppVMs, as well as for StandaloneVMs + // TODO This might not work for detecting Qubes virtualization for other OSes + // like Windows + return getOSVersion().contains("qubes"); + } + public static boolean isOSX() { return getOSName().contains("mac") || getOSName().contains("darwin"); } diff --git a/core/src/main/java/bisq/core/app/BisqHeadlessApp.java b/core/src/main/java/bisq/core/app/BisqHeadlessApp.java index b93d1697885..03140f8dfad 100644 --- a/core/src/main/java/bisq/core/app/BisqHeadlessApp.java +++ b/core/src/main/java/bisq/core/app/BisqHeadlessApp.java @@ -98,6 +98,7 @@ protected void setupHandlers() { bisqSetup.setShowPopupIfInvalidBtcConfigHandler(() -> log.error("onShowPopupIfInvalidBtcConfigHandler")); bisqSetup.setRevolutAccountsUpdateHandler(revolutAccountList -> log.info("setRevolutAccountsUpdateHandler: revolutAccountList={}", revolutAccountList)); bisqSetup.setOsxKeyLoggerWarningHandler(() -> log.info("setOsxKeyLoggerWarningHandler")); + bisqSetup.setQubesOSInfoHandler(() -> log.info("setQubesOSInfoHandler")); //TODO move to bisqSetup corruptedDatabaseFilesHandler.getCorruptedDatabaseFiles().ifPresent(files -> log.warn("getCorruptedDatabaseFiles. files={}", files)); diff --git a/core/src/main/java/bisq/core/app/BisqSetup.java b/core/src/main/java/bisq/core/app/BisqSetup.java index 164f74a04da..15c657552d4 100644 --- a/core/src/main/java/bisq/core/app/BisqSetup.java +++ b/core/src/main/java/bisq/core/app/BisqSetup.java @@ -232,6 +232,9 @@ default void onRequestWalletPassword() { @Setter @Nullable private Runnable osxKeyLoggerWarningHandler; + @Setter + @Nullable + private Runnable qubesOSInfoHandler; @Getter final BooleanProperty newVersionAvailableProperty = new SimpleBooleanProperty(false); @@ -357,6 +360,7 @@ private void step2() { checkCryptoSetup(); checkForCorrectOSArchitecture(); checkOSXVersion(); + checkIfRunningOnQubesOS(); } private void step3() { @@ -678,6 +682,17 @@ private void checkOSXVersion() { } } + /** + * If Bisq is running on an OS that is virtualized under Qubes, show info popup with + * link to the Setup Guide. The guide documents what other steps are needed, in + * addition to installing the Linux package (qube sizing, etc) + */ + private void checkIfRunningOnQubesOS() { + if (Utilities.isQubesOS() && qubesOSInfoHandler != null) { + qubesOSInfoHandler.run(); + } + } + private void initDomainServices() { log.info("initDomainServices"); diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 753d8bc3394..405bd88f504 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -2759,6 +2759,9 @@ popup.info.shutDownWithOpenOffers=Bisq is being shut down, but there are open of they will be re-published to the P2P network the next time you start Bisq.\n\n\ To keep your offers online, keep Bisq running and make sure this computer remains online too \ (i.e., make sure it doesn't go into standby mode...monitor standby is not a problem). +popup.info.qubesOSSetupInfo=It appears you are running Bisq on Qubes OS. \n\n\ + Please make sure your Bisq qube is setup according to our Setup Guide at \ + https://bisq.wiki/Running_Bisq_on_Qubes popup.privateNotification.headline=Important private notification! diff --git a/desktop/src/main/java/bisq/desktop/main/MainViewModel.java b/desktop/src/main/java/bisq/desktop/main/MainViewModel.java index 1fd34cb7bd8..95ea9fb148a 100644 --- a/desktop/src/main/java/bisq/desktop/main/MainViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/MainViewModel.java @@ -397,6 +397,15 @@ private void setupHandlers() { .show(); } }); + bisqSetup.setQubesOSInfoHandler(() -> { + String key = "qubesOSSetupInfo"; + if (preferences.showAgain(key)) { + new Popup().information(Res.get("popup.info.qubesOSSetupInfo")) + .closeButtonText(Res.get("shared.iUnderstand")) + .dontShowAgainId(key) + .show(); + } + }); corruptedDatabaseFilesHandler.getCorruptedDatabaseFiles().ifPresent(files -> new Popup() .warning(Res.get("popup.warning.incompatibleDB", files.toString(), config.appDataDir))