packed into mac app

This commit is contained in:
Manfred Karrer 2014-07-07 18:59:55 +02:00
parent 65d97819ac
commit 5a04af595b
7 changed files with 50 additions and 44 deletions

View File

@ -146,10 +146,6 @@
<pathelement location="${path.variable.maven_repository}/com/lambdaworks/scrypt/1.3.3/scrypt-1.3.3.jar"/>
</path>
<path id="library.maven:_com.madgag.spongycastle:core:1.50.0.0.classpath">
<pathelement location="${path.variable.maven_repository}/com/madgag/spongycastle/core/1.50.0.0/core-1.50.0.0.jar"/>
</path>
<path id="library.maven:_com.madgag:sc-light-jdk15on:1.47.0.2.classpath">
<pathelement location="${path.variable.maven_repository}/com/madgag/sc-light-jdk15on/1.47.0.2/sc-light-jdk15on-1.47.0.2.jar"/>
</path>
@ -259,7 +255,6 @@
<path refid="library.maven:_net.glxn:qrgen:1.3.classpath"/>
<path refid="library.maven:_com.google.zxing:javase:2.0.classpath"/>
<path refid="library.maven:_com.google.zxing:core:2.0.classpath"/>
<path refid="library.maven:_com.madgag.spongycastle:core:1.50.0.0.classpath"/>
<path refid="library.maven:_org.jetbrains:annotations:13.0.classpath"/>
</path>
@ -287,7 +282,6 @@
<path refid="library.maven:_net.glxn:qrgen:1.3.classpath"/>
<path refid="library.maven:_com.google.zxing:javase:2.0.classpath"/>
<path refid="library.maven:_com.google.zxing:core:2.0.classpath"/>
<path refid="library.maven:_com.madgag.spongycastle:core:1.50.0.0.classpath"/>
<path refid="library.maven:_org.jetbrains:annotations:13.0.classpath"/>
</path>
@ -318,7 +312,6 @@
<path refid="library.maven:_net.glxn:qrgen:1.3.classpath"/>
<path refid="library.maven:_com.google.zxing:javase:2.0.classpath"/>
<path refid="library.maven:_com.google.zxing:core:2.0.classpath"/>
<path refid="library.maven:_com.madgag.spongycastle:core:1.50.0.0.classpath"/>
<path refid="library.maven:_org.jetbrains:annotations:13.0.classpath"/>
</path>
@ -349,7 +342,6 @@
<path refid="library.maven:_net.glxn:qrgen:1.3.classpath"/>
<path refid="library.maven:_com.google.zxing:javase:2.0.classpath"/>
<path refid="library.maven:_com.google.zxing:core:2.0.classpath"/>
<path refid="library.maven:_com.madgag.spongycastle:core:1.50.0.0.classpath"/>
<path refid="library.maven:_org.jetbrains:annotations:13.0.classpath"/>
</path>

11
pom.xml
View File

@ -108,11 +108,6 @@
<artifactId>bitcoinj</artifactId>
<version>0.11.3</version>
</dependency>
<dependency>
<groupId>com.madgag</groupId>
<artifactId>sc-light-jdk15on</artifactId>
<version>1.47.0.2</version>
</dependency>
<dependency>
<groupId>net.tomp2p</groupId>
@ -189,12 +184,6 @@
<version>1.3</version>
</dependency>
<dependency>
<groupId>com.madgag.spongycastle</groupId>
<artifactId>core</artifactId>
<version>1.50.0.0</version>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>

View File

@ -35,6 +35,7 @@ import org.slf4j.LoggerFactory;
public class BitSquare extends Application
{
private static final Logger log = LoggerFactory.getLogger(BitSquare.class);
public static String ID = "bitsquare";
private static Stage primaryStage;
private WalletFacade walletFacade;
@ -59,11 +60,12 @@ public class BitSquare extends Application
log.trace("Startup: start");
BitSquare.primaryStage = primaryStage;
Thread.currentThread().setUncaughtExceptionHandler((thread, throwable) -> Popups.handleUncaughtExceptions(Throwables.getRootCause(throwable)));
// use a local data dir as default storage dir (can be overwritten in the settings)
// TODO save root preferences always in app dir top get preferred storage location
StorageDirectory.setStorageDirectory(new File(StorageDirectory.getApplicationDirectory().getAbsolutePath() + "/data"));
Thread.currentThread().setUncaughtExceptionHandler((thread, throwable) -> Popups.handleUncaughtExceptions(Throwables.getRootCause(throwable)));
// currently there is not SystemTray support for java fx (planned for version 3) so we use the old AWT
AWTSystemTray.createSystemTray(primaryStage);

View File

@ -3,12 +3,17 @@ package io.bitsquare;
import net.tomp2p.p2p.Peer;
import net.tomp2p.p2p.PeerMaker;
import net.tomp2p.peers.Number160;
import net.tomp2p.peers.PeerAddress;
import net.tomp2p.peers.PeerMapChangeListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Network node for relaying p2p msg
*/
class RelayNode
{
private static final Logger log = LoggerFactory.getLogger(RelayNode.class);
private static final Number160 ID = Number160.createHash(1);
private static Peer masterPeer = null;
@ -32,6 +37,26 @@ class RelayNode
masterPeer = new PeerMaker(ID).setPorts(port).makeAndListen();
// masterPeer = new PeerMaker(ID).setPorts(port).setBagSize(100).makeAndListen(); // setBagSize cause sync problems...
masterPeer.getBroadcastRPC().getConnectionBean().getConnectionReservation().reserve(3).awaitUninterruptibly();
masterPeer.getConnectionHandler().getPeerBean().getPeerMap().addPeerMapChangeListener(new PeerMapChangeListener()
{
@Override
public void peerInserted(PeerAddress peerAddress)
{
log.info("peerInserted " + peerAddress);
}
@Override
public void peerRemoved(PeerAddress peerAddress)
{
log.info("peerRemoved " + peerAddress);
}
@Override
public void peerUpdated(PeerAddress peerAddress)
{
log.info("peerUpdated " + peerAddress);
}
});
}
}
}

View File

@ -29,7 +29,7 @@ public class BitSquareWalletAppKit extends WalletAppKit
{
if (!directory.mkdir())
{
throw new IOException("Could not create named directory.");
throw new IOException("Could not create named directory " + directory.getAbsolutePath());
}
}
FileInputStream walletStream = null;

View File

@ -41,28 +41,17 @@ public class StorageDirectory
public static File getApplicationDirectory()
{
File propertiesFile = new File(USER_PROPERTIES_FILE_NAME);
if (propertiesFile.exists())
{
return new File("");
}
File executionRoot = new File(StorageDirectory.class.getProtectionDomain().getCodeSource().getLocation().getFile());
log.trace("executionRoot " + executionRoot.getAbsolutePath());
// check if it is packed into a mac app (e.g.: "/Users/mk/Desktop/bitsquare.app/Contents/Java/bitsquare.jar")
if (executionRoot.getAbsolutePath().endsWith("/bitsquare.app/Contents/Java/bitsquare.jar") && System.getProperty("os.name").startsWith("Mac"))
return executionRoot.getParentFile().getParentFile().getParentFile().getParentFile();
else if (executionRoot.getAbsolutePath().endsWith("/target/classes"))
return executionRoot.getParentFile(); // dev e.g.: /Users/mk/Documents/_intellij/bitsquare/target/classes -> use target as root
else if (executionRoot.getAbsolutePath().endsWith("/bitsquare.jar"))
return executionRoot.getParentFile(); // dev with jar e.g.: Users/mk/Documents/_intellij/bitsquare/out/artifacts/bitsquare2/bitsquare.jar -> use target as root
else
{
// when running form a packed app the file structure is different on mac
String operatingSystemName = System.getProperty("os.name");
if (operatingSystemName != null && operatingSystemName.startsWith("Mac"))
{
if (new File("../../../../" + USER_PROPERTIES_FILE_NAME).exists())
{
return new File("../../../..");
}
else
{
return null;
}
}
return null;
}
return executionRoot;
}
public static File getSystemApplicationDataDirectory()
@ -82,7 +71,7 @@ public class StorageDirectory
{
boolean created = storageDirectory.mkdir();
if (!created)
log.error("Could not create the application data directory of '" + storageDirectory + "'");
throw new RuntimeException("Could not create the application data directory of '" + storageDirectory + "'");
}
}
}

View File

@ -9,14 +9,23 @@
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>bitsquare_out.log</file>
<append>false</append>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg %xEx%n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="CONSOLE_APPENDER"/>
<appender-ref ref="FILE"/>
</root>
<logger name="io.bitsquare" level="TRACE"/>
<logger name="com.google.bitcoin" level="INFO"/>
<logger name="net.tomp2p" level="WARN"/>
<logger name="net.tomp2p" level="INFO"/>
<!--
-->