Provide earlier feedback in the UI when connecting to a new contact.

Partially addresses issue #3611924.
This commit is contained in:
akwizgran
2013-05-15 18:22:04 +01:00
parent 07ab659c6b
commit 635973c845
7 changed files with 114 additions and 29 deletions

View File

@@ -91,10 +91,12 @@ class AliceConnector extends Connector {
secret = deriveMasterSecret(hash, key, true);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
group.keyAgreementFailed();
tryToClose(conn, true);
return;
} catch(GeneralSecurityException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
group.keyAgreementFailed();
tryToClose(conn, true);
return;
}
@@ -102,7 +104,7 @@ class AliceConnector extends Connector {
if(LOG.isLoggable(INFO)) LOG.info(pluginName + " agreement succeeded");
int[] codes = crypto.deriveConfirmationCodes(secret);
int aliceCode = codes[0], bobCode = codes[1];
group.connectionSucceeded(aliceCode, bobCode);
group.keyAgreementSucceeded(aliceCode, bobCode);
// Exchange confirmation results
try {
sendConfirmation(w);

View File

@@ -91,10 +91,12 @@ class BobConnector extends Connector {
secret = deriveMasterSecret(hash, key, false);
} catch(IOException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
group.keyAgreementFailed();
tryToClose(conn, true);
return;
} catch(GeneralSecurityException e) {
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
group.keyAgreementFailed();
tryToClose(conn, true);
return;
}
@@ -102,7 +104,7 @@ class BobConnector extends Connector {
if(LOG.isLoggable(INFO)) LOG.info(pluginName + " agreement succeeded");
int[] codes = crypto.deriveConfirmationCodes(secret);
int aliceCode = codes[0], bobCode = codes[1];
group.connectionSucceeded(bobCode, aliceCode);
group.keyAgreementSucceeded(bobCode, aliceCode);
// Exchange confirmation results
try {
if(receiveConfirmation(r)) group.remoteConfirmationSucceeded();

View File

@@ -101,7 +101,7 @@ class ConnectorGroup extends Thread implements InvitationTask {
public synchronized InvitationState addListener(InvitationListener l) {
listeners.add(l);
return new InvitationState(localInvitationCode, remoteInvitationCode,
localConfirmationCode, remoteConfirmationCode,
localConfirmationCode, remoteConfirmationCode, connected.get(),
connectionFailed, localCompared, remoteCompared, localMatched,
remoteMatched, remoteName);
}
@@ -202,16 +202,24 @@ class ConnectorGroup extends Thread implements InvitationTask {
}
boolean getAndSetConnected() {
return connected.getAndSet(true);
boolean redundant = connected.getAndSet(true);
if(!redundant) {
for(InvitationListener l : listeners) l.connectionSucceeded();
}
return redundant;
}
void connectionSucceeded(int localCode, int remoteCode) {
void keyAgreementSucceeded(int localCode, int remoteCode) {
synchronized(this) {
localConfirmationCode = localCode;
remoteConfirmationCode = remoteCode;
}
for(InvitationListener l : listeners)
l.connectionSucceeded(localCode, remoteCode);
l.keyAgreementSucceeded(localCode, remoteCode);
}
void keyAgreementFailed() {
for(InvitationListener l : listeners) l.keyAgreementFailed();
}
void remoteConfirmationSucceeded() {