Add malwarebytes notice

This commit is contained in:
crschnick committed 2023-12-25 20:09:43 +00:00
1 parent 86758f06b7
commit 829deddc1d
10 files changed
+123 -60

No files matched your search

@@ -1,25 +0,0 @@
package io.xpipe.app.core;
import io.xpipe.app.Main;
import javafx.scene.Scene;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
public class AppSplashScreen {
public static void show() {
var stage = new Stage();
stage.setWidth(500);
stage.setHeight(500);
stage.setResizable(false);
stage.initStyle(StageStyle.TRANSPARENT);
var content = new ImageView(
Main.class.getResource("resources/img/loading.gif").toString());
var scene = new Scene(new Pane(content), -1, -1, false);
stage.setScene(scene);
stage.show();
}
}
@@ -1,6 +1,7 @@
package io.xpipe.app.core;
package io.xpipe.app.core.check;
import io.xpipe.app.comp.base.MarkdownComp;
import io.xpipe.app.core.*;
import io.xpipe.app.core.mode.OperationMode;
import io.xpipe.app.util.PlatformState;
import io.xpipe.app.util.WindowsRegistry;
@@ -13,9 +14,9 @@ import javafx.scene.control.ButtonType;
import java.nio.file.Files;
import java.util.Optional;
public class AppAntivirusAlert {
public class AppAvBlockCheck {
public static Optional<String> detect() {
private static Optional<String> detect() {
var bitdefender = WindowsRegistry.readString(WindowsRegistry.HKEY_LOCAL_MACHINE,"SOFTWARE\\Bitdefender", "InstallDir");
if (bitdefender.isPresent()) {
return Optional.of("Bitdefender");
@@ -24,7 +25,7 @@ public class AppAntivirusAlert {
return Optional.empty();
}
public static void showIfNeeded() throws Throwable {
public static void check() throws Throwable {
// Only show this on first launch on windows
if (OsType.getLocal() != OsType.WINDOWS || !AppState.get().isInitialLaunch()) {
return;
@@ -0,0 +1,58 @@
package io.xpipe.app.core.check;
import io.xpipe.app.comp.base.MarkdownComp;
import io.xpipe.app.core.*;
import io.xpipe.app.util.PlatformState;
import io.xpipe.app.util.WindowsRegistry;
import io.xpipe.core.process.OsType;
import javafx.geometry.Insets;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonBar;
import javafx.scene.control.ButtonType;
import java.nio.file.Files;
public class AppMalwarebytesCheck {
private static boolean detect() {
var reg = WindowsRegistry.readString(WindowsRegistry.HKEY_LOCAL_MACHINE,"SOFTWARE\\Malwarebytes", "id");
if (reg.isPresent()) {
return true;
}
return false;
}
public static void check() throws Throwable {
// Only show this on first launch on windows
if (OsType.getLocal() != OsType.WINDOWS || AppCache.get("malwarebytesSeen", Boolean.class,() -> false)) {
return;
}
var found = detect();
if (!found) {
return;
}
PlatformState.initPlatformOrThrow();
AppStyle.init();
AppImages.init();
var a = AppWindowHelper.showBlockingAlert(alert -> {
alert.setTitle(AppI18n.get("malwarebytesNoticeTitle"));
alert.setAlertType(Alert.AlertType.NONE);
AppResources.with(
AppResources.XPIPE_MODULE,
"misc/malwarebytes.md",
file -> {
var markdown = new MarkdownComp(Files.readString(file), s -> s).prefWidth(550).prefHeight(500).createRegion();
alert.getDialogPane().setContent(markdown);
alert.getDialogPane().setPadding(new Insets(15));
});
alert.getButtonTypes().add(new ButtonType(AppI18n.get("gotIt"), ButtonBar.ButtonData.OK_DONE));
});
a.filter(b -> b.getButtonData().isDefaultButton())
.ifPresentOrElse(buttonType -> {}, () -> AppCache.update("malwarebytesSeen", true));
}
}
@@ -0,0 +1,34 @@
package io.xpipe.app.core.check;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.core.process.OsType;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
public class AppTempCheck {
private static void checkTemp(String tmpdir) {
Path dir = null;
try {
dir = Path.of(tmpdir);
} catch (InvalidPathException ignored) {
}
if (dir == null || !Files.exists(dir) || !Files.isDirectory(dir)) {
ErrorEvent.fromThrowable(
new IOException("Specified temporary directory " + tmpdir + ", set via the environment variable %TEMP% is invalid."))
.term()
.handle();
}
}
public static void check() {
if (OsType.getLocal().equals(OsType.WINDOWS)) {
checkTemp(System.getProperty("java.io.tmpdir"));
checkTemp(System.getenv("TEMP"));
}
}
}
@@ -1,16 +1,14 @@
package io.xpipe.app.core;
package io.xpipe.app.core.check;
import io.xpipe.app.core.AppProperties;
import io.xpipe.app.issue.ErrorEvent;
import io.xpipe.core.process.OsType;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
public class AppChecks {
public class AppUserDirectoryCheck {
public static void checkDirectoryPermissions() {
public static void check() {
var dataDirectory = AppProperties.get().getDataDir();
try {
@@ -29,26 +27,4 @@ public class AppChecks {
.handle();
}
}
private static void checkTemp(String tmpdir) {
Path dir = null;
try {
dir = Path.of(tmpdir);
} catch (InvalidPathException ignored) {
}
if (dir == null || !Files.exists(dir) || !Files.isDirectory(dir)) {
ErrorEvent.fromThrowable(
new IOException("Specified temporary directory " + tmpdir + ", set via the environment variable %TEMP% is invalid."))
.term()
.handle();
}
}
public static void checkTemp() {
if (OsType.getLocal().equals(OsType.WINDOWS)) {
checkTemp(System.getProperty("java.io.tmpdir"));
checkTemp(System.getenv("TEMP"));
}
}
}
@@ -3,6 +3,8 @@ package io.xpipe.app.core.mode;
import io.xpipe.app.browser.BrowserModel;
import io.xpipe.app.comp.store.StoreViewState;
import io.xpipe.app.core.*;
import io.xpipe.app.core.check.AppAvBlockCheck;
import io.xpipe.app.core.check.AppMalwarebytesCheck;
import io.xpipe.app.ext.ActionProvider;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs;
@@ -47,7 +49,8 @@ public class BaseMode extends OperationMode {
// Also loaded before antivirus alert to localize that
AppI18n.init();
LicenseProvider.get().init();
AppAntivirusAlert.showIfNeeded();
AppAvBlockCheck.check();
AppMalwarebytesCheck.check();
LocalShell.init();
XPipeDistributionType.init();
AppPrefs.init();
@@ -1,6 +1,8 @@
package io.xpipe.app.core.mode;
import io.xpipe.app.core.*;
import io.xpipe.app.core.check.AppTempCheck;
import io.xpipe.app.core.check.AppUserDirectoryCheck;
import io.xpipe.app.ext.DataStoreProviders;
import io.xpipe.app.issue.*;
import io.xpipe.app.launcher.LauncherCommand;
@@ -95,8 +97,8 @@ public abstract class OperationMode {
AppProperties.init();
AppState.init();
XPipeSession.init(AppProperties.get().getBuildUuid());
AppChecks.checkDirectoryPermissions();
AppChecks.checkTemp();
AppUserDirectoryCheck.check();
AppTempCheck.check();
AppLogs.init();
AppProperties.logArguments(args);
AppProperties.logSystemProperties();
+1
View File
@@ -37,6 +37,7 @@ open module io.xpipe.app {
exports io.xpipe.app.browser.action;
exports io.xpipe.app.browser;
exports io.xpipe.app.browser.icon;
exports io.xpipe.app.core.check;
requires com.sun.jna;
requires com.sun.jna.platform;