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

View File

@@ -124,9 +124,11 @@ abstract class ConversationItem {
text = ctx.getString(
R.string.introduction_response_accepted_sent,
ir.getName());
text += "\n\n" + ctx.getString(
R.string.introduction_response_accepted_sent_info,
ir.getName());
if (ir.isSuccessPossible()) {
text += "\n\n" + ctx.getString(
R.string.introduction_response_accepted_sent_info,
ir.getName());
}
} else {
text = ctx.getString(
R.string.introduction_response_declined_sent,

View File

@@ -22,7 +22,7 @@ public class IntroductionRequest extends IntroductionResponse {
@Nullable String message, boolean answered, boolean exists) {
super(sessionId, messageId, groupId, role, time, local, sent, seen,
read, name, accepted);
read, name, accepted, false);
this.message = message;
this.answered = answered;
@@ -41,4 +41,11 @@ public class IntroductionRequest extends IntroductionResponse {
public boolean contactExists() {
return exists;
}
@Override
public boolean isSuccessPossible() {
// TODO fix this IntroductionMessage mess
throw new AssertionError();
}
}

View File

@@ -12,16 +12,18 @@ import javax.annotation.concurrent.Immutable;
public class IntroductionResponse extends IntroductionMessage {
private final String name;
private final boolean accepted;
private final boolean accepted, successPossible;
public IntroductionResponse(SessionId sessionId, MessageId messageId,
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,
read);
this.name = name;
this.accepted = accepted;
this.successPossible = successPossible;
}
public String getName() {
@@ -32,4 +34,8 @@ public class IntroductionResponse extends IntroductionMessage {
return accepted;
}
public boolean isSuccessPossible() {
return successPossible;
}
}

View File

@@ -149,11 +149,12 @@ abstract class AbstractProtocolEngine<S extends Session>
throws DbException {
AuthorId localAuthorId = identityManager.getLocalAuthor(txn).getId();
Contact c = contactManager.getContact(txn, sender, localAuthorId);
boolean possible = s.getState().successPossible();
IntroductionResponse response =
new IntroductionResponse(s.getSessionId(), m.getMessageId(),
m.getGroupId(), s.getRole(), m.getTimestamp(), false,
false, false, false, otherAuthor.getName(),
m instanceof AcceptMessage);
m instanceof AcceptMessage, possible);
IntroductionResponseReceivedEvent e =
new IntroductionResponseReceivedEvent(c.getId(), response);
txn.attach(e);

View File

@@ -34,4 +34,10 @@ enum IntroduceeState implements State {
throw new FormatException();
}
@Override
public boolean successPossible() {
return this != START && this != LOCAL_DECLINED &&
this != REMOTE_DECLINED;
}
}

View File

@@ -34,4 +34,9 @@ enum IntroducerState implements State {
throw new FormatException();
}
@Override
public boolean successPossible() {
return this != START && this != A_DECLINED && this != B_DECLINED;
}
}

View File

@@ -470,6 +470,7 @@ class IntroductionManagerImpl extends ConversationClientImpl
Role role = sessionParser.getRole(bdfSession);
SessionId sessionId;
Author author;
boolean successPossible;
if (role == INTRODUCER) {
IntroducerSession session =
sessionParser.parseIntroducerSession(bdfSession);
@@ -479,15 +480,18 @@ class IntroductionManagerImpl extends ConversationClientImpl
} else {
author = session.getIntroduceeA().author;
}
successPossible = session.getState().successPossible();
} else if (role == INTRODUCEE) {
IntroduceeSession session = sessionParser
.parseIntroduceeSession(contactGroupId, bdfSession);
sessionId = session.getSessionId();
author = session.getRemote().author;
successPossible = session.getState().successPossible();
} else throw new AssertionError();
return new IntroductionResponse(sessionId, m, contactGroupId,
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,

View File

@@ -4,4 +4,6 @@ interface State {
int getValue();
boolean successPossible();
}

View File

@@ -415,8 +415,8 @@ public class IntroductionIntegrationTest
eventWaiter.await(TIMEOUT, 1);
assertTrue(listener0.response2Received);
// Forward AUTH
sync0To1(1, true);
// Forward AUTH and response
sync0To1(2, true);
// Second AUTH and ACTIVATE and forward them
sync1To0(2, true);