[Git][java-team/jameica][upstream] New upstream version 2.8.1+dfsg

Jochen Sprickerhof gitlab at salsa.debian.org
Mon Aug 13 21:11:44 BST 2018


Jochen Sprickerhof pushed to branch upstream at Debian Java Maintainers / jameica


Commits:
14a028fd by Jochen Sprickerhof at 2018-08-13T15:42:57Z
New upstream version 2.8.1+dfsg
- - - - -


18 changed files:

- LICENSE
- build/BUILD
- build/ChangeLog
- plugin.xml
- src/de/willuhn/jameica/gui/GUI.java
- src/de/willuhn/jameica/gui/dialogs/PasswordDialog.java
- src/de/willuhn/jameica/gui/internal/parts/BackgroundTaskMonitor.java
- src/de/willuhn/jameica/gui/internal/swt/PopupList.java
- src/de/willuhn/jameica/gui/parts/ProgressBar.java
- src/de/willuhn/jameica/messaging/LookupService.java
- src/de/willuhn/jameica/plugin/Version.java
- src/de/willuhn/jameica/security/JameicaSecurityManager.java
- src/de/willuhn/jameica/services/RepositoryService.java
- src/de/willuhn/jameica/system/ApplicationCallbackSWT.java
- src/de/willuhn/jameica/system/Config.java
- src/de/willuhn/jameica/system/Platform.java
- src/de/willuhn/jameica/system/WorkdirChooser.java
- test/de/willuhn/jameica/system/VersionTest.java


Changes:

=====================================
LICENSE
=====================================
--- a/LICENSE
+++ b/LICENSE
@@ -1,13 +1,13 @@
 May 11, 2018
 
-Jameica is licensed under the terms of the GNU General Public License.
+Jameica is licensed under the terms of the GNU General Public License version 2 or later.
 
 Linking this program statically or dynamically with other modules is making a
 combined work based on this program. Thus, the terms and conditions of the
 GNU General Public License cover the whole combination.
 
 As a special exception, the copyright holders of this program give you
-permission to link this proram with independent modules to produce an
+permission to link this program with independent modules to produce an
 executable, regardless of the license terms of these independent modules, and
 to copy and distribute the resulting executable under terms of your choice,
 provided that you also meet, for each linked independent module, the terms and
@@ -20,9 +20,8 @@ statement from your version.
 You should have received a copy of the GNU General Public License along with
 Jameica; see the file COPYING.  If not, write to
 
-Free Software Foundation
-59 Temple Place - Suite 330
+Free Software Foundation, Inc.
+51 Franklin St, Fifth Floor
 Boston
-MA 02111-1307
+MA 02110-1301
 USA
-


=====================================
build/BUILD
=====================================
--- a/build/BUILD
+++ b/build/BUILD
@@ -1,3 +1,3 @@
 #Build Number for ANT. Do not edit!
-#Fri May 11 11:17:59 CEST 2018
-build.number=444
+#Fri Jul 13 12:02:22 CEST 2018
+build.number=449


=====================================
build/ChangeLog
=====================================
--- a/build/ChangeLog
+++ b/build/ChangeLog
@@ -1,5 +1,14 @@
-HEAD 2.9 (nightly)
+2018-07-13 Version 2.8.1
 
+  * BUG: 0099 BUGZILLA 1856 - Änderung in Bug 1852 betraf zu viele Plugins, Interpretation der abhängigen Versionsnummern nochmal so angepasst, dass das neue Verhalten nur gilt, wenn das "+"/"-" in Klammern angegeben ist, ansonsten gilt wieder das vorherige Verhalten
+  * BUG: 0098 Button "Übernehmen" im Auswahlfenster für den Benutzerordner wurde nicht korrekt freigegeben
+  * BUG: 0097 Jameica-Fenster wurde bei Dualscreen-Setup unter bestimmten Bedingungen nicht auf dem tatsächlichen sondern auf dem primären Monitor wiederhergestellt 
+  * NEW: 0096 BUGZILLA 1852 - Definition von der Versionsnummern von abhängigen Plugins erweitert. Wenn z.Bsp. "1.1.2+" definiert ist, erlaubt das nur noch "1.1.2" - "1.1.(x>2)". Vorher war z.Bsp. auch "1.2" erlaubt
+  * BUG: 0095 Die Prüfung, ob sich der Benutzerordner innerhalb des Programmordners befindet, war zu streng (schlug auch an, wenn der Name des Benutzerordners mit dem Namen des Programmordners beginnt)
+  * BUG: 0094 Fortschrittsfenster mit Logausgaben wurde u.U. zu früh automatisch geschlossen, wenn mehrere Tasks direkt nacheinander ausgeführt werden
+  * BUG: 0093 Bei der Frage "Jameica scheint bereits zu laufen..." wurde ein zusätzliches leeres Fenster angezeigt (siehe 0079 und 0074)
+  * NEW: 0092 Default-Größe und Position des Hauptfensters optimiert
+  
 2018-05-22 Version 2.8.0
 
   * NEW: 0091 BUGZILLA 1731 - Besserer Support für HiDPI-Monitore


=====================================
plugin.xml
=====================================
--- a/plugin.xml
+++ b/plugin.xml
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="ISO-8859-1"?> 
 
-<system name="Jameica" version="2.8.0">
+<system name="Jameica" version="2.8.1">
 
   <description>Jameica - Java based messages interchange</description>
-  <url>http://www.willuhn.de/products/jameica/releases/2.8/jameica/jameica-2.8.0.zip</url>
-  <homepage>http://www.willuhn.de/projects/jameica</homepage>
+  <url>https://www.willuhn.de/products/jameica/releases/2.8/jameica/jameica-2.8.1.zip</url>
+  <homepage>https://www.willuhn.de/projects/jameica</homepage>
   <license>GPL - http://www.gnu.org/copyleft/gpl.html</license>
 
   <classfinder>


=====================================
src/de/willuhn/jameica/gui/GUI.java
=====================================
--- a/src/de/willuhn/jameica/gui/GUI.java
+++ b/src/de/willuhn/jameica/gui/GUI.java
@@ -245,7 +245,7 @@ public class GUI implements ApplicationController
 
       ////////////////////////////////////////////////////////////////////////
       // init sashes
-      this.left.setWeights(new int[] {SETTINGS.getInt("navi.height.0",7), SETTINGS.getInt("navi.height.1",3)});
+      this.left.setWeights(new int[] {SETTINGS.getInt("navi.height.0",8), SETTINGS.getInt("navi.height.1",5)});
       this.left.addDisposeListener(new DisposeListener() {
         public void widgetDisposed(DisposeEvent e)
         {
@@ -340,10 +340,10 @@ public class GUI implements ApplicationController
   {
     ////////////////////////////
     // size and position restore
-    int x      = SETTINGS.getInt("window.x", 0);
-    int y      = SETTINGS.getInt("window.y", 0);
-    int width  = SETTINGS.getInt("window.width", 920);
-    int height = SETTINGS.getInt("window.height", 720);
+    int x      = SETTINGS.getInt("window.x", -1); // Position ueberlassen wir beim ersten Start dem Desktop
+    int y      = SETTINGS.getInt("window.y", -1);
+    int width  = SETTINGS.getInt("window.width", 1000);
+    int height = SETTINGS.getInt("window.height", 780);
 
     // BUGZILLA 194
     boolean maximized = SETTINGS.getBoolean("window.maximized", false);
@@ -365,7 +365,7 @@ public class GUI implements ApplicationController
         // OK, es ist etwas angegeben. Checken, ob die Werte plausibel sind
         // Sonst koennte es passieren, dass das Fenster ausserhalb des sichtbaren
         // Bereiches landet
-        Rectangle rect = getDisplay().getPrimaryMonitor().getClientArea(); // getClientArea liefert die Groesse des gesamten virtuellen Screens
+        Rectangle rect = getDisplay().getClientArea(); // getClientArea liefert die Groesse des gesamten virtuellen Screens
         if ((x < (rect.width)) && (y < rect.height))
           getShell().setLocation(x,y);
       }


=====================================
src/de/willuhn/jameica/gui/dialogs/PasswordDialog.java
=====================================
--- a/src/de/willuhn/jameica/gui/dialogs/PasswordDialog.java
+++ b/src/de/willuhn/jameica/gui/dialogs/PasswordDialog.java
@@ -51,7 +51,9 @@ public class PasswordDialog extends AbstractDialog
 
   private int retries                 = 0;
   private boolean showPassword        = false;
-  
+
+  private TextInput userInput         = null;
+  private PasswordInput passwordInput = null;
   private String text                 = null;
   private String userText             = null;
   private String labelText 					  = i18n.tr("Passwort");
@@ -177,22 +179,22 @@ public class PasswordDialog extends AbstractDialog
 
     Container container = new SimpleContainer(parent);
 
-    final TextInput username = (this.userText != null && this.userText.length() > 0) ? new TextInput(null) : null;
-    if (username != null)
+    this.userInput = (this.userText != null && this.userText.length() > 0) ? new TextInput(null) : null;
+    if (this.userInput != null)
     {
-      username.setValue(this.enteredUsername != null ? this.enteredUsername : Application.getStartupParams().getUsername());
-      username.setName(this.userText);
-      username.setMandatory(true);
-      username.focus();
-      container.addInput(username);
+      this.userInput.setValue(this.enteredUsername != null ? this.enteredUsername : Application.getStartupParams().getUsername());
+      this.userInput.setName(this.userText);
+      this.userInput.setMandatory(true);
+      this.userInput.focus();
+      container.addInput(this.userInput);
     }
 
     // das Passwort
-    final PasswordInput passwordInput = new PasswordInput(this.enteredPassword);
-    passwordInput.setName(this.labelText);
-    passwordInput.setShowPassword(this.showPassword);
-    if (username == null) passwordInput.focus();
-    container.addInput(passwordInput);
+    this.passwordInput = new PasswordInput(this.enteredPassword);
+    this.passwordInput.setName(this.labelText);
+    this.passwordInput.setShowPassword(this.showPassword);
+    if (this.userInput == null) this.passwordInput.focus();
+    container.addInput(this.passwordInput);
     
     // Fehlertext
     this.error = new LabelInput(this.errorText);
@@ -206,7 +208,7 @@ public class PasswordDialog extends AbstractDialog
 
     // Listener, welcher passwordModified() aufruft wenn sich das
     // passwort aendert (fuer Erweiterungen).
-    ((Text)passwordInput.getControl()).addModifyListener(
+    ((Text)this.passwordInput.getControl()).addModifyListener(
         new ModifyListener() {
           public void modifyText(ModifyEvent e)
           {
@@ -222,9 +224,9 @@ public class PasswordDialog extends AbstractDialog
       {
         retries++;
 
-        if (username != null)
+        if (userInput != null)
         {
-          String u = (String) username.getValue();
+          String u = (String) userInput.getValue();
           if (!checkUsername(u))
             return;
           enteredUsername = u;
@@ -350,7 +352,7 @@ public class PasswordDialog extends AbstractDialog
    */
   public String getUsername()
   {
-    return this.enteredUsername;
+    return this.userInput != null ? (String) this.userInput.getValue() : this.enteredUsername;
   }
   
   /**
@@ -360,6 +362,8 @@ public class PasswordDialog extends AbstractDialog
   public void setUsername(String username)
   {
     this.enteredUsername = username;
+    if (this.userInput != null)
+      this.userInput.setValue(this.enteredUsername);
   }
   
   /**
@@ -369,5 +373,7 @@ public class PasswordDialog extends AbstractDialog
   public void setPassword(String password)
   {
     this.enteredPassword = password;
+    if (this.passwordInput != null)
+      this.passwordInput.setValue(this.enteredPassword);
   }
 }


=====================================
src/de/willuhn/jameica/gui/internal/parts/BackgroundTaskMonitor.java
=====================================
--- a/src/de/willuhn/jameica/gui/internal/parts/BackgroundTaskMonitor.java
+++ b/src/de/willuhn/jameica/gui/internal/parts/BackgroundTaskMonitor.java
@@ -15,6 +15,7 @@ import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
 
 import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Listener;
@@ -42,15 +43,17 @@ public class BackgroundTaskMonitor extends ProgressBar
    * Datums-Format dd.MM.yyyy HH:mm:ss.
    */
   private final static DateFormat DF  = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
-  
+
   private final static AtomicBoolean DEFAULT_LOCKED = new AtomicBoolean(false);
+  private final static AtomicLong USAGES = new AtomicLong(0);
 
-  private DelayedListener delay        = null;
-  private AtomicBoolean started        = new AtomicBoolean(false);
-  private AtomicBoolean panelLocked    = DEFAULT_LOCKED;
+  private DelayedListener delay     = null;
+  private AtomicBoolean started     = new AtomicBoolean(false);
+  private AtomicBoolean panelLocked = DEFAULT_LOCKED;
+  private AtomicLong usage          = new AtomicLong(USAGES.incrementAndGet());
   
-  private BackgroundTask task          = null;
-  private PanelButton cancel           = null;
+  private BackgroundTask task       = null;
+  private PanelButton cancel        = null;
   
   /**
    * ct.
@@ -88,13 +91,25 @@ public class BackgroundTaskMonitor extends ProgressBar
           // Wenn wir hier sind, muss das timeout abgelaufen und niemand
           // sonst an dem Progress etwas aktualisiert haben
           // BUGZILLA 179 + 432
-          int status = event.detail;
-          if (started.get() && (status == STATUS_CANCEL || status == STATUS_DONE || status == STATUS_ERROR))
+          if (started.get() && isFinalState(event.detail))
           {
             GUI.getDisplay().asyncExec(new Runnable() {
               public void run()
               {
-                if (!started.get() || !GUI.getView().snappedIn())
+                // Wir machen das Fenster nicht zu, wenn:
+                // a) wir wurden noch nicht gestartet
+                // b) es ist gar nicht offen
+                // c) wir waren nicht die letzte Instanz.
+                //    Das kann passieren, wenn das Snapin von einem Folgeprozess wiederverwendet wurde, bevor es
+                //    von unserer Instanz geschlossen wurde. Beispiel: User synchronisiert die Konten, wartet
+                //    nicht, bis das Snapin automatisch zugegangen ist und schliesst es auch nicht manuell. Dann
+                //    startet er eine erneute Synchronisation - noch bevor das vorherige Snapin geschlossen wurde.
+                //    Da der vorherige Monitor auf einen finalen State ging, wird der nach 30 Sekunden versuchen,
+                //    das Snapin zu schliessen. Das hierfuer gefeuerte Event laesst sich nachtraeglich auch nicht
+                //    mehr aufhalten. Es ist per Display#timerExec bereits an SWT uebergeben worden. Stattdessen
+                //    muessen wir hier bei der Ausfuehrung des Events erkennen, ob wir die letzten waren. Sind
+                //    wir es nicht mehr, ist der Nachfolger fuer das Schliessen zustaendig.
+                if (!started.get() || !GUI.getView().snappedIn() || usage.get() != USAGES.get())
                   return;
                 try
                 {
@@ -160,6 +175,18 @@ public class BackgroundTaskMonitor extends ProgressBar
       }
     });
   }
+  
+  /**
+   * Prueft, ob es sich um einen finalen Status handelt.
+   * @param state der Status.
+   * @return true, wenn es ein finaler Status ist.
+   */
+  private boolean isFinalState(int state)
+  {
+    return state == STATUS_CANCEL ||
+           state == STATUS_DONE ||
+           state == STATUS_ERROR;
+  }
 
   /**
    * Erzeugt den Lock-Button.


=====================================
src/de/willuhn/jameica/gui/internal/swt/PopupList.java
=====================================
--- a/src/de/willuhn/jameica/gui/internal/swt/PopupList.java
+++ b/src/de/willuhn/jameica/gui/internal/swt/PopupList.java
@@ -1,12 +1,13 @@
-/**********************************************************************
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
  *
- * Copyright (c) 2004 Olaf Willuhn
- * All rights reserved.
- * 
- * This software is copyrighted work licensed under the terms of the
- * Jameica License.  Please consult the file "LICENSE" for details. 
- *
- **********************************************************************/
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
 
 // Das ist eine Kopie von org.eclipse.swt.custom.PopupList
 // Wir haben einen Fork davon erstellt, weil die originale Implementierung


=====================================
src/de/willuhn/jameica/gui/parts/ProgressBar.java
=====================================
--- a/src/de/willuhn/jameica/gui/parts/ProgressBar.java
+++ b/src/de/willuhn/jameica/gui/parts/ProgressBar.java
@@ -126,7 +126,8 @@ public class ProgressBar implements ProgressMonitor, Part
 		{
 			public void run()
 			{
-        log.appendText(msg);
+			  if (log != null)
+			    log.appendText(msg);
 			}
 		});
   }


=====================================
src/de/willuhn/jameica/messaging/LookupService.java
=====================================
--- a/src/de/willuhn/jameica/messaging/LookupService.java
+++ b/src/de/willuhn/jameica/messaging/LookupService.java
@@ -16,6 +16,7 @@ import java.net.InetAddress;
 import java.util.Hashtable;
 
 import de.willuhn.jameica.system.Application;
+import de.willuhn.logging.Level;
 import de.willuhn.logging.Logger;
 import de.willuhn.net.MulticastClient;
 
@@ -208,7 +209,9 @@ public class LookupService implements MessageConsumer
     }
     catch (Exception e)
     {
-      Logger.error("error while performing lookup",e);
+      // Wenn das fehlschlaegt, kann der Lookup-Dienst halt nicht verwendet werden.
+      Logger.write(Level.DEBUG,"multicast lookup failed, stacktrace for debugging purpose",e);
+      Logger.info("multicast lookup not possible: " + e.getMessage());
     }
     finally
     {


=====================================
src/de/willuhn/jameica/plugin/Version.java
=====================================
--- a/src/de/willuhn/jameica/plugin/Version.java
+++ b/src/de/willuhn/jameica/plugin/Version.java
@@ -11,8 +11,11 @@
 package de.willuhn.jameica.plugin;
 
 import java.io.Serializable;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
 
 import de.willuhn.logging.Logger;
 
@@ -28,15 +31,9 @@ public class Version implements Serializable, Comparable<Version>
    */
   public final static Version NONE = new Version();
 
-  private static final Pattern SINGLE  = Pattern.compile("^(\\d+)$");
-  private static final Pattern OLD     = Pattern.compile("^(\\d+)\\.(\\d+)$");
-  private static final Pattern PATTERN = Pattern.compile("^v?(\\d+)\\.(\\d+)\\.(\\d+)-?(.*)$");
-
-  boolean oldVersion = false;
-
-  private int major     = 0;
-  private int minor     = 0;
-  private int patch     = 0;
+  private Integer major = null;
+  private Integer minor = null;
+  private Integer patch = null;
   private String suffix = null;
 
   /**
@@ -52,33 +49,38 @@ public class Version implements Serializable, Comparable<Version>
    */
   public Version(String v)
   {
-    if (v != null && v.length() > 0)
+    v = StringUtils.trimToNull(v);
+    if (v == null)
+      return;
+
+    int spos = v.indexOf("-");
+    if (spos > 0)
     {
-      final Matcher mSin = SINGLE.matcher(v);
-      final Matcher mOld = OLD.matcher(v);
-      final Matcher mNew = PATTERN.matcher(v);
-      if (mSin.matches())
-      {
-        this.oldVersion = true;
-        this.major = Integer.parseInt(mSin.group(1));
-      }
-      if (mOld.matches())
-      {
-        this.oldVersion = true;
-        this.major = Integer.parseInt(mOld.group(1));
-        this.minor = Integer.parseInt(mOld.group(2));
-      }
-      else if (mNew.matches())
-      {
-        this.major = Integer.parseInt(mNew.group(1));
-        this.minor = Integer.parseInt(mNew.group(2));
-        this.patch = Integer.parseInt(mNew.group(3));
-        this.suffix = mNew.group(4);
-      }
-      else
-      {
-        Logger.warn("unparsable version number: " + v);
-      }
+      this.suffix = v.substring(spos+1);
+      v = v.substring(0,spos);
+    }
+
+    List<String> parts = new ArrayList(Arrays.asList(v.split("\\.")));
+    if (parts.size() > 0) this.major = this.parse(parts.remove(0));
+    if (parts.size() > 0) this.minor = this.parse(parts.remove(0));
+    if (parts.size() > 0) this.patch = this.parse(parts.remove(0));
+  }
+  
+  /**
+   * Parset den Versionsteil.
+   * @param part der Versionsteil.
+   * @return der Versionsteil oder NULL, wenn er nicht geparst werden konnte.
+   */
+  private Integer parse(String part)
+  {
+    try
+    {
+      return Integer.parseInt(part);
+    }
+    catch (Exception e)
+    {
+      Logger.error("unparsable version part: " + part,e);
+      return null;
     }
   }
 
@@ -88,7 +90,7 @@ public class Version implements Serializable, Comparable<Version>
    */
   public int getMajor()
   {
-    return this.major;
+    return this.major != null ? this.major.intValue() : 0;
   }
 
   /**
@@ -106,7 +108,7 @@ public class Version implements Serializable, Comparable<Version>
    */
   public int getMinor()
   {
-    return this.minor;
+    return this.minor != null ? this.minor.intValue() : 0;
   }
 
   /**
@@ -124,7 +126,7 @@ public class Version implements Serializable, Comparable<Version>
    */
   public int getPatch()
   {
-    return this.patch;
+    return this.patch != null ? this.patch.intValue() : 0;
   }
 
   /**
@@ -155,55 +157,56 @@ public class Version implements Serializable, Comparable<Version>
   }
   
   /**
-   * Liefert true, wenn es sich um eine 3-stellige Versionsnummer mit Patch-Level handelt.
-   * @return true, wenn es sich um eine 3-stellige Versionsnummer mit Patch-Level handelt.
-   */
-  public boolean hasPatchLevel()
-  {
-    return !this.oldVersion;
-  }
-
-  /**
    * @see java.lang.Object#hashCode()
-   * Generiert von Eclipse.
    */
+  @Override
   public int hashCode()
   {
     final int prime = 31;
     int result = 1;
-    result = prime * result + this.major;
-    result = prime * result + this.minor;
-    result = prime * result + this.patch;
-    result = prime * result
-        + ((this.suffix == null) ? 0 : this.suffix.hashCode());
+    result = prime * result + ((major == null) ? 0 : major.hashCode());
+    result = prime * result + ((minor == null) ? 0 : minor.hashCode());
+    result = prime * result + ((patch == null) ? 0 : patch.hashCode());
+    result = prime * result + ((suffix == null) ? 0 : suffix.hashCode());
     return result;
   }
 
   /**
    * @see java.lang.Object#equals(java.lang.Object)
-   * Generiert von Eclipse.
    */
+  @Override
   public boolean equals(Object obj)
   {
     if (this == obj)
       return true;
     if (obj == null)
       return false;
-    if (getClass() != obj.getClass())
+    if (!(obj instanceof Version))
       return false;
     Version other = (Version) obj;
-    if (this.major != other.major)
+    if (major == null)
+    {
+      if (other.major != null)
+        return false;
+    } else if (!major.equals(other.major))
       return false;
-    if (this.minor != other.minor)
+    if (minor == null)
+    {
+      if (other.minor != null)
+        return false;
+    } else if (!minor.equals(other.minor))
       return false;
-    if (this.patch != other.patch)
+    if (patch == null)
+    {
+      if (other.patch != null)
+        return false;
+    } else if (!patch.equals(other.patch))
       return false;
-    if (this.suffix == null)
+    if (suffix == null)
     {
       if (other.suffix != null)
         return false;
-    }
-    else if (!this.suffix.equals(other.suffix))
+    } else if (!suffix.equals(other.suffix))
       return false;
     return true;
   }
@@ -213,12 +216,12 @@ public class Version implements Serializable, Comparable<Version>
    */
   public int compareTo(Version v)
   {
-    int r = this.major - v.major;
+    int r = this.getMajor() - v.getMajor();
     if (r == 0)
     {
-      r = this.minor - v.minor;
+      r = this.getMinor() - v.getMinor();
       if (r == 0)
-        r = this.patch - v.patch;
+        r = this.getPatch() - v.getPatch();
     }
     return r;
   }
@@ -232,15 +235,12 @@ public class Version implements Serializable, Comparable<Version>
     sb.append(getMajor());
     sb.append(".");
     sb.append(getMinor());
-    if (!this.oldVersion)
+    sb.append(".");
+    sb.append(getPatch());
+    if (getSuffix() != null && getSuffix().length() > 0)
     {
-      sb.append(".");
-      sb.append(getPatch());
-      if (getSuffix() != null && getSuffix().length() > 0)
-      {
-        sb.append("-");
-        sb.append(getSuffix());
-      }
+      sb.append("-");
+      sb.append(getSuffix());
     }
     return sb.toString();
   }
@@ -262,20 +262,73 @@ public class Version implements Serializable, Comparable<Version>
     
     try
     {
-      Version required = new Version(dependency.replaceAll("[+-]",""));
+      String cleaned = dependency.replaceAll("[\\(\\)\\-\\+]","");
+      // Beim Parsen der Version muessen wir das "+"/"-" am Ende entfernen
+      Version required = new Version(cleaned);
 
-      int compare = this.compareTo(required);
       
-      // Versionsnummer ist mit einem Minus angegeben.
-      // also darf hoechstens die angegebene Versionsnummer vorhanden sein
-      if (dependency.endsWith("-"))
-        return compare <= 0;
+      // Versionsnummer ist mit einem Plus in Klammern angegeben.
+      // Dann darf nur der letzte Teil der Versionsnummer, der sich vor dem "(+)"
+      // groesser sein.
+      if (dependency.endsWith("(+)"))
+      {
+        // Format 1+
+        // Major-Version muss die Anforderung erfuellen
+        if (required.minor == null && required.patch == null)
+          return this.getMajor() >= required.getMajor();
+        
+        // Format 1.1+
+        // Major-Version muss identisch sein
+        // Minor-Version muss die Anforderung erfuellen
+        if (required.patch == null)
+          return this.getMajor() == required.getMajor() &&
+                 this.getMinor() >= required.getMinor();
+
+        // Format 1.1.1+
+        // Major- und Minor-Version muessen identisch sein
+        // Patch-Version muss die Anforderung erfuellen
+        return this.getMajor() == required.getMajor() &&
+               this.getMinor() == required.getMinor() &&
+               this.getPatch() >= required.getPatch();
+      }
       
-      // Versionsnummer mit Plus, also muss die vorhandene Version
-      // gleicher ODER groesser sein
+      // Versionsnummer ist mit einem Minus in Klammern angegeben.
+      // Dann darf nur der letzte Teil der Versionsnummer, der sich vor dem "(-)"
+      // groesser sein.
+      if (dependency.endsWith("(-)"))
+      {
+        // Format 1-
+        // Major-Version muss die Anforderung erfuellen
+        if (required.minor == null && required.patch == null)
+          return this.getMajor() <= required.getMajor();
+        
+        // Format 1.1-
+        // Major-Version muss identisch sein
+        // Minor-Version muss die Anforderung erfuellen
+        if (required.patch == null)
+          return this.getMajor() == required.getMajor() &&
+                 this.getMinor() <= required.getMinor();
+
+        // Format 1.1.1-
+        // Major- und Minor-Version muessen identisch sein
+        // Patch-Version muss die Anforderung erfuellen
+        return this.getMajor() == required.getMajor() &&
+               this.getMinor() == required.getMinor() &&
+               this.getPatch() <= required.getPatch();
+      }
+
+      int compare = this.compareTo(required);
+
+      // Versionsnummer ist mit einem Plus ohne Klammern angegeben
+      // Dann ist jede beliebige gleiche oder groessere Versionsnummer erlaubt.
       if (dependency.endsWith("+"))
         return compare >= 0;
 
+        // Versionsnummer ist mit einem Minus ohne Klammern angegeben
+        // Dann ist jede beliebige gleiche oder kleinere Versionsnummer erlaubt.
+      if (dependency.endsWith("-"))
+        return compare <= 0;
+      
       // Kein Vorzeichen, dann muss die Versionsnummer exakt passen
       return compare == 0;
     }


=====================================
src/de/willuhn/jameica/security/JameicaSecurityManager.java
=====================================
--- a/src/de/willuhn/jameica/security/JameicaSecurityManager.java
+++ b/src/de/willuhn/jameica/security/JameicaSecurityManager.java
@@ -18,6 +18,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 
 import de.willuhn.jameica.system.Application;
 import de.willuhn.jameica.system.OperationCanceledException;
+import de.willuhn.jameica.system.Platform;
 import de.willuhn.logging.Logger;
 import de.willuhn.util.ApplicationException;
 
@@ -99,12 +100,13 @@ public class JameicaSecurityManager extends SecurityManager
       
       File check = new File(path);
 
-      String s = check.getCanonicalPath();
-      if (!s.startsWith(this.jameicaPath))
+      if (!Platform.inProgramDir(check))
         return; // Wir sind nicht im Jameica-Ordner. Nicht relevant
-      
+
+      final String s = check.getCanonicalPath();
+
       File pluginDir    = Application.getConfig().getSystemPluginDir();
-      String pluginPath = pluginDir.getCanonicalPath();
+      String pluginPath = pluginDir.getCanonicalPath() + File.separator;
 
       // Wir sind nicht im Plugin-Ordner.
       if (!s.startsWith(pluginPath))


=====================================
src/de/willuhn/jameica/services/RepositoryService.java
=====================================
--- a/src/de/willuhn/jameica/services/RepositoryService.java
+++ b/src/de/willuhn/jameica/services/RepositoryService.java
@@ -80,7 +80,7 @@ public class RepositoryService implements Bootable
   {
     "https://www.willuhn.de/products/jameica/updates/extensions",
     "http://www.jverein.de/updates/",
-    "http://scripting-updates.derrichter.de/",
+    "https://scripting-updates.derrichter.de/",
     "https://www.open4me.de/hibiscus/"
   };
 


=====================================
src/de/willuhn/jameica/system/ApplicationCallbackSWT.java
=====================================
--- a/src/de/willuhn/jameica/system/ApplicationCallbackSWT.java
+++ b/src/de/willuhn/jameica/system/ApplicationCallbackSWT.java
@@ -298,6 +298,20 @@ public class ApplicationCallbackSWT extends AbstractApplicationCallback
    */
   public boolean askUser(final String question, String[] variables, final boolean storeAnswer) throws Exception
   {
+    return this.askUser(null,question,variables,storeAnswer);
+  }
+
+  /**
+   * @see de.willuhn.jameica.system.ApplicationCallback#askUser(java.lang.String, java.lang.String[], boolean)
+   * @param shell
+   * @param question
+   * @param variables
+   * @param storeAnswer
+   * @return
+   * @throws Exception
+   */
+  private boolean askUser(final Shell shell, final String question, String[] variables, final boolean storeAnswer) throws Exception
+  {
     if (question == null)
     {
       Logger.warn("<null> question!");
@@ -322,6 +336,15 @@ public class ApplicationCallbackSWT extends AbstractApplicationCallback
       {
         return choice;
       }
+      
+      /**
+       * @see de.willuhn.jameica.gui.dialogs.AbstractDialog#createShell(org.eclipse.swt.widgets.Shell, int)
+       */
+      @Override
+      protected Shell createShell(Shell parent, int flags)
+      {
+        return super.createShell(shell != null ? shell : parent, flags);
+      }
 
       protected void paint(Composite parent) throws Exception
       {
@@ -382,7 +405,8 @@ public class ApplicationCallbackSWT extends AbstractApplicationCallback
   {
     try
     {
-      return askUser(Application.getI18n().tr("Jameica scheint bereits zu laufen. Wollen Sie den Startvorgang wirklich fortsetzen?"));
+      Shell shell = this.startupMonitor != null ? startupMonitor.getShell() : null;
+      return askUser(shell,Application.getI18n().tr("Jameica scheint bereits zu laufen. Wollen Sie den Startvorgang wirklich fortsetzen?"),null,true);
     }
     catch (Exception e)
     {


=====================================
src/de/willuhn/jameica/system/Config.java
=====================================
--- a/src/de/willuhn/jameica/system/Config.java
+++ b/src/de/willuhn/jameica/system/Config.java
@@ -119,7 +119,7 @@ public final class Config
   public void setRmiPort(int port) throws ApplicationException
 	{
     if (port < 1 || port > 65535)
-      throw new ApplicationException(Application.getI18n().tr("TCP-Portnummer fr Netzwerkbetrieb ausserhalb des gltigen Bereichs von {0} bis {1}", new String[]{""+1,""+65535}));
+      throw new ApplicationException(Application.getI18n().tr("TCP-Portnummer fr Netzwerkbetrieb auerhalb des gltigen Bereichs von {0} bis {1}", new String[]{""+1,""+65535}));
 
     ServerSocket s = null;
     try
@@ -219,7 +219,7 @@ public final class Config
     }
 
     if (port < 1 || port > 65535)
-      throw new ApplicationException(Application.getI18n().tr("TCP-Portnummer fr Proxy ausserhalb des gltigen Bereichs von {0} bis {1}", new String[]{""+1,""+65535}));
+      throw new ApplicationException(Application.getI18n().tr("TCP-Portnummer fr Proxy auerhalb des gltigen Bereichs von {0} bis {1}", new String[]{""+1,""+65535}));
 
     settings.setAttribute("jameica.system.proxy.port",port);
   }
@@ -269,7 +269,7 @@ public final class Config
     }
 
     if (port < 1 || port > 65535)
-      throw new ApplicationException(Application.getI18n().tr("TCP-Portnummer fr HTTPS-Proxy ausserhalb des gltigen Bereichs von {0} bis {1}", new String[]{""+1,""+65535}));
+      throw new ApplicationException(Application.getI18n().tr("TCP-Portnummer fr HTTPS-Proxy auerhalb des gltigen Bereichs von {0} bis {1}", new String[]{""+1,""+65535}));
 
     settings.setAttribute("jameica.system.proxy.https.port",port);
   }


=====================================
src/de/willuhn/jameica/system/Platform.java
=====================================
--- a/src/de/willuhn/jameica/system/Platform.java
+++ b/src/de/willuhn/jameica/system/Platform.java
@@ -70,7 +70,7 @@ public class Platform
    * Liefert eine plattform-spezifische Instanz.
    * @return Instanz.
    */
-  public final static Platform getInstance()
+  public static Platform getInstance()
   {
     // Haette ich gern modularer, allerdings weiss
     // ich im Moment nicht, wie das sinnvoll gaenge.
@@ -81,6 +81,22 @@ public class Platform
   }
   
   /**
+   * Prueft, ob sich der angegebene Ordner oder die Datei innerhalb des Programmordners befindet.
+   * @param f der zu pruefende Ordner oder die Datei. 
+   * @return true, wenn sich der Ordner oder die Datei im Programmordner befindet.
+   * @throws IOException
+   */
+  public static boolean inProgramDir(File f) throws IOException
+  {
+    if (f == null)
+      return false;
+
+    String test    = f.getCanonicalPath();
+    String program = new File(".").getCanonicalPath();
+    return test.startsWith(program + File.separator) || test.equals(program);
+  }
+  
+  /**
    * Liefert das Benutzerverzeichnis, in dem Jameica alle Daten speichert.
    * Falls es noch nicht existiert, wird es automatisch angelegt.
    * @return Benutzerverzeichnis.
@@ -118,9 +134,8 @@ public class Platform
       // Checken, ob es sich ausserhalb des Programmordners befindet
       try
       {
-        String systemPath = new File(".").getCanonicalPath();
-        if (this.workdir.getCanonicalPath().startsWith(systemPath))
-          throw new ApplicationException("Bitte whlen Sie einen Benutzer-Ordner, der sich ausserhalb des Programm-Verzeichnisses befindet.");
+        if (inProgramDir(this.workdir))
+          throw new ApplicationException("Bitte whlen Sie einen Benutzer-Ordner, der sich auerhalb des Programm-Verzeichnisses befindet.");
       }
       catch (IOException ioe)
       {
@@ -148,7 +163,6 @@ public class Platform
       BootstrapSettings.setAskWorkdir(true);
       throw new ApplicationException("Bitte versuchen Sie, Jameica erneut zu starten und whlen Sie einen anderen Benuzterordner.",e);
     }
-    
   }
   
   /**


=====================================
src/de/willuhn/jameica/system/WorkdirChooser.java
=====================================
--- a/src/de/willuhn/jameica/system/WorkdirChooser.java
+++ b/src/de/willuhn/jameica/system/WorkdirChooser.java
@@ -121,7 +121,7 @@ public class WorkdirChooser
       this.dir.addModifyListener(new ModifyListener() {
         public void modifyText(ModifyEvent e)
         {
-          getDir(); // Anzeigen aktualisieren
+          getDir(true); // Anzeigen aktualisieren
         }
       });
       
@@ -210,7 +210,7 @@ public class WorkdirChooser
     }
     
     // Einmal initial ausloesen
-    this.getDir();
+    this.getDir(true);
 
     this.shell.pack();
     this.shell.setMinimumSize(this.shell.computeSize(WINDOW_WIDTH,SWT.DEFAULT));
@@ -250,69 +250,70 @@ public class WorkdirChooser
   
   /**
    * Liefert das ausgewaehle Benutzerverzeichnis.
+   * @param lock true, wenn der Apply-Button waehrenddessen gesperrt werden soll.
    * @return das Benutzer-Verzeichnis oder NULL, wenn ein ungueltiges Benutzerverzeichnis ausgewaehlt wurde.
    */
-  private String getDir()
+  private String getDir(boolean lock)
   {
-    if (this.dir == null || this.dir.isDisposed())
-    {
-      Logger.warn("dialog already disposed");
-      return null;
-    }
-    
-    if (this.apply != null && !this.apply.isDisposed())
-      this.apply.setEnabled(false);
-    
-    String dir = this.dir.getText();
-    
-    if (dir == null || dir.trim().length() == 0)
-    {
-      this.error.setText("Bitte whlen Sie einen Ordner aus.");
-      return null;
-    }
-
     String path = null;
-
-    // Checken, ob das Verzeichnis existiert und ob wir darin schreiben koennen.
-    File file = new File(dir);
     
-    // Checken, ob sich der Ordner innerhalb des Programmordners befindet
     try
     {
-      path = file.getCanonicalPath();
-      String systemPath = new File(".").getCanonicalPath();
-      if (path.startsWith(systemPath))
+      if (this.dir == null || this.dir.isDisposed())
       {
-        this.error.setText("Bitte whlen Sie einen Benutzer-Ordner, der sich\nausserhalb des Programm-Verzeichnisses befindet.");
+        Logger.warn("dialog already disposed");
         return null;
       }
+      
+      String dir = this.dir.getText();
+      
+      if (dir == null || dir.trim().length() == 0)
+      {
+        this.error.setText("Bitte whlen Sie einen Ordner aus.");
+        return null;
+      }
+
+      // Checken, ob das Verzeichnis existiert und ob wir darin schreiben koennen.
+      File file = new File(dir);
+      
+      // Checken, ob sich der Ordner innerhalb des Programmordners befindet
+      try
+      {
+        if (Platform.inProgramDir(file))
+        {
+          this.error.setText("Bitte whlen Sie einen Benutzer-Ordner, der sich\nauerhalb des Programm-Verzeichnisses befindet.");
+          return null;
+        }
+      }
+      catch (Exception e)
+      {
+        Logger.error("unable to check canonical path",e);
+        this.error.setText("Benutzer-Ordner nicht auswhlbar: " + e.getMessage());
+        return null;
+      }
+      
+      
+      if (file.exists() && !file.canWrite())
+      {
+        this.error.setText("Sie besitzen keinen Schreibzugriff in diesem Ordner.");
+        return null;
+      }
+      
+      if (!file.exists() && !file.getParentFile().canWrite())
+      {
+        this.error.setText("Sie besitzen keinen Schreibzugriff in diesem Ordner.");
+        return null;
+      }
+      
+      this.error.setText("\n");
+      path = file.getAbsolutePath();
+      return path;
     }
-    catch (Exception e)
-    {
-      Logger.error("unable to check canonical path",e);
-      this.error.setText("Benutzer-Ordner nicht auswhlbar: " + e.getMessage());
-      return null;
-    }
-    
-    
-    if (file.exists() && !file.canWrite())
-    {
-      this.error.setText("Sie besitzen keinen Schreibzugriff in diesem Ordner.");
-      return null;
-    }
-    
-    if (!file.exists() && !file.getParentFile().canWrite())
+    finally
     {
-      this.error.setText("Sie besitzen keinen Schreibzugriff in diesem Ordner.");
-      return null;
+      if (this.apply != null && !this.apply.isDisposed())
+        this.apply.setEnabled(!lock || path != null);
     }
-    
-    this.error.setText("\n");
-    
-    if (this.apply != null && !this.apply.isDisposed())
-      apply.setEnabled(true);
-    
-    return path;
   }
   
   /**
@@ -320,7 +321,7 @@ public class WorkdirChooser
    */
   private void apply()
   {
-    String dir = this.getDir();
+    String dir = this.getDir(false);
     if (dir == null)
       return;
     


=====================================
test/de/willuhn/jameica/system/VersionTest.java
=====================================
--- a/test/de/willuhn/jameica/system/VersionTest.java
+++ b/test/de/willuhn/jameica/system/VersionTest.java
@@ -26,7 +26,7 @@ public class VersionTest
   @Test
   public void test001()
   {
-    test("1.0.0",1,0,0,"");
+    test("1.0.0",1,0,0,null);
   }
   
   /**
@@ -35,7 +35,7 @@ public class VersionTest
   @Test
   public void test002()
   {
-    test("1.2.3",1,2,3,"");
+    test("1.2.3",1,2,3,null);
   }
 
   /**
@@ -63,6 +63,65 @@ public class VersionTest
   public void test005()
   {
     Version v = new Version("1.0.0-foobar");
+    Assert.assertTrue(v.compliesTo("1(+)"));
+    Assert.assertTrue(v.compliesTo("1.0(+)"));
+    Assert.assertTrue(v.compliesTo("1.0.0(+)"));
+    Assert.assertTrue(v.compliesTo("1(-)"));
+    Assert.assertTrue(v.compliesTo("1.0(-)"));
+    Assert.assertTrue(v.compliesTo("1.0.0(-)"));
+
+    Assert.assertTrue(v.compliesTo("1.0.0"));
+
+    Assert.assertFalse(v.compliesTo("1.0.1(+)"));
+    Assert.assertFalse(v.compliesTo("0.9(-)"));
+  }
+  
+  /**
+   * 
+   */
+  @Test
+  public void test006()
+  {
+    Version v = new Version("1.2.0-foobar");
+    Assert.assertTrue(v.compliesTo("1(+)"));
+    Assert.assertFalse(v.compliesTo("2(+)"));
+    
+    Assert.assertTrue(v.compliesTo("1.1(+)"));
+    Assert.assertTrue(v.compliesTo("1.2(+)"));
+    Assert.assertFalse(v.compliesTo("1.3(+)"));
+    
+    Assert.assertTrue(v.compliesTo("1.2.0(+)"));
+    Assert.assertFalse(v.compliesTo("1.1.0(+)"));
+    Assert.assertFalse(v.compliesTo("1.2.2(+)"));
+  }
+
+  /**
+   * 
+   */
+  @Test
+  public void test007()
+  {
+    Version v = new Version("2.2.0-foobar");
+    Assert.assertTrue(v.compliesTo("2(-)"));
+    Assert.assertFalse(v.compliesTo("1(-)"));
+    
+    Assert.assertTrue(v.compliesTo("2.2(-)"));
+    Assert.assertTrue(v.compliesTo("2.3(-)"));
+    Assert.assertFalse(v.compliesTo("2.1(-)"));
+    
+    Assert.assertTrue(v.compliesTo("2.2.0(-)"));
+    Assert.assertTrue(v.compliesTo("2.2.1(-)"));
+    Assert.assertFalse(v.compliesTo("2.1.0(-)"));
+    Assert.assertFalse(v.compliesTo("1.2.2(-)"));
+  }
+
+  /**
+   * 
+   */
+  @Test
+  public void test008()
+  {
+    Version v = new Version("1.0.0-foobar");
     Assert.assertTrue(v.compliesTo("1+"));
     Assert.assertTrue(v.compliesTo("1.0+"));
     Assert.assertTrue(v.compliesTo("1.0.0+"));
@@ -80,7 +139,60 @@ public class VersionTest
    * 
    */
   @Test
-  public void test006()
+  public void test009()
+  {
+    Version v = new Version("1.2.0-foobar");
+    Assert.assertTrue(v.compliesTo("1+"));
+    Assert.assertFalse(v.compliesTo("2+"));
+    
+    Assert.assertTrue(v.compliesTo("1.1+"));
+    Assert.assertTrue(v.compliesTo("1.2+"));
+    Assert.assertFalse(v.compliesTo("1.3+"));
+    
+    Assert.assertTrue(v.compliesTo("0.2.0+"));
+    Assert.assertTrue(v.compliesTo("1.2.0+"));
+    Assert.assertTrue(v.compliesTo("1.1.0+"));
+    Assert.assertFalse(v.compliesTo("1.2.2+"));
+  }
+
+  /**
+   * 
+   */
+  @Test
+  public void test010()
+  {
+    Version v = new Version("2.2.0-foobar");
+    Assert.assertFalse(v.compliesTo("2-"));
+    Assert.assertFalse(v.compliesTo("1-"));
+    
+    Assert.assertTrue(v.compliesTo("2.2-"));
+    Assert.assertTrue(v.compliesTo("2.3-"));
+    Assert.assertFalse(v.compliesTo("2.1-"));
+    
+    Assert.assertTrue(v.compliesTo("2.2.0-"));
+    Assert.assertTrue(v.compliesTo("2.2.1-"));
+    Assert.assertFalse(v.compliesTo("2.1.0-"));
+    Assert.assertFalse(v.compliesTo("1.2.2-"));
+  }
+
+
+  /**
+   * 
+   */
+  @Test
+  public void test011()
+  {
+    Version v = new Version("2.2.0-foobar");
+    Assert.assertTrue(v.compliesTo("2.2.0"));
+    Assert.assertFalse(v.compliesTo("2.2.1"));
+    Assert.assertFalse(v.compliesTo("2.1.0"));
+  }
+
+  /**
+   * 
+   */
+  @Test
+  public void test012()
   {
     Version v1 = new Version("1.0.1-foo");
     Version v2 = new Version("1.0.2-bar");
@@ -91,7 +203,7 @@ public class VersionTest
    * 
    */
   @Test
-  public void test007()
+  public void test013()
   {
     Version v1 = new Version("1.0.1-foo");
     Version v2 = new Version("1.0.1-bar");
@@ -102,7 +214,7 @@ public class VersionTest
    * 
    */
   @Test
-  public void test008()
+  public void test014()
   {
     Version v1 = new Version("1.0.2-foo");
     Version v2 = new Version("1.0.1-bar");



View it on GitLab: https://salsa.debian.org/java-team/jameica/commit/14a028fd9d501c87904126198b9637aa59a31b4d

-- 
View it on GitLab: https://salsa.debian.org/java-team/jameica/commit/14a028fd9d501c87904126198b9637aa59a31b4d
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20180813/b6d6ac27/attachment.html>


More information about the pkg-java-commits mailing list