import java.util.List;
import java.util.Properties;
-import javax.swing.JFrame;
-
import de.todesbaum.jsite.application.Freenet7Interface;
import de.todesbaum.jsite.main.Main;
import de.todesbaum.jsite.main.Version;
/** Last found version. */
private Version lastVersion = Main.getVersion();
- /** The parent of the dialog. */
- private final JFrame parent;
-
/** The freenet interface. */
private final Freenet7Interface freenetInterface;
* Creates a new update checker that uses the given frame as its parent and
* communications via the given freenet interface.
*
- * @param parent
- * The parent of the dialog
* @param freenetInterface
* The freenet interface
*/
- public UpdateChecker(JFrame parent, Freenet7Interface freenetInterface) {
- this.parent = parent;
+ public UpdateChecker(Freenet7Interface freenetInterface) {
this.freenetInterface = freenetInterface;
}
e1.printStackTrace();
}
Client client = new Client(connection);
+ boolean checkNow = false;
+ int currentEdition = lastUpdateEdition;
while (!shouldStop()) {
- System.out.println("Trying " + constructUpdateKey(lastUpdateEdition));
+ checkNow = false;
+ System.out.println("Trying " + constructUpdateKey(currentEdition));
ClientGet clientGet = new ClientGet("get-update-key");
- clientGet.setUri(constructUpdateKey(lastUpdateEdition));
+ clientGet.setUri(constructUpdateKey(currentEdition));
clientGet.setPersistence(Persistence.CONNECTION);
clientGet.setReturnType(ReturnType.direct);
clientGet.setVerbosity(Verbosity.ALL);
}
if (editionNumber != -1) {
System.out.println("Found new edition " + editionNumber);
+ currentEdition = editionNumber;
lastUpdateEdition = editionNumber;
+ checkNow = true;
break;
}
}
if (foundVersionString != null) {
Version foundVersion = Version.parse(foundVersionString);
if (foundVersion != null) {
- if (foundVersion.compareTo(Main.getVersion()) > 0) {
- lastVersion = foundVersion;
- String versionTimestampString = properties.getProperty("jSite.Date");
- long versionTimestamp = -1;
- try {
- versionTimestamp = Long.parseLong(versionTimestampString);
- } catch (NumberFormatException nfe1) {
- /* ignore. */
- }
- fireUpdateFound(foundVersion, versionTimestamp);
+ lastVersion = foundVersion;
+ String versionTimestampString = properties.getProperty("jSite.Date");
+ System.out.println(versionTimestampString);
+ long versionTimestamp = -1;
+ try {
+ versionTimestamp = Long.parseLong(versionTimestampString);
+ } catch (NumberFormatException nfe1) {
+ /* ignore. */
}
+ fireUpdateFound(foundVersion, versionTimestamp);
+ stop = true;
+ checkNow = true;
+ ++currentEdition;
}
}
}
System.out.println("Got IOException: " + e.getMessage());
e.printStackTrace();
}
+ if (!checkNow && !shouldStop()) {
+ synchronized (syncObject) {
+ try {
+ syncObject.wait(15 * 60 * 1000);
+ } catch (InterruptedException ie1) {
+ /* ignore. */
+ }
+ }
+ }
}
}
}