Compare commits

...

1 Commits

Author SHA1 Message Date
Torsten Grote 1aec948f18 Only show Introduction Accept Information if success is still possible 2018-04-28 11:45:10 -03:00
9 changed files with 43 additions and 10 deletions
@@ -124,9 +124,11 @@ abstract class ConversationItem {
text = ctx.getString( text = ctx.getString(
R.string.introduction_response_accepted_sent, R.string.introduction_response_accepted_sent,
ir.getName()); ir.getName());
if (ir.isSuccessPossible()) {
text += "\n\n" + ctx.getString( text += "\n\n" + ctx.getString(
R.string.introduction_response_accepted_sent_info, R.string.introduction_response_accepted_sent_info,
ir.getName()); ir.getName());
}
} else { } else {
text = ctx.getString( text = ctx.getString(
R.string.introduction_response_declined_sent, R.string.introduction_response_declined_sent,
@@ -22,7 +22,7 @@ public class IntroductionRequest extends IntroductionResponse {
@Nullable String message, boolean answered, boolean exists) { @Nullable String message, boolean answered, boolean exists) {
super(sessionId, messageId, groupId, role, time, local, sent, seen, super(sessionId, messageId, groupId, role, time, local, sent, seen,
read, name, accepted); read, name, accepted, false);
this.message = message; this.message = message;
this.answered = answered; this.answered = answered;
@@ -41,4 +41,11 @@ public class IntroductionRequest extends IntroductionResponse {
public boolean contactExists() { public boolean contactExists() {
return exists; return exists;
} }
@Override
public boolean isSuccessPossible() {
// TODO fix this IntroductionMessage mess
throw new AssertionError();
}
} }
@@ -12,16 +12,18 @@ import javax.annotation.concurrent.Immutable;
public class IntroductionResponse extends IntroductionMessage { public class IntroductionResponse extends IntroductionMessage {
private final String name; private final String name;
private final boolean accepted; private final boolean accepted, successPossible;
public IntroductionResponse(SessionId sessionId, MessageId messageId, public IntroductionResponse(SessionId sessionId, MessageId messageId,
GroupId groupId, Role role, long time, boolean local, boolean sent, GroupId groupId, Role role, long time, boolean local, boolean sent,
boolean seen, boolean read, String name, boolean accepted) { boolean seen, boolean read, String name, boolean accepted,
boolean successPossible) {
super(sessionId, messageId, groupId, role, time, local, sent, seen, super(sessionId, messageId, groupId, role, time, local, sent, seen,
read); read);
this.name = name; this.name = name;
this.accepted = accepted; this.accepted = accepted;
this.successPossible = successPossible;
} }
public String getName() { public String getName() {
@@ -32,4 +34,8 @@ public class IntroductionResponse extends IntroductionMessage {
return accepted; return accepted;
} }
public boolean isSuccessPossible() {
return successPossible;
}
} }
@@ -149,11 +149,12 @@ abstract class AbstractProtocolEngine<S extends Session>
throws DbException { throws DbException {
AuthorId localAuthorId = identityManager.getLocalAuthor(txn).getId(); AuthorId localAuthorId = identityManager.getLocalAuthor(txn).getId();
Contact c = contactManager.getContact(txn, sender, localAuthorId); Contact c = contactManager.getContact(txn, sender, localAuthorId);
boolean possible = s.getState().successPossible();
IntroductionResponse response = IntroductionResponse response =
new IntroductionResponse(s.getSessionId(), m.getMessageId(), new IntroductionResponse(s.getSessionId(), m.getMessageId(),
m.getGroupId(), s.getRole(), m.getTimestamp(), false, m.getGroupId(), s.getRole(), m.getTimestamp(), false,
false, false, false, otherAuthor.getName(), false, false, false, otherAuthor.getName(),
m instanceof AcceptMessage); m instanceof AcceptMessage, possible);
IntroductionResponseReceivedEvent e = IntroductionResponseReceivedEvent e =
new IntroductionResponseReceivedEvent(c.getId(), response); new IntroductionResponseReceivedEvent(c.getId(), response);
txn.attach(e); txn.attach(e);
@@ -34,4 +34,10 @@ enum IntroduceeState implements State {
throw new FormatException(); throw new FormatException();
} }
@Override
public boolean successPossible() {
return this != START && this != LOCAL_DECLINED &&
this != REMOTE_DECLINED;
}
} }
@@ -34,4 +34,9 @@ enum IntroducerState implements State {
throw new FormatException(); throw new FormatException();
} }
@Override
public boolean successPossible() {
return this != START && this != A_DECLINED && this != B_DECLINED;
}
} }
@@ -470,6 +470,7 @@ class IntroductionManagerImpl extends ConversationClientImpl
Role role = sessionParser.getRole(bdfSession); Role role = sessionParser.getRole(bdfSession);
SessionId sessionId; SessionId sessionId;
Author author; Author author;
boolean successPossible;
if (role == INTRODUCER) { if (role == INTRODUCER) {
IntroducerSession session = IntroducerSession session =
sessionParser.parseIntroducerSession(bdfSession); sessionParser.parseIntroducerSession(bdfSession);
@@ -479,15 +480,18 @@ class IntroductionManagerImpl extends ConversationClientImpl
} else { } else {
author = session.getIntroduceeA().author; author = session.getIntroduceeA().author;
} }
successPossible = session.getState().successPossible();
} else if (role == INTRODUCEE) { } else if (role == INTRODUCEE) {
IntroduceeSession session = sessionParser IntroduceeSession session = sessionParser
.parseIntroduceeSession(contactGroupId, bdfSession); .parseIntroduceeSession(contactGroupId, bdfSession);
sessionId = session.getSessionId(); sessionId = session.getSessionId();
author = session.getRemote().author; author = session.getRemote().author;
successPossible = session.getState().successPossible();
} else throw new AssertionError(); } else throw new AssertionError();
return new IntroductionResponse(sessionId, m, contactGroupId, return new IntroductionResponse(sessionId, m, contactGroupId,
role, meta.getTimestamp(), meta.isLocal(), status.isSent(), role, meta.getTimestamp(), meta.isLocal(), status.isSent(),
status.isSeen(), meta.isRead(), author.getName(), accept); status.isSeen(), meta.isRead(), author.getName(), accept,
successPossible);
} }
private void removeSessionWithIntroducer(Transaction txn, private void removeSessionWithIntroducer(Transaction txn,
@@ -4,4 +4,6 @@ interface State {
int getValue(); int getValue();
boolean successPossible();
} }
@@ -415,8 +415,8 @@ public class IntroductionIntegrationTest
eventWaiter.await(TIMEOUT, 1); eventWaiter.await(TIMEOUT, 1);
assertTrue(listener0.response2Received); assertTrue(listener0.response2Received);
// Forward AUTH // Forward AUTH and response
sync0To1(1, true); sync0To1(2, true);
// Second AUTH and ACTIVATE and forward them // Second AUTH and ACTIVATE and forward them
sync1To0(2, true); sync1To0(2, true);