cleanup, deactivate updateservice

This commit is contained in:
Manfred Karrer 2015-11-05 23:59:49 +01:00
parent 81bf4b65d4
commit d33ebbed27
13 changed files with 45 additions and 66 deletions

View file

@ -118,19 +118,6 @@
<version>${project.parent.version}</version> <version>${project.parent.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.vinumeris</groupId>
<artifactId>updatefx</artifactId>
<version>1.3-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency> <dependency>
<groupId>org.controlsfx</groupId> <groupId>org.controlsfx</groupId>
<artifactId>controlsfx</artifactId> <artifactId>controlsfx</artifactId>

View file

@ -20,7 +20,6 @@ package io.bitsquare.app;
import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.Logger;
import com.google.inject.Guice; import com.google.inject.Guice;
import com.google.inject.Injector; import com.google.inject.Injector;
import com.vinumeris.updatefx.UpdateFX;
import io.bitsquare.alert.AlertManager; import io.bitsquare.alert.AlertManager;
import io.bitsquare.btc.WalletService; import io.bitsquare.btc.WalletService;
import io.bitsquare.common.UserThread; import io.bitsquare.common.UserThread;
@ -322,6 +321,7 @@ public class BitsquareApp extends Application {
} }
private void restart() { private void restart() {
gracefulShutDown(UpdateFX::restartApp); //TODO
//gracefulShutDown(UpdateFX::restartApp);
} }
} }

View file

@ -17,7 +17,6 @@
package io.bitsquare.app; package io.bitsquare.app;
import com.vinumeris.updatefx.UpdateFX;
import io.bitsquare.BitsquareException; import io.bitsquare.BitsquareException;
import io.bitsquare.btc.BitcoinNetwork; import io.bitsquare.btc.BitcoinNetwork;
import io.bitsquare.btc.RegTestHost; import io.bitsquare.btc.RegTestHost;
@ -29,7 +28,6 @@ import joptsimple.OptionSet;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
@ -38,6 +36,7 @@ import java.nio.file.Paths;
import static io.bitsquare.app.BitsquareEnvironment.*; import static io.bitsquare.app.BitsquareEnvironment.*;
import static java.util.Arrays.asList; import static java.util.Arrays.asList;
//TODO clean up
public class BitsquareAppMain extends BitsquareExecutable { public class BitsquareAppMain extends BitsquareExecutable {
private static final Logger log = LoggerFactory.getLogger(BitsquareAppMain.class); private static final Logger log = LoggerFactory.getLogger(BitsquareAppMain.class);
@ -63,15 +62,9 @@ public class BitsquareAppMain extends BitsquareExecutable {
} }
BitsquareEnvironment bitsquareEnvironment = new BitsquareEnvironment(options); BitsquareEnvironment bitsquareEnvironment = new BitsquareEnvironment(options);
// update dir need to be setup before UpdateFX bootstrap // need to call that before BitsquareAppMain().execute(args)
initAppDir(bitsquareEnvironment.getProperty(BitsquareEnvironment.APP_DATA_DIR_KEY)); initAppDir(bitsquareEnvironment.getProperty(BitsquareEnvironment.APP_DATA_DIR_KEY));
UpdateFX.bootstrap(BitsquareAppMain.class, new File(bitsquareEnvironment.getProperty(BitsquareEnvironment.APP_DATA_DIR_KEY)).toPath(), args);
}
// That will be called from UpdateFX after updates are checked
public static void realMain(String[] args) throws Exception {
//log.trace("realMain");
// For some reason the JavaFX launch process results in us losing the thread context class loader: reset it. // For some reason the JavaFX launch process results in us losing the thread context class loader: reset it.
// In order to work around a bug in JavaFX 8u25 and below, you must include the following code as the first line of your realMain method: // In order to work around a bug in JavaFX 8u25 and below, you must include the following code as the first line of your realMain method:
Thread.currentThread().setContextClassLoader(BitsquareAppMain.class.getClassLoader()); Thread.currentThread().setContextClassLoader(BitsquareAppMain.class.getClassLoader());
@ -122,7 +115,6 @@ public class BitsquareAppMain extends BitsquareExecutable {
.ofType(BitcoinNetwork.class) .ofType(BitcoinNetwork.class)
.withValuesConvertedBy(new EnumValueConverter(BitcoinNetwork.class)); .withValuesConvertedBy(new EnumValueConverter(BitcoinNetwork.class));
parser.accepts(RegTestHost.KEY, description("", RegTestHost.DEFAULT)) parser.accepts(RegTestHost.KEY, description("", RegTestHost.DEFAULT))
.withRequiredArg() .withRequiredArg()
.ofType(RegTestHost.class) .ofType(RegTestHost.class)

View file

@ -18,38 +18,30 @@
package io.bitsquare.app; package io.bitsquare.app;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.vinumeris.updatefx.Crypto;
import com.vinumeris.updatefx.UpdateFX;
import com.vinumeris.updatefx.UpdateSummary;
import com.vinumeris.updatefx.Updater;
import io.bitsquare.common.handlers.ResultHandler; import io.bitsquare.common.handlers.ResultHandler;
import io.bitsquare.common.util.Utilities;
import javafx.beans.property.ObjectProperty; import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleObjectProperty;
import org.bouncycastle.math.ec.ECPoint;
import org.reactfx.util.FxTimer;
import org.reactfx.util.Timer; import org.reactfx.util.Timer;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException; // TODO
import java.nio.file.Path; // Deactivated for the moment.
import java.nio.file.Paths; // UpdateFX use https for getting the version nr./jars, which we want to avoid with the Tor P2p network
import java.time.Duration; // We need to wait until tor is setup and then request from a hidden service the version and jars
import java.util.List;
public class UpdateProcess { public class UpdateProcess {
private static final Logger log = LoggerFactory.getLogger(UpdateProcess.class); private static final Logger log = LoggerFactory.getLogger(UpdateProcess.class);
private static final List<ECPoint> UPDATE_SIGNING_KEYS = Crypto.decode("029EF2D0D33A2546CB15FB10D969B7D65CAFB811CB3AC902E8D9A46BE847B1DA21"); // private static final List<ECPoint> UPDATE_SIGNING_KEYS = Crypto.decode("029EF2D0D33A2546CB15FB10D969B7D65CAFB811CB3AC902E8D9A46BE847B1DA21");
private static final String UPDATES_BASE_URL = "https://bitsquare.io/updateFX/v03"; // private static final String UPDATES_BASE_URL = "https://bitsquare.io/updateFX/v03";
private static final int UPDATE_SIGNING_THRESHOLD = 1; private static final int UPDATE_SIGNING_THRESHOLD = 1;
private static final Path ROOT_CLASS_PATH = UpdateFX.findCodePath(BitsquareAppMain.class); // private static final Path ROOT_CLASS_PATH = UpdateFX.findCodePath(BitsquareAppMain.class);
private final BitsquareEnvironment environment; private final BitsquareEnvironment environment;
private ResultHandler resultHandler; private ResultHandler resultHandler;
public enum State { public enum State {
INIT,
CHECK_FOR_UPDATES, CHECK_FOR_UPDATES,
UPDATE_AVAILABLE, UPDATE_AVAILABLE,
UP_TO_DATE, UP_TO_DATE,
@ -57,7 +49,7 @@ public class UpdateProcess {
FAILURE FAILURE
} }
public final ObjectProperty<State> state = new SimpleObjectProperty<>(State.CHECK_FOR_UPDATES); public final ObjectProperty<State> state = new SimpleObjectProperty<>(State.INIT);
private String releaseUrl; private String releaseUrl;
private Timer timeoutTimer; private Timer timeoutTimer;
@ -68,25 +60,29 @@ public class UpdateProcess {
} }
public void restart() { public void restart() {
UpdateFX.restartApp(); // UpdateFX.restartApp();
} }
public void setResultHandler(ResultHandler resultHandler) { public void setResultHandler(ResultHandler resultHandler) {
this.resultHandler = resultHandler; this.resultHandler = resultHandler;
resultHandler.handleResult();
} }
public void init() { public void init() {
log.info("UpdateFX checking for patch version " + Version.PATCH_VERSION);
//log.info("UpdateFX checking for patch version " + Version.PATCH_VERSION);
// process.timeout() will cause an error state back but we don't want to break startup in case of an timeout // process.timeout() will cause an error state back but we don't want to break startup in case of an timeout
timeoutTimer = FxTimer.runLater(Duration.ofMillis(10000), () -> { /* timeoutTimer = FxTimer.runLater(Duration.ofMillis(10000), () -> {
log.error("Timeout reached for UpdateFX"); log.error("Timeout reached for UpdateFX");
resultHandler.handleResult(); resultHandler.handleResult();
}); });
String userAgent = environment.getProperty(BitsquareEnvironment.APP_NAME_KEY) + Version.VERSION; String userAgent = environment.getProperty(BitsquareEnvironment.APP_NAME_KEY) + Version.VERSION;
*/
// Check if there is a new minor version release out. The release_url should be empty if no release is available, otherwise the download url. // Check if there is a new minor version release out. The release_url should be empty if no release is available, otherwise the download url.
try { /* try {
releaseUrl = Utilities.readTextFileFromServer(UPDATES_BASE_URL + "/release_url", userAgent); releaseUrl = Utilities.readTextFileFromServer(UPDATES_BASE_URL + "/release_url", userAgent);
if (releaseUrl != null && releaseUrl.length() > 0) { if (releaseUrl != null && releaseUrl.length() > 0) {
log.info("New release available at: " + releaseUrl); log.info("New release available at: " + releaseUrl);
@ -99,9 +95,9 @@ public class UpdateProcess {
} }
} catch (IOException e) { } catch (IOException e) {
// ignore. File might be missing // ignore. File might be missing
} }*/
Updater updater = new Updater(UPDATES_BASE_URL, userAgent, Version.PATCH_VERSION, /* Updater updater = new Updater(UPDATES_BASE_URL, userAgent, Version.PATCH_VERSION,
Paths.get(environment.getProperty(BitsquareEnvironment.APP_DATA_DIR_KEY)), Paths.get(environment.getProperty(BitsquareEnvironment.APP_DATA_DIR_KEY)),
ROOT_CLASS_PATH, UPDATE_SIGNING_KEYS, UPDATE_SIGNING_THRESHOLD) { ROOT_CLASS_PATH, UPDATE_SIGNING_KEYS, UPDATE_SIGNING_THRESHOLD) {
@Override @Override
@ -109,13 +105,13 @@ public class UpdateProcess {
//log.trace("updateProgress " + workDone + "/" + max); //log.trace("updateProgress " + workDone + "/" + max);
super.updateProgress(workDone, max); super.updateProgress(workDone, max);
} }
}; };*/
/* updater.progressProperty().addListener((observableValue, oldValue, newValue) -> { /* updater.progressProperty().addListener((observableValue, oldValue, newValue) -> {
log.trace("progressProperty newValue = " + newValue); log.trace("progressProperty newValue = " + newValue);
});*/ });*/
updater.setOnSucceeded(event -> { /* updater.setOnSucceeded(event -> {
try { try {
UpdateSummary summary = updater.get(); UpdateSummary summary = updater.get();
//log.info("summary " + summary.toString()); //log.info("summary " + summary.toString());
@ -159,7 +155,7 @@ public class UpdateProcess {
Thread thread = new Thread(updater, "Online update check"); Thread thread = new Thread(updater, "Online update check");
thread.setDaemon(true); thread.setDaemon(true);
thread.start(); thread.start();*/
} }
public String getReleaseUrl() { public String getReleaseUrl() {

View file

@ -146,6 +146,7 @@
} }
/* software update*/ /* software update*/
#image-update-in-progress { #image-update-in-progress {
-fx-image: url("../../../images/update/update_in_progress.png"); -fx-image: url("../../../images/update/update_in_progress.png");
} }

View file

@ -340,7 +340,9 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
}); });
ImageView updateIcon = new ImageView(); ImageView updateIcon = new ImageView();
updateIcon.setId(model.updateIconId.get()); String id = model.updateIconId.get();
if (id != null && !id.equals(""))
updateIcon.setId(id);
updateIconIdListener = (ov, oldValue, newValue) -> { updateIconIdListener = (ov, oldValue, newValue) -> {
updateIcon.setId(newValue); updateIcon.setId(newValue);
@ -410,8 +412,7 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
bitcoinNetworkLabel.setId("splash-error-state-msg"); bitcoinNetworkLabel.setId("splash-error-state-msg");
bitcoinNetworkLabel.setText("Not connected"); bitcoinNetworkLabel.setText("Not connected");
openBTCConnectionErrorPopup(newValue); openBTCConnectionErrorPopup(newValue);
} } else {
else {
bitcoinNetworkLabel.setId("footer-bitcoin-network-label"); bitcoinNetworkLabel.setId("footer-bitcoin-network-label");
bitcoinNetworkLabel.setText(model.bitcoinNetworkAsString); bitcoinNetworkLabel.setText(model.bitcoinNetworkAsString);
} }
@ -469,8 +470,7 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
bootstrapLabel.setText("Not connected"); bootstrapLabel.setText("Not connected");
new Popup().error("Connecting to the P2P network failed. \n" + newValue new Popup().error("Connecting to the P2P network failed. \n" + newValue
+ "\nPlease check your internet connection.").show(); + "\nPlease check your internet connection.").show();
} } else {
else {
bootstrapLabel.setId("footer-pane"); bootstrapLabel.setId("footer-pane");
bootstrapLabel.textProperty().bind(model.p2pNetworkInfoFooter); bootstrapLabel.textProperty().bind(model.p2pNetworkInfoFooter);
} }
@ -559,8 +559,7 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
this.setGraphicTextGap(newValue ? -1 : 0); this.setGraphicTextGap(newValue ? -1 : 0);
if (newValue) { if (newValue) {
this.getGraphic().setId("image-nav-" + viewId(viewClass) + "-active"); this.getGraphic().setId("image-nav-" + viewId(viewClass) + "-active");
} } else {
else {
this.getGraphic().setId("image-nav-" + viewId(viewClass)); this.getGraphic().setId("image-nav-" + viewId(viewClass));
} }
}); });

View file

@ -462,6 +462,10 @@ class MainViewModel implements ViewModel {
private void applyUpdateState(UpdateProcess.State state) { private void applyUpdateState(UpdateProcess.State state) {
switch (state) { switch (state) {
case INIT:
updateInfo.set("");
updateIconId.set(null);
break;
case CHECK_FOR_UPDATES: case CHECK_FOR_UPDATES:
updateInfo.set("Check for updates..."); updateInfo.set("Check for updates...");
updateIconId.set("image-update-in-progress"); updateIconId.set("image-update-in-progress");

View file

@ -85,8 +85,8 @@
<TextField fx:id="nodeAddress" GridPane.rowIndex="6" GridPane.columnIndex="1" <TextField fx:id="nodeAddress" GridPane.rowIndex="6" GridPane.columnIndex="1"
mouseTransparent="true" focusTraversable="false"/> mouseTransparent="true" focusTraversable="false"/>
<Label text="P2P bootstrap node addresses:" GridPane.rowIndex="7" GridPane.valignment="TOP"/> <Label text="P2P seed node addresses:" GridPane.rowIndex="7" GridPane.valignment="TOP"/>
<TextArea fx:id="bootstrapNodeAddress" GridPane.rowIndex="7" GridPane.columnIndex="1" <TextArea fx:id="seedNodeNodeAddress" GridPane.rowIndex="7" GridPane.columnIndex="1"
mouseTransparent="true" focusTraversable="false"/> mouseTransparent="true" focusTraversable="false"/>
<columnConstraints> <columnConstraints>

View file

@ -55,7 +55,7 @@ public class NetworkSettingsView extends InitializableView {
@FXML @FXML
ComboBox<BitcoinNetwork> netWorkComboBox; ComboBox<BitcoinNetwork> netWorkComboBox;
@FXML @FXML
TextArea bootstrapNodeAddress; TextArea seedNodeNodeAddress;
@Inject @Inject
public NetworkSettingsView(WalletService walletService, P2PService p2PService, SeedNodesRepository bootstrapNodes, Preferences preferences, BSFormatter public NetworkSettingsView(WalletService walletService, P2PService p2PService, SeedNodesRepository bootstrapNodes, Preferences preferences, BSFormatter

View file

@ -41,7 +41,7 @@
<module>common</module> <module>common</module>
<module>core</module> <module>core</module>
<module>network</module> <module>network</module>
<module>bootstrap</module> <module>seednode</module>
<module>gui</module> <module>gui</module>
</modules> </modules>

View file

@ -9,7 +9,7 @@
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>bootstrap</artifactId> <artifactId>seednode</artifactId>
<build> <build>
@ -41,7 +41,7 @@
<minimizeJar>false</minimizeJar> <minimizeJar>false</minimizeJar>
<transformers> <transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>io.bitsquare.app.bootstrap.BootstrapNodeMain</mainClass> <mainClass>io.bitsquare.p2p.seed.SeedNodeMain</mainClass>
</transformer> </transformer>
</transformers> </transformers>
<filters> <filters>
@ -65,7 +65,7 @@
<configuration> <configuration>
<shadedArtifactAttached>true</shadedArtifactAttached> <shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>bundled</shadedClassifierName> <shadedClassifierName>bundled</shadedClassifierName>
<finalName>BootstrapNodeMain</finalName> <finalName>SeedNodeMain</finalName>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>