From 0953f7cde8a2c09850f398790adc983ebf7f1b8b Mon Sep 17 00:00:00 2001 From: Jakob Heher Date: Tue, 22 Mar 2022 13:52:29 +0100 Subject: sanitize swt handling --- .../main/java/at/asit/pdfover/gui/MainWindow.java | 18 ---- .../java/at/asit/pdfover/gui/utils/SWTLoader.java | 109 --------------------- pdf-over-gui/src/main/resources/izpack/install.xml | 8 -- .../src/main/resources/scripts/pdf-over_linux.sh | 1 - .../src/main/resources/scripts/pdf-over_mac.sh | 1 - .../main/resources/scripts/pdf-over_win-cli.bat | 1 - .../src/main/resources/scripts/pdf-over_win.bat | 1 - .../main/resources/scripts/postInstall_linux.sh | 4 - .../src/main/resources/scripts/postInstall_win.bat | 2 - .../src/main/resources/scripts/postinstall_mac.sh | 1 - 10 files changed, 146 deletions(-) delete mode 100644 pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTLoader.java delete mode 100644 pdf-over-gui/src/main/resources/scripts/postInstall_linux.sh delete mode 100644 pdf-over-gui/src/main/resources/scripts/postInstall_win.bat (limited to 'pdf-over-gui/src/main') diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java index c2528adc..6af00889 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java @@ -58,7 +58,6 @@ import at.asit.pdfover.gui.controls.MainBarRectangleButton; import at.asit.pdfover.gui.controls.MainBarStartButton; import at.asit.pdfover.gui.osx.CocoaUIEnhancer; import at.asit.pdfover.commons.Messages; -import at.asit.pdfover.gui.utils.SWTLoader; import at.asit.pdfover.gui.workflow.StateMachine; import at.asit.pdfover.gui.workflow.states.BKUSelectionState; import at.asit.pdfover.gui.workflow.states.ConfigurationUIState; @@ -212,23 +211,6 @@ public class MainWindow { if (System.getProperty("os.name").contains("OS X")) { //$NON-NLS-1$ //$NON-NLS-2$ hookupOSXMenu(); } - // Workaround for SWT bug on Mac: disable full screen mode - try { - Field field = Control.class.getDeclaredField("view"); //$NON-NLS-1$ - Object /*NSView*/ view = field.get(getShell()); - if (view != null) - { - Class c = Class.forName("org.eclipse.swt.internal.cocoa.NSView"); //$NON-NLS-1$ - Object nswindow = c.getDeclaredMethod("window").invoke(view); //$NON-NLS-1$ - c = Class.forName("org.eclipse.swt.internal.cocoa.NSWindow"); //$NON-NLS-1$ - Method setCollectionBehavior = c.getDeclaredMethod( - "setCollectionBehavior", //$NON-NLS-1$ - (SWTLoader.getArchBits() == 64) ? long.class : int.class); - setCollectionBehavior.invoke(nswindow, 0); - } - } catch (Exception e) { - log.error("Error disabling full screen mode", e); //$NON-NLS-1$ - } } try { Display display = Display.getCurrent(); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTLoader.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTLoader.java deleted file mode 100644 index 6184ebc7..00000000 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SWTLoader.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 2012 by A-SIT, Secure Information Technology Center Austria - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://joinup.ec.europa.eu/software/page/eupl - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - */ -package at.asit.pdfover.gui.utils; - -// Imports -import java.io.File; -import java.io.UnsupportedEncodingException; -import java.lang.reflect.Method; -import java.net.URL; -import java.net.URLClassLoader; -import java.net.URLDecoder; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import at.asit.pdfover.gui.exceptions.InitializationException; - -/** - * - */ -@SuppressWarnings("nls") -public class SWTLoader { - /** - * SLF4J Logger instance - **/ - private static final Logger log = LoggerFactory.getLogger(SWTLoader.class); - - /** - * Load the SWT library for this OS - * @throws InitializationException Loading failed - */ - public static void loadSWT() throws InitializationException { - try { - URLClassLoader cl = (URLClassLoader)SWTLoader.class.getClassLoader(); - Method addUrlMethod = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); - addUrlMethod.setAccessible(true); - - String swtLibPath = getSwtJarPath() + getSwtJarName(); - log.debug("loading " + swtLibPath); - File swtLib = new File(swtLibPath); - if (!swtLib.isFile()) - throw new SWTLoadFailedException("Library " + swtLibPath + " not found"); - log.debug("Adding " + swtLib + " to ClassLoader..."); - addUrlMethod.invoke(cl, swtLib.toURI().toURL()); - log.debug("Success."); - } catch (Exception e) { - throw new InitializationException("SWT loading failed", e); - } - } - - /** - * Get bit-ness of the JVM - * @return 32 or 64 - */ - public static int getArchBits() { - String arch = System.getProperty("os.arch"); - return arch.contains("64") ? 64 : 32; - } - - private static String getSwtJarName() throws SWTLoadFailedException { - String os = System.getProperty("os.name").toLowerCase(); - if (os.contains("win")) - os = "windows"; - else if (os.contains("mac")) - os = "mac"; - else if (os.contains("linux") || os.contains("nix")) - os = "linux"; - else { - log.error("Unknown OS: " + os); - throw new SWTLoadFailedException("Unknown OS: " + os); - } - return "swt-" + os + "-" + getArchBits() + ".jar"; - } - - private static String getSwtJarPath() { - String path = ""; - try { - path = URLDecoder.decode(SWTLoader.class.getProtectionDomain().getCodeSource().getLocation().getPath(), "UTF-8"); - int idx = path.lastIndexOf('/'); - idx = path.lastIndexOf('/', idx - 1); - path = path.substring(0, idx + 1); - } catch (UnsupportedEncodingException e) { - // Ignore - } - return path + "lib-swt/"; - } - - private static class SWTLoadFailedException extends Exception { - private static final long serialVersionUID = 1L; - - SWTLoadFailedException(String msg) { - super(msg); - } - } - -} diff --git a/pdf-over-gui/src/main/resources/izpack/install.xml b/pdf-over-gui/src/main/resources/izpack/install.xml index 457fb083..f07da7ef 100644 --- a/pdf-over-gui/src/main/resources/izpack/install.xml +++ b/pdf-over-gui/src/main/resources/izpack/install.xml @@ -57,10 +57,8 @@ Main Installation - - @@ -71,8 +69,6 @@ os="unix" stage="never"> - - - diff --git a/pdf-over-gui/src/main/resources/scripts/pdf-over_linux.sh b/pdf-over-gui/src/main/resources/scripts/pdf-over_linux.sh index 438cec28..ca4e6279 100644 --- a/pdf-over-gui/src/main/resources/scripts/pdf-over_linux.sh +++ b/pdf-over-gui/src/main/resources/scripts/pdf-over_linux.sh @@ -1,5 +1,4 @@ #!/bin/sh BASEDIR=`dirname $0` export GDK_BACKEND=X11 -java -jar "$BASEDIR/../lib/pdf-over-install-helper.jar" exec java -cp "$BASEDIR/../lib/*" at.asit.pdfover.gui.Main "$@" diff --git a/pdf-over-gui/src/main/resources/scripts/pdf-over_mac.sh b/pdf-over-gui/src/main/resources/scripts/pdf-over_mac.sh index 2c488544..dcb805ae 100644 --- a/pdf-over-gui/src/main/resources/scripts/pdf-over_mac.sh +++ b/pdf-over-gui/src/main/resources/scripts/pdf-over_mac.sh @@ -1,5 +1,4 @@ #!/bin/sh BASEDIR=$(cd "$(dirname "$0")"; pwd) export LC_CTYPE="UTF-8" -#java -jar "$BASEDIR/../lib/pdf-over-install-helper.jar" exec java -XstartOnFirstThread -cp "$BASEDIR/../lib/*" at.asit.pdfover.gui.Main "$@" & diff --git a/pdf-over-gui/src/main/resources/scripts/pdf-over_win-cli.bat b/pdf-over-gui/src/main/resources/scripts/pdf-over_win-cli.bat index fe9bad65..fb7b7c39 100644 --- a/pdf-over-gui/src/main/resources/scripts/pdf-over_win-cli.bat +++ b/pdf-over-gui/src/main/resources/scripts/pdf-over_win-cli.bat @@ -1,4 +1,3 @@ @echo off -start /b javaw -jar "%~dp0\..\lib\pdf-over-install-helper.jar" start /b /WAIT java -cp "%~dp0\..\lib\*" at.asit.pdfover.gui.Main %* diff --git a/pdf-over-gui/src/main/resources/scripts/pdf-over_win.bat b/pdf-over-gui/src/main/resources/scripts/pdf-over_win.bat index 5e336241..6468e582 100644 --- a/pdf-over-gui/src/main/resources/scripts/pdf-over_win.bat +++ b/pdf-over-gui/src/main/resources/scripts/pdf-over_win.bat @@ -1,3 +1,2 @@ @echo off -start /b javaw -jar "%~dp0\..\lib\pdf-over-install-helper.jar" start /b javaw -cp "%~dp0\..\lib\*" at.asit.pdfover.gui.Main %* diff --git a/pdf-over-gui/src/main/resources/scripts/postInstall_linux.sh b/pdf-over-gui/src/main/resources/scripts/postInstall_linux.sh deleted file mode 100644 index 7c8d9cf5..00000000 --- a/pdf-over-gui/src/main/resources/scripts/postInstall_linux.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -BASEDIR=`dirname $0` -java -jar "$BASEDIR/../lib/pdf-over-install-helper.jar" - diff --git a/pdf-over-gui/src/main/resources/scripts/postInstall_win.bat b/pdf-over-gui/src/main/resources/scripts/postInstall_win.bat deleted file mode 100644 index 78deb870..00000000 --- a/pdf-over-gui/src/main/resources/scripts/postInstall_win.bat +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -java -jar "%~dp0\..\lib\pdf-over-install-helper.jar" diff --git a/pdf-over-gui/src/main/resources/scripts/postinstall_mac.sh b/pdf-over-gui/src/main/resources/scripts/postinstall_mac.sh index 82e1add9..0b020ea3 100644 --- a/pdf-over-gui/src/main/resources/scripts/postinstall_mac.sh +++ b/pdf-over-gui/src/main/resources/scripts/postinstall_mac.sh @@ -3,7 +3,6 @@ SCRIPTDIR=$(cd "$(dirname "$0")"; pwd) BASEDIR=$(cd "$(dirname "$0")/.."; pwd) export LC_CTYPE="UTF-8" cd "$SCRIPTDIR" -java -jar "$BASEDIR/lib/pdf-over-install-helper.jar" chmod a+x pdf-over_mac.sh cd "$BASEDIR" if [ -d "$BASEDIR.app" ]; then -- cgit v1.2.3