Use PopupManager for queuing popups, improve version handling, deactivate focus requests, add popup when getting disconnection because of version conflict

This commit is contained in:
Manfred Karrer 2016-02-04 13:16:40 +01:00
parent ba4a228fed
commit a264fa4e0b
94 changed files with 421 additions and 288 deletions

View file

@ -25,7 +25,7 @@ import java.util.concurrent.TimeUnit;
public final class Alert implements PubKeyProtectedExpirablePayload {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
private static final long TTL = TimeUnit.DAYS.toMillis(10);

View file

@ -30,7 +30,7 @@ import java.util.concurrent.TimeUnit;
public final class Arbitrator implements PubKeyProtectedExpirablePayload {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
public static final long TTL = TimeUnit.DAYS.toMillis(10);

View file

@ -40,7 +40,7 @@ import java.util.List;
public class Dispute implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
private static final Logger log = LoggerFactory.getLogger(Dispute.class);
///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -32,7 +32,7 @@ import java.util.Date;
public class DisputeResult implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
private static final Logger log = LoggerFactory.getLogger(DisputeResult.class);
public enum FeePaymentPolicy {

View file

@ -34,7 +34,7 @@ import java.util.List;
public final class DisputeDirectMessage extends DisputeMessage {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
private static final Logger log = LoggerFactory.getLogger(DisputeDirectMessage.class);
private final long date;
@ -188,7 +188,7 @@ public final class DisputeDirectMessage extends DisputeMessage {
public static class Attachment implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
private static final Logger log = LoggerFactory.getLogger(Attachment.class);
private final byte[] bytes;

View file

@ -21,10 +21,10 @@ import io.bitsquare.app.Version;
import io.bitsquare.p2p.messaging.MailboxMessage;
public abstract class DisputeMessage implements MailboxMessage {
private final int networkId = Version.getNetworkId();
private final int messageVersion = Version.getP2PMessageVersion();
@Override
public int networkId() {
return networkId;
public int getMessageVersion() {
return messageVersion;
}
}

View file

@ -23,7 +23,7 @@ import io.bitsquare.p2p.NodeAddress;
public final class DisputeResultMessage extends DisputeMessage {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
public final DisputeResult disputeResult;
private final NodeAddress myNodeAddress;

View file

@ -23,7 +23,7 @@ import io.bitsquare.p2p.NodeAddress;
public final class OpenNewDisputeMessage extends DisputeMessage {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
public final Dispute dispute;
private final NodeAddress myNodeAddress;

View file

@ -23,7 +23,7 @@ import io.bitsquare.p2p.NodeAddress;
public final class PeerOpenedDisputeMessage extends DisputeMessage {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
public final Dispute dispute;
private final NodeAddress myNodeAddress;

View file

@ -24,7 +24,7 @@ import java.util.Arrays;
public final class PeerPublishedPayoutTxMessage extends DisputeMessage {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
public final byte[] transaction;
public final String tradeId;

View file

@ -24,7 +24,7 @@ import java.util.Arrays;
public class RawInput implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
public final long index;
public final byte[] parentTransaction;

View file

@ -23,7 +23,7 @@ import java.io.Serializable;
public class AliPayAccountContractData extends PaymentAccountContractData implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
private String accountNr;

View file

@ -23,7 +23,7 @@ import java.io.Serializable;
public class BlockChainAccountContractData extends PaymentAccountContractData implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
private String address;
// used in crypto note coins. not supported now but hopefully in future, so leave it for now.

View file

@ -23,7 +23,7 @@ import java.io.Serializable;
public class OKPayAccountContractData extends PaymentAccountContractData implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
private String accountNr;

View file

@ -24,7 +24,7 @@ import java.io.Serializable;
public abstract class PaymentAccountContractData implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
private final String paymentMethodName;
private final String id;

View file

@ -23,7 +23,7 @@ import java.io.Serializable;
public class PerfectMoneyAccountContractData extends PaymentAccountContractData implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
private String accountNr;

View file

@ -30,7 +30,7 @@ import java.util.stream.Collectors;
public class SepaAccountContractData extends PaymentAccountContractData implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
private static final Logger log = LoggerFactory.getLogger(SepaAccountContractData.class);

View file

@ -23,7 +23,7 @@ import java.io.Serializable;
public class SwishAccountContractData extends PaymentAccountContractData implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
private String mobileNr;
private String holderName;

View file

@ -36,7 +36,7 @@ import static com.google.common.base.Preconditions.checkArgument;
public class Contract implements Serializable {
// That object is sent over the wire, so we need to take care of version compatibility.
@JsonExclude
public static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
public static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
public final Offer offer;
private final long tradeAmount;

View file

@ -49,7 +49,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
public final class Offer implements PubKeyProtectedExpirablePayload {
// That object is sent over the wire, so we need to take care of version compatibility.
@JsonExclude
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
@JsonExclude
private static final Logger log = LoggerFactory.getLogger(Offer.class);
@ -58,7 +58,6 @@ public final class Offer implements PubKeyProtectedExpirablePayload {
"take that offer.";
public static final String TAC_TAKER = "With taking the offer I commit to the trade conditions as defined.";
public enum Direction {BUY, SELL}
public enum State {
@ -71,12 +70,11 @@ public final class Offer implements PubKeyProtectedExpirablePayload {
}
// key attributes for lookup
private final String id;
private final Direction direction;
private final String currencyCode;
private final long date;
private final long protocolVersion;
private final long fiatPrice;
private final long amount;
private final long minAmount;
@ -138,6 +136,8 @@ public final class Offer implements PubKeyProtectedExpirablePayload {
this.arbitratorNodeAddresses = arbitratorNodeAddresses;
this.acceptedCountryCodes = acceptedCountryCodes;
protocolVersion = Version.TRADE_PROTOCOL_VERSION;
date = new Date().getTime();
setState(State.UNDEFINED);
}
@ -258,6 +258,9 @@ public final class Offer implements PubKeyProtectedExpirablePayload {
return pubKeyRing.getSignaturePubKey();
}
public long getProtocolVersion() {
return protocolVersion;
}
public String getId() {
return id;

View file

@ -22,7 +22,7 @@ import io.bitsquare.common.crypto.PubKeyRing;
public final class OfferAvailabilityRequest extends OfferMessage {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
private final PubKeyRing pubKeyRing;

View file

@ -21,7 +21,7 @@ import io.bitsquare.app.Version;
public final class OfferAvailabilityResponse extends OfferMessage {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
public final boolean isAvailable;

View file

@ -25,9 +25,9 @@ import javax.annotation.concurrent.Immutable;
@Immutable
public abstract class OfferMessage implements DirectMessage {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
private final int networkId = Version.getNetworkId();
private final int messageVersion = Version.getP2PMessageVersion();
public final String offerId;
protected OfferMessage(String offerId) {
@ -35,14 +35,14 @@ public abstract class OfferMessage implements DirectMessage {
}
@Override
public int networkId() {
return networkId;
public int getMessageVersion() {
return messageVersion;
}
@Override
public String toString() {
return "OfferMessage{" +
"networkId=" + networkId +
"messageVersion=" + messageVersion +
", offerId='" + offerId + '\'' +
'}';
}

View file

@ -27,7 +27,7 @@ import java.util.Arrays;
@Immutable
public final class DepositTxPublishedMessage extends TradeMessage implements MailboxMessage {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
public final byte[] depositTx;
private final NodeAddress senderNodeAddress;

View file

@ -26,7 +26,7 @@ import javax.annotation.concurrent.Immutable;
@Immutable
public final class FiatTransferStartedMessage extends TradeMessage implements MailboxMessage {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
public final String buyerPayoutAddress;
private final NodeAddress senderNodeAddress;

View file

@ -27,7 +27,7 @@ import java.util.Arrays;
@Immutable
public final class FinalizePayoutTxRequest extends TradeMessage implements MailboxMessage {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
public final byte[] sellerSignature;
public final String sellerPayoutAddress;

View file

@ -31,7 +31,7 @@ import java.util.List;
@Immutable
public final class PayDepositRequest extends TradeMessage implements MailboxMessage {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
public final long tradeAmount;
public final byte[] takerTradeWalletPubKey;

View file

@ -27,7 +27,7 @@ import java.util.Arrays;
@Immutable
public final class PayoutTxFinalizedMessage extends TradeMessage implements MailboxMessage {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
public final byte[] payoutTx;
private final NodeAddress senderNodeAddress;

View file

@ -31,7 +31,7 @@ import java.util.List;
@Immutable
public final class PublishDepositTxRequest extends TradeMessage {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
private static final Logger log = LoggerFactory.getLogger(PublishDepositTxRequest.class);

View file

@ -25,9 +25,9 @@ import javax.annotation.concurrent.Immutable;
@Immutable
public abstract class TradeMessage implements DirectMessage {
// That object is sent over the wire, so we need to take care of version compatibility.
private static final long serialVersionUID = Version.NETWORK_PROTOCOL_VERSION;
private static final long serialVersionUID = Version.P2P_NETWORK_VERSION;
private final int networkId = Version.getNetworkId();
private final int messageVersion = Version.getP2PMessageVersion();
public final String tradeId;
@Override
@ -51,7 +51,7 @@ public abstract class TradeMessage implements DirectMessage {
}
@Override
public int networkId() {
return networkId;
public int getMessageVersion() {
return messageVersion;
}
}